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/rect.h"
16 #include "ui/gfx/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(gfx::Rect content_rect) { content_rect_ = content_rect; }
33 gfx::Rect content_rect() const { return content_rect_; }
35 void SetDrawOpacity(float opacity) { draw_opacity_ = opacity; }
36 float draw_opacity() const { return draw_opacity_; }
38 void SetDrawOpacityIsAnimating(bool draw_opacity_is_animating) {
39 draw_opacity_is_animating_ = draw_opacity_is_animating;
41 bool draw_opacity_is_animating() const { return draw_opacity_is_animating_; }
43 void SetDrawTransform(const gfx::Transform& draw_transform) {
44 draw_transform_ = draw_transform;
46 const gfx::Transform& draw_transform() const { return draw_transform_; }
48 void SetScreenSpaceTransform(const gfx::Transform& screen_space_transform) {
49 screen_space_transform_ = screen_space_transform;
51 const gfx::Transform& screen_space_transform() const {
52 return screen_space_transform_;
55 void SetReplicaDrawTransform(const gfx::Transform& replica_draw_transform) {
56 replica_draw_transform_ = replica_draw_transform;
58 const gfx::Transform& replica_draw_transform() const {
59 return replica_draw_transform_;
62 void SetReplicaScreenSpaceTransform(
63 const gfx::Transform& replica_screen_space_transform) {
64 replica_screen_space_transform_ = replica_screen_space_transform;
66 const gfx::Transform& replica_screen_space_transform() const {
67 return replica_screen_space_transform_;
70 void SetTargetSurfaceTransformsAreAnimating(bool animating) {
71 target_surface_transforms_are_animating_ = animating;
73 bool target_surface_transforms_are_animating() const {
74 return target_surface_transforms_are_animating_;
76 void SetScreenSpaceTransformsAreAnimating(bool animating) {
77 screen_space_transforms_are_animating_ = animating;
79 bool screen_space_transforms_are_animating() const {
80 return screen_space_transforms_are_animating_;
83 bool is_clipped() const { return is_clipped_; }
84 void SetIsClipped(bool is_clipped) { is_clipped_ = is_clipped; }
86 gfx::Rect clip_rect() const { return clip_rect_; }
87 void SetClipRect(gfx::Rect clip_rect) { clip_rect_ = clip_rect; }
89 // When false, the RenderSurface does not contribute to another target
90 // RenderSurface that is being drawn for the current frame. It could still be
91 // drawn to as a target, but its output will not be a part of any other
93 bool contributes_to_drawn_surface() const {
94 return contributes_to_drawn_surface_;
96 void set_contributes_to_drawn_surface(bool contributes_to_drawn_surface) {
97 contributes_to_drawn_surface_ = contributes_to_drawn_surface;
100 RenderSurfaceLayerList& layer_list() { return layer_list_; }
101 // A no-op since DelegatedRendererLayers on the main thread don't have any
102 // RenderPasses so they can't contribute to a surface.
103 void AddContributingDelegatedRenderPassLayer(Layer* layer) {}
105 void SetNearestAncestorThatMovesPixels(RenderSurface* surface) {
106 nearest_ancestor_that_moves_pixels_ = surface;
108 const RenderSurface* nearest_ancestor_that_moves_pixels() const {
109 return nearest_ancestor_that_moves_pixels_;
113 friend struct LayerIteratorActions;
115 Layer* owning_layer_;
117 // Uses this surface's space.
118 gfx::Rect content_rect_;
121 bool draw_opacity_is_animating_;
122 gfx::Transform draw_transform_;
123 gfx::Transform screen_space_transform_;
124 gfx::Transform replica_draw_transform_;
125 gfx::Transform replica_screen_space_transform_;
126 bool target_surface_transforms_are_animating_;
127 bool screen_space_transforms_are_animating_;
130 bool contributes_to_drawn_surface_;
132 // Uses the space of the surface's target surface.
133 gfx::Rect clip_rect_;
135 RenderSurfaceLayerList layer_list_;
137 // The nearest ancestor target surface that will contain the contents of this
138 // surface, and that is going to move pixels within the surface (such as with
139 // a blur). This can point to itself.
140 RenderSurface* nearest_ancestor_that_moves_pixels_;
142 // For LayerIteratorActions
143 int target_render_surface_layer_index_history_;
144 int current_layer_index_history_;
146 DISALLOW_COPY_AND_ASSIGN(RenderSurface);
150 #endif // CC_LAYERS_RENDER_SURFACE_H_