render_surface.h revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
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 "ui/gfx/rect.h" 15#include "ui/gfx/rect_f.h" 16#include "ui/gfx/transform.h" 17 18namespace cc { 19 20class Layer; 21 22class CC_EXPORT RenderSurface { 23 public: 24 explicit RenderSurface(Layer* owning_layer); 25 ~RenderSurface(); 26 27 // Returns the rect that encloses the RenderSurfaceImpl including any 28 // reflection. 29 gfx::RectF DrawableContentRect() const; 30 31 void SetContentRect(gfx::Rect content_rect) { content_rect_ = content_rect; } 32 gfx::Rect content_rect() const { return content_rect_; } 33 34 void SetDrawOpacity(float opacity) { draw_opacity_ = opacity; } 35 float draw_opacity() const { return draw_opacity_; } 36 37 void SetDrawOpacityIsAnimating(bool draw_opacity_is_animating) { 38 draw_opacity_is_animating_ = draw_opacity_is_animating; 39 } 40 bool draw_opacity_is_animating() const { return draw_opacity_is_animating_; } 41 42 void SetDrawTransform(const gfx::Transform& draw_transform) { 43 draw_transform_ = draw_transform; 44 } 45 const gfx::Transform& draw_transform() const { return draw_transform_; } 46 47 void SetScreenSpaceTransform(const gfx::Transform& screen_space_transform) { 48 screen_space_transform_ = screen_space_transform; 49 } 50 const gfx::Transform& screen_space_transform() const { 51 return screen_space_transform_; 52 } 53 54 void SetReplicaDrawTransform(const gfx::Transform& replica_draw_transform) { 55 replica_draw_transform_ = replica_draw_transform; 56 } 57 const gfx::Transform& replica_draw_transform() const { 58 return replica_draw_transform_; 59 } 60 61 void SetReplicaScreenSpaceTransform( 62 const gfx::Transform& replica_screen_space_transform) { 63 replica_screen_space_transform_ = replica_screen_space_transform; 64 } 65 const gfx::Transform& replica_screen_space_transform() const { 66 return replica_screen_space_transform_; 67 } 68 69 void SetTargetSurfaceTransformsAreAnimating(bool animating) { 70 target_surface_transforms_are_animating_ = animating; 71 } 72 bool target_surface_transforms_are_animating() const { 73 return target_surface_transforms_are_animating_; 74 } 75 void SetScreenSpaceTransformsAreAnimating(bool animating) { 76 screen_space_transforms_are_animating_ = animating; 77 } 78 bool screen_space_transforms_are_animating() const { 79 return screen_space_transforms_are_animating_; 80 } 81 82 bool is_clipped() const { return is_clipped_; } 83 void SetIsClipped(bool is_clipped) { is_clipped_ = is_clipped; } 84 85 gfx::Rect clip_rect() const { return clip_rect_; } 86 void SetClipRect(gfx::Rect clip_rect) { clip_rect_ = clip_rect; } 87 88 typedef std::vector<scoped_refptr<Layer> > LayerList; 89 LayerList& layer_list() { return layer_list_; } 90 // A no-op since DelegatedRendererLayers on the main thread don't have any 91 // RenderPasses so they can't contribute to a surface. 92 void AddContributingDelegatedRenderPassLayer(Layer* layer) {} 93 void ClearLayerLists() { layer_list_.clear(); } 94 95 void SetNearestAncestorThatMovesPixels(RenderSurface* surface) { 96 nearest_ancestor_that_moves_pixels_ = surface; 97 } 98 const RenderSurface* nearest_ancestor_that_moves_pixels() const { 99 return nearest_ancestor_that_moves_pixels_; 100 } 101 102 private: 103 friend struct LayerIteratorActions; 104 105 Layer* owning_layer_; 106 107 // Uses this surface's space. 108 gfx::Rect content_rect_; 109 110 float draw_opacity_; 111 bool draw_opacity_is_animating_; 112 gfx::Transform draw_transform_; 113 gfx::Transform screen_space_transform_; 114 gfx::Transform replica_draw_transform_; 115 gfx::Transform replica_screen_space_transform_; 116 bool target_surface_transforms_are_animating_; 117 bool screen_space_transforms_are_animating_; 118 119 bool is_clipped_; 120 121 // Uses the space of the surface's target surface. 122 gfx::Rect clip_rect_; 123 124 LayerList layer_list_; 125 126 // The nearest ancestor target surface that will contain the contents of this 127 // surface, and that is going to move pixels within the surface (such as with 128 // a blur). This can point to itself. 129 RenderSurface* nearest_ancestor_that_moves_pixels_; 130 131 // For LayerIteratorActions 132 int target_render_surface_layer_index_history_; 133 int current_layer_index_history_; 134 135 DISALLOW_COPY_AND_ASSIGN(RenderSurface); 136}; 137 138} 139#endif // CC_LAYERS_RENDER_SURFACE_H_ 140