Lots of random cleanups, mostly for native_theme_win.cc:
[chromium-blink-merge.git] / cc / layers / render_surface.cc
blob15e11875ea2b433478642520037b7ed854d5031c
1 // Copyright 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "cc/layers/render_surface.h"
7 #include "cc/base/math_util.h"
8 #include "cc/layers/layer.h"
9 #include "ui/gfx/transform.h"
11 namespace cc {
13 RenderSurface::RenderSurface(Layer* owning_layer)
14 : owning_layer_(owning_layer),
15 draw_opacity_(1),
16 draw_opacity_is_animating_(false),
17 target_surface_transforms_are_animating_(false),
18 screen_space_transforms_are_animating_(false),
19 is_clipped_(false),
20 contributes_to_drawn_surface_(false),
21 nearest_occlusion_immune_ancestor_(NULL) {}
23 RenderSurface::~RenderSurface() {
24 for (size_t i = 0; i < layer_list_.size(); ++i) {
25 DCHECK(!layer_list_.at(i)->render_surface()) <<
26 "RenderSurfaces should be cleared from the contributing layers " <<
27 "before destroying this surface to avoid leaking a circular " <<
28 "reference on the contributing layer. Probably the " <<
29 "RenderSurfaceLayerList should just be destroyed before destroying " <<
30 "any RenderSurfaces on layers.";
34 gfx::RectF RenderSurface::DrawableContentRect() const {
35 gfx::RectF drawable_content_rect =
36 MathUtil::MapClippedRect(draw_transform_, content_rect_);
37 if (owning_layer_->has_replica())
38 drawable_content_rect.Union(
39 MathUtil::MapClippedRect(replica_draw_transform_, content_rect_));
40 return drawable_content_rect;
43 void RenderSurface::ClearLayerLists() {
44 layer_list_.clear();
47 } // namespace cc