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.
6 #ifndef CC_LAYERS_RENDER_SURFACE_H_
7 #define CC_LAYERS_RENDER_SURFACE_H_
11 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h"
13 #include "cc/base/cc_export.h"
14 #include "cc/layers/layer_lists.h"
15 #include "ui/gfx/geometry/rect.h"
16 #include "ui/gfx/geometry/rect_f.h"
17 #include "ui/gfx/transform.h"
23 class CC_EXPORT RenderSurface
{
25 explicit RenderSurface(Layer
* owning_layer
);
28 // Returns the rect that encloses the RenderSurfaceImpl including any
30 gfx::RectF
DrawableContentRect() const;
32 void SetContentRect(const gfx::Rect
& content_rect
) {
33 content_rect_
= content_rect
;
35 gfx::Rect
content_rect() const { return content_rect_
; }
37 void SetDrawOpacity(float opacity
) { draw_opacity_
= opacity
; }
38 float draw_opacity() const { return draw_opacity_
; }
40 void SetDrawTransform(const gfx::Transform
& draw_transform
) {
41 draw_transform_
= draw_transform
;
43 const gfx::Transform
& draw_transform() const { return draw_transform_
; }
45 void SetScreenSpaceTransform(const gfx::Transform
& screen_space_transform
) {
46 screen_space_transform_
= screen_space_transform
;
48 const gfx::Transform
& screen_space_transform() const {
49 return screen_space_transform_
;
52 void SetReplicaDrawTransform(const gfx::Transform
& replica_draw_transform
) {
53 replica_draw_transform_
= replica_draw_transform
;
55 const gfx::Transform
& replica_draw_transform() const {
56 return replica_draw_transform_
;
59 void SetReplicaScreenSpaceTransform(
60 const gfx::Transform
& replica_screen_space_transform
) {
61 replica_screen_space_transform_
= replica_screen_space_transform
;
63 const gfx::Transform
& replica_screen_space_transform() const {
64 return replica_screen_space_transform_
;
67 bool is_clipped() const { return is_clipped_
; }
68 void SetIsClipped(bool is_clipped
) { is_clipped_
= is_clipped
; }
70 gfx::Rect
clip_rect() const { return clip_rect_
; }
71 void SetClipRect(const gfx::Rect
& clip_rect
) { clip_rect_
= clip_rect
; }
73 // When false, the RenderSurface does not contribute to another target
74 // RenderSurface that is being drawn for the current frame. It could still be
75 // drawn to as a target, but its output will not be a part of any other
77 bool contributes_to_drawn_surface() const {
78 return contributes_to_drawn_surface_
;
80 void set_contributes_to_drawn_surface(bool contributes_to_drawn_surface
) {
81 contributes_to_drawn_surface_
= contributes_to_drawn_surface
;
84 LayerList
& layer_list() { return layer_list_
; }
85 // A no-op since DelegatedRendererLayers on the main thread don't have any
86 // RenderPasses so they can't contribute to a surface.
87 void AddContributingDelegatedRenderPassLayer(Layer
* layer
) {}
89 void SetNearestOcclusionImmuneAncestor(RenderSurface
* surface
) {
90 nearest_occlusion_immune_ancestor_
= surface
;
92 const RenderSurface
* nearest_occlusion_immune_ancestor() const {
93 return nearest_occlusion_immune_ancestor_
;
96 void ClearLayerLists();
101 // Uses this surface's space.
102 gfx::Rect content_rect_
;
105 gfx::Transform draw_transform_
;
106 gfx::Transform screen_space_transform_
;
107 gfx::Transform replica_draw_transform_
;
108 gfx::Transform replica_screen_space_transform_
;
111 bool contributes_to_drawn_surface_
;
113 // Uses the space of the surface's target surface.
114 gfx::Rect clip_rect_
;
116 LayerList layer_list_
;
118 // The nearest ancestor target surface that will contain the contents of this
119 // surface, and that ignores outside occlusion. This can point to itself.
120 RenderSurface
* nearest_occlusion_immune_ancestor_
;
122 DISALLOW_COPY_AND_ASSIGN(RenderSurface
);
126 #endif // CC_LAYERS_RENDER_SURFACE_H_