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. 4 5 6 #ifndef CC_LAYERS_RENDER_SURFACE_H_ 7 #define CC_LAYERS_RENDER_SURFACE_H_ 8 9 #include <vector> 10 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" 18 19 namespace cc { 20 21 class Layer; 22 23 class CC_EXPORT RenderSurface { 24 public: 25 explicit RenderSurface(Layer* owning_layer); 26 ~RenderSurface(); 27 28 // Returns the rect that encloses the RenderSurfaceImpl including any 29 // reflection. 30 gfx::RectF DrawableContentRect() const; 31 SetContentRect(gfx::Rect content_rect)32 void SetContentRect(gfx::Rect content_rect) { content_rect_ = content_rect; } content_rect()33 gfx::Rect content_rect() const { return content_rect_; } 34 SetDrawOpacity(float opacity)35 void SetDrawOpacity(float opacity) { draw_opacity_ = opacity; } draw_opacity()36 float draw_opacity() const { return draw_opacity_; } 37 SetDrawOpacityIsAnimating(bool draw_opacity_is_animating)38 void SetDrawOpacityIsAnimating(bool draw_opacity_is_animating) { 39 draw_opacity_is_animating_ = draw_opacity_is_animating; 40 } draw_opacity_is_animating()41 bool draw_opacity_is_animating() const { return draw_opacity_is_animating_; } 42 SetDrawTransform(const gfx::Transform & draw_transform)43 void SetDrawTransform(const gfx::Transform& draw_transform) { 44 draw_transform_ = draw_transform; 45 } draw_transform()46 const gfx::Transform& draw_transform() const { return draw_transform_; } 47 SetScreenSpaceTransform(const gfx::Transform & screen_space_transform)48 void SetScreenSpaceTransform(const gfx::Transform& screen_space_transform) { 49 screen_space_transform_ = screen_space_transform; 50 } screen_space_transform()51 const gfx::Transform& screen_space_transform() const { 52 return screen_space_transform_; 53 } 54 SetReplicaDrawTransform(const gfx::Transform & replica_draw_transform)55 void SetReplicaDrawTransform(const gfx::Transform& replica_draw_transform) { 56 replica_draw_transform_ = replica_draw_transform; 57 } replica_draw_transform()58 const gfx::Transform& replica_draw_transform() const { 59 return replica_draw_transform_; 60 } 61 SetReplicaScreenSpaceTransform(const gfx::Transform & replica_screen_space_transform)62 void SetReplicaScreenSpaceTransform( 63 const gfx::Transform& replica_screen_space_transform) { 64 replica_screen_space_transform_ = replica_screen_space_transform; 65 } replica_screen_space_transform()66 const gfx::Transform& replica_screen_space_transform() const { 67 return replica_screen_space_transform_; 68 } 69 SetTargetSurfaceTransformsAreAnimating(bool animating)70 void SetTargetSurfaceTransformsAreAnimating(bool animating) { 71 target_surface_transforms_are_animating_ = animating; 72 } target_surface_transforms_are_animating()73 bool target_surface_transforms_are_animating() const { 74 return target_surface_transforms_are_animating_; 75 } SetScreenSpaceTransformsAreAnimating(bool animating)76 void SetScreenSpaceTransformsAreAnimating(bool animating) { 77 screen_space_transforms_are_animating_ = animating; 78 } screen_space_transforms_are_animating()79 bool screen_space_transforms_are_animating() const { 80 return screen_space_transforms_are_animating_; 81 } 82 is_clipped()83 bool is_clipped() const { return is_clipped_; } SetIsClipped(bool is_clipped)84 void SetIsClipped(bool is_clipped) { is_clipped_ = is_clipped; } 85 clip_rect()86 gfx::Rect clip_rect() const { return clip_rect_; } SetClipRect(gfx::Rect clip_rect)87 void SetClipRect(gfx::Rect clip_rect) { clip_rect_ = clip_rect; } 88 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 92 // surface. contributes_to_drawn_surface()93 bool contributes_to_drawn_surface() const { 94 return contributes_to_drawn_surface_; 95 } set_contributes_to_drawn_surface(bool 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; 98 } 99 layer_list()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. AddContributingDelegatedRenderPassLayer(Layer * layer)103 void AddContributingDelegatedRenderPassLayer(Layer* layer) {} 104 SetNearestOcclusionImmuneAncestor(RenderSurface * surface)105 void SetNearestOcclusionImmuneAncestor(RenderSurface* surface) { 106 nearest_occlusion_immune_ancestor_ = surface; 107 } nearest_occlusion_immune_ancestor()108 const RenderSurface* nearest_occlusion_immune_ancestor() const { 109 return nearest_occlusion_immune_ancestor_; 110 } 111 112 private: 113 friend struct LayerIteratorActions; 114 115 Layer* owning_layer_; 116 117 // Uses this surface's space. 118 gfx::Rect content_rect_; 119 120 float draw_opacity_; 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_; 128 129 bool is_clipped_; 130 bool contributes_to_drawn_surface_; 131 132 // Uses the space of the surface's target surface. 133 gfx::Rect clip_rect_; 134 135 RenderSurfaceLayerList layer_list_; 136 137 // The nearest ancestor target surface that will contain the contents of this 138 // surface, and that ignores outside occlusion. This can point to itself. 139 RenderSurface* nearest_occlusion_immune_ancestor_; 140 141 // For LayerIteratorActions 142 int target_render_surface_layer_index_history_; 143 int current_layer_index_history_; 144 145 DISALLOW_COPY_AND_ASSIGN(RenderSurface); 146 }; 147 148 } // namespace cc 149 #endif // CC_LAYERS_RENDER_SURFACE_H_ 150