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"
13 RenderSurface::RenderSurface(Layer
* owning_layer
)
14 : owning_layer_(owning_layer
),
17 contributes_to_drawn_surface_(false),
18 nearest_occlusion_immune_ancestor_(nullptr) {
21 RenderSurface::~RenderSurface() {
22 for (size_t i
= 0; i
< layer_list_
.size(); ++i
) {
23 DCHECK(!layer_list_
.at(i
)->render_surface()) <<
24 "RenderSurfaces should be cleared from the contributing layers " <<
25 "before destroying this surface to avoid leaking a circular " <<
26 "reference on the contributing layer. Probably the " <<
27 "RenderSurfaceLayerList should just be destroyed before destroying " <<
28 "any RenderSurfaces on layers.";
32 gfx::RectF
RenderSurface::DrawableContentRect() const {
33 gfx::RectF drawable_content_rect
=
34 MathUtil::MapClippedRect(draw_transform_
, content_rect_
);
35 if (owning_layer_
->has_replica())
36 drawable_content_rect
.Union(
37 MathUtil::MapClippedRect(replica_draw_transform_
, content_rect_
));
38 return drawable_content_rect
;
41 void RenderSurface::ClearLayerLists() {