summaryrefslogtreecommitdiffstats
path: root/chromium/ppapi/shared_impl/compositor_layer_data.cc
blob: a4b51d379c9a1906fa2aef165fd73d153e8a8797 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ppapi/shared_impl/compositor_layer_data.h"

namespace ppapi {

namespace {

template<typename T>
void Copy(scoped_ptr<T>* a, const scoped_ptr<T>& b) {
  if (b) {
    if (!(*a))
      a->reset(new T());
    **a = *b;
  } else {
    a->reset();
  }
}

}  // namespace

const CompositorLayerData& CompositorLayerData::operator=(
    const CompositorLayerData& other) {
  DCHECK(other.is_null() || other.is_valid());

  common = other.common;
  Copy(&color, other.color);
  Copy(&texture, other.texture);
  Copy(&image, other.image);

  return *this;
}

}  // namespace ppapi