summaryrefslogtreecommitdiffstats
path: root/cc/layers/render_surface.cc
blob: 0eab856a9563c7f990793029adce0e236b4aa48f (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
37
38
39
40
41
42
43
// Copyright 2010 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 "cc/layers/render_surface.h"

#include "cc/base/math_util.h"
#include "cc/layers/layer.h"
#include "ui/gfx/transform.h"

namespace cc {

RenderSurface::RenderSurface(Layer* owning_layer)
    : owning_layer_(owning_layer),
      draw_opacity_(1),
      draw_opacity_is_animating_(false),
      target_surface_transforms_are_animating_(false),
      screen_space_transforms_are_animating_(false),
      is_clipped_(false),
      contributes_to_drawn_surface_(false),
      nearest_occlusion_immune_ancestor_(NULL) {}

RenderSurface::~RenderSurface() {
  for (size_t i = 0; i < layer_list_.size(); ++i) {
    DCHECK(!layer_list_.at(i)->render_surface()) <<
        "RenderSurfaces should be cleared from the contributing layers " <<
        "before destroying this surface to avoid leaking a circular " <<
        "reference on the contributing layer. Probably the " <<
        "RenderSurfaceLayerList should just be destroyed before destroying " <<
        "any RenderSurfaces on layers.";
  }
}

gfx::RectF RenderSurface::DrawableContentRect() const {
  gfx::RectF drawable_content_rect =
      MathUtil::MapClippedRect(draw_transform_, content_rect_);
  if (owning_layer_->has_replica())
    drawable_content_rect.Union(
        MathUtil::MapClippedRect(replica_draw_transform_, content_rect_));
  return drawable_content_rect;
}

}  // namespace cc