Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(687)

Side by Side Diff: cc/render_pass.h

Issue 11413106: cc: Make RenderPass into a struct-like class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CC_RENDER_PASS_H_ 5 #ifndef CC_RENDER_PASS_H_
6 #define CC_RENDER_PASS_H_ 6 #define CC_RENDER_PASS_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "cc/cc_export.h" 9 #include "cc/cc_export.h"
10 #include "cc/draw_quad.h" 10 #include "cc/draw_quad.h"
(...skipping 15 matching lines...) Expand all
26 template<typename LayerType, typename SurfaceType> 26 template<typename LayerType, typename SurfaceType>
27 class OcclusionTrackerBase; 27 class OcclusionTrackerBase;
28 class RenderSurfaceImpl; 28 class RenderSurfaceImpl;
29 29
30 struct AppendQuadsData; 30 struct AppendQuadsData;
31 31
32 typedef OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl> OcclusionTrackerImpl; 32 typedef OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl> OcclusionTrackerImpl;
33 33
34 // A list of DrawQuad objects, sorted internally in front-to-back order. 34 // A list of DrawQuad objects, sorted internally in front-to-back order.
35 class QuadList : public ScopedPtrVector<DrawQuad> { 35 class QuadList : public ScopedPtrVector<DrawQuad> {
36 public: 36 public:
37 typedef reverse_iterator backToFrontIterator; 37 typedef reverse_iterator backToFrontIterator;
38 typedef const_reverse_iterator constBackToFrontIterator; 38 typedef const_reverse_iterator constBackToFrontIterator;
39 39
40 inline backToFrontIterator backToFrontBegin() { return rbegin(); } 40 inline backToFrontIterator backToFrontBegin() { return rbegin(); }
41 inline backToFrontIterator backToFrontEnd() { return rend(); } 41 inline backToFrontIterator backToFrontEnd() { return rend(); }
42 inline constBackToFrontIterator backToFrontBegin() const { return rbegin(); } 42 inline constBackToFrontIterator backToFrontBegin() const { return rbegin(); }
43 inline constBackToFrontIterator backToFrontEnd() const { return rend(); } 43 inline constBackToFrontIterator backToFrontEnd() const { return rend(); }
44 }; 44 };
45 45
46 typedef ScopedPtrVector<SharedQuadState> SharedQuadStateList; 46 typedef ScopedPtrVector<SharedQuadState> SharedQuadStateList;
47 47
48 class CC_EXPORT RenderPass { 48 class CC_EXPORT RenderPass {
49 public: 49 public:
50 ~RenderPass(); 50 struct Id {
51 int layer_id;
52 int index;
51 53
52 struct Id { 54 Id(int layer_id, int index) : layer_id(layer_id), index(index) {}
53 int layerId;
54 int index;
55 55
56 Id(int layerId, int index) 56 bool operator==(const Id& other) const {
57 : layerId(layerId) 57 return layer_id == other.layer_id && index == other.index;
58 , index(index) 58 }
59 { 59 bool operator!=(const Id& other) const {
60 } 60 return !(*this == other);
61 }
62 bool operator<(const Id& other) const {
63 return layer_id < other.layer_id ||
64 (layer_id == other.layer_id && index < other.index);
65 }
66 };
61 67
62 bool operator==(const Id& other) const { return layerId == other.layerId && index == other.index; } 68 ~RenderPass();
63 bool operator!=(const Id& other) const { return !(*this == other); }
64 bool operator<(const Id& other) const { return layerId < other.layerId | | (layerId == other.layerId && index < other.index); }
65 };
66 69
67 static scoped_ptr<RenderPass> create(Id, gfx::Rect outputRect, const WebKit: :WebTransformationMatrix& transformToRootTarget); 70 static scoped_ptr<RenderPass> Create();
68 71
69 // A shallow copy of the render pass, which does not include its quads. 72 // A shallow copy of the render pass, which does not include its quads.
70 scoped_ptr<RenderPass> copy(Id newId) const; 73 scoped_ptr<RenderPass> Copy(Id newId) const;
71 74
72 void appendQuadsForLayer(LayerImpl*, OcclusionTrackerImpl*, AppendQuadsData& ); 75 void SetNew(Id id,
73 void appendQuadsForRenderSurfaceLayer(LayerImpl*, const RenderPass* contribu tingRenderPass, OcclusionTrackerImpl*, AppendQuadsData&); 76 gfx::Rect output_rect,
74 void appendQuadsToFillScreen(LayerImpl* rootLayer, SkColor screenBackgroundC olor, const OcclusionTrackerImpl&); 77 gfx::RectF damage_rect,
78 const WebKit::WebTransformationMatrix& transform_to_root_target);
75 79
76 const QuadList& quadList() const { return m_quadList; } 80 void SetAll(Id id,
81 gfx::Rect output_rect,
82 gfx::RectF damage_rect,
83 const WebKit::WebTransformationMatrix& transform_to_root_target,
84 bool has_transparent_background,
85 bool has_occlusion_from_outside_target_surface,
86 const WebKit::WebFilterOperations& filters,
87 SkImageFilter* filter,
88 const WebKit::WebFilterOperations& background_filters);
77 89
78 Id id() const { return m_id; } 90 // Uniquely identifies the render pass in the compositor's current frame.
91 Id id;
79 92
80 // FIXME: Modify this transform when merging the RenderPass into a parent co mpositor. 93 // These are in the space of the render pass' physical pixels.
81 // Transforms from quad's original content space to the root target's conten t space. 94 gfx::Rect output_rect;
82 const WebKit::WebTransformationMatrix& transformToRootTarget() const { retur n m_transformToRootTarget; } 95 gfx::RectF damage_rect;
83 96
84 // This denotes the bounds in physical pixels of the output generated by thi s RenderPass. 97 // Transforms from the origin of the |output_rect| to the origin of the root
85 const gfx::Rect& outputRect() const { return m_outputRect; } 98 // render pass' |output_rect|.
99 WebKit::WebTransformationMatrix transform_to_root_target;
86 100
87 gfx::RectF damageRect() const { return m_damageRect; } 101 // If false, the pixels in the render pass' texture are all opaque.
88 void setDamageRect(gfx::RectF rect) { m_damageRect = rect; } 102 bool has_transparent_background;
89 103
90 const WebKit::WebFilterOperations& filters() const { return m_filters; } 104 // If true, then there may be pixels in the render pass' texture that are not
91 void setFilters(const WebKit::WebFilterOperations& filters) { m_filters = fi lters; } 105 // complete, since they are occluded.
106 bool has_occlusion_from_outside_target_surface;
92 107
93 const WebKit::WebFilterOperations& backgroundFilters() const { return m_back groundFilters; } 108 // Deprecated post-processing filters, applied to the pixels in the render
94 void setBackgroundFilters(const WebKit::WebFilterOperations& filters) { m_ba ckgroundFilters = filters; } 109 // pass' texture.
110 WebKit::WebFilterOperations filters;
111 // Post-processing filter applied to the pixels in the render pass' texture.
112 // TODO(danakj): This can not be serialized right now for security reasons.
113 SkImageFilter* filter;
95 114
96 SkImageFilter* filter() const { return m_filter; } 115 // Post-processing filters, applied to the pixels showing through the
97 void setFilter(SkImageFilter* filter); 116 // background of the render pass, from behind it.
117 WebKit::WebFilterOperations background_filters;
98 118
99 bool hasTransparentBackground() const { return m_hasTransparentBackground; } 119 QuadList quad_list;
100 void setHasTransparentBackground(bool transparent) { m_hasTransparentBackgro und = transparent; } 120 SharedQuadStateList shared_quad_state_list;
101 121
102 bool hasOcclusionFromOutsideTargetSurface() const { return m_hasOcclusionFro mOutsideTargetSurface; } 122 void AppendQuadsForLayer(
103 void setHasOcclusionFromOutsideTargetSurface(bool hasOcclusionFromOutsideTar getSurface) { m_hasOcclusionFromOutsideTargetSurface = hasOcclusionFromOutsideTa rgetSurface; } 123 LayerImpl* layer,
104 protected: 124 OcclusionTrackerImpl& occlusion_tracker,
105 RenderPass(Id, gfx::Rect outputRect, const WebKit::WebTransformationMatrix& transformToRootTarget); 125 AppendQuadsData& append_quads_data);
126 void AppendQuadsForRenderSurfaceLayer(
127 LayerImpl* layer,
128 const RenderPass& contributing_render_pass,
129 OcclusionTrackerImpl& occlusion_tracker,
130 AppendQuadsData& append_quads_data);
131 void AppendQuadsToFillScreen(
132 LayerImpl* root_layer,
133 SkColor screen_background_color,
134 const OcclusionTrackerImpl& occlusion_tracker);
106 135
107 Id m_id; 136 protected:
108 QuadList m_quadList; 137 RenderPass();
109 SharedQuadStateList m_sharedQuadStateList;
110 WebKit::WebTransformationMatrix m_transformToRootTarget;
111 gfx::Rect m_outputRect;
112 gfx::RectF m_damageRect;
113 bool m_hasTransparentBackground;
114 bool m_hasOcclusionFromOutsideTargetSurface;
115 WebKit::WebFilterOperations m_filters;
116 WebKit::WebFilterOperations m_backgroundFilters;
117 SkImageFilter* m_filter;
118 138
119 DISALLOW_COPY_AND_ASSIGN(RenderPass); 139 DISALLOW_COPY_AND_ASSIGN(RenderPass);
120 }; 140 };
121 141
122 } // namespace cc 142 } // namespace cc
123 143
124 namespace BASE_HASH_NAMESPACE { 144 namespace BASE_HASH_NAMESPACE {
125 #if defined(COMPILER_MSVC) 145 #if defined(COMPILER_MSVC)
126 template<> 146 template<>
127 inline size_t hash_value<cc::RenderPass::Id>(const cc::RenderPass::Id& key) { 147 inline size_t hash_value<cc::RenderPass::Id>(const cc::RenderPass::Id& key) {
128 return hash_value<std::pair<int, int> >(std::pair<int, int>(key.layerId, key .index)); 148 return hash_value<std::pair<int, int> >(
149 std::pair<int, int>(key.layer_id, key.index));
129 } 150 }
130 #elif defined(COMPILER_GCC) 151 #elif defined(COMPILER_GCC)
131 template<> 152 template<>
132 struct hash<cc::RenderPass::Id> { 153 struct hash<cc::RenderPass::Id> {
133 size_t operator()(cc::RenderPass::Id key) const { 154 size_t operator()(cc::RenderPass::Id key) const {
134 return hash<std::pair<int, int> >()(std::pair<int, int>(key.layerId, key .index)); 155 return hash<std::pair<int, int> >()(
135 } 156 std::pair<int, int>(key.layer_id, key.index));
157 }
136 }; 158 };
137 #else 159 #else
138 #error define a hash function for your compiler 160 #error define a hash function for your compiler
139 #endif // COMPILER 161 #endif // COMPILER
140 } 162 }
141 163
142 namespace cc { 164 namespace cc {
143 typedef std::vector<RenderPass*> RenderPassList; 165 typedef std::vector<RenderPass*> RenderPassList;
144 typedef ScopedPtrHashMap<RenderPass::Id, RenderPass> RenderPassIdHashMap; 166 typedef ScopedPtrHashMap<RenderPass::Id, RenderPass> RenderPassIdHashMap;
145 } // namespace cc 167 } // namespace cc
146 168
147 #endif // CC_RENDER_PASS_H_ 169 #endif // CC_RENDER_PASS_H_
OLDNEW
« no previous file with comments | « cc/quad_culler_unittest.cc ('k') | cc/render_pass.cc » ('j') | cc/render_pass.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698