Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_QUADS_RENDER_PASS_H_ | 5 #ifndef CC_QUADS_RENDER_PASS_H_ |
| 6 #define CC_QUADS_RENDER_PASS_H_ | 6 #define CC_QUADS_RENDER_PASS_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <unordered_map> | 10 #include <unordered_map> |
| 11 #include <utility> | 11 #include <utility> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/hash.h" | 15 #include "base/hash.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "cc/base/cc_export.h" | 17 #include "cc/base/cc_export.h" |
| 18 #include "cc/base/list_container.h" | 18 #include "cc/base/list_container.h" |
| 19 #include "cc/output/filter_operations.h" | |
| 19 #include "cc/quads/draw_quad.h" | 20 #include "cc/quads/draw_quad.h" |
| 20 #include "cc/quads/largest_draw_quad.h" | 21 #include "cc/quads/largest_draw_quad.h" |
| 21 #include "cc/quads/render_pass_id.h" | 22 #include "cc/quads/render_pass_id.h" |
| 22 #include "cc/surfaces/surface_id.h" | 23 #include "cc/surfaces/surface_id.h" |
| 23 #include "ui/gfx/geometry/rect.h" | 24 #include "ui/gfx/geometry/rect.h" |
| 24 #include "ui/gfx/geometry/rect_f.h" | 25 #include "ui/gfx/geometry/rect_f.h" |
| 25 #include "ui/gfx/transform.h" | 26 #include "ui/gfx/transform.h" |
| 26 | 27 |
| 27 namespace base { | 28 namespace base { |
| 28 namespace trace_event { | 29 namespace trace_event { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 // A deep copy of the render pass that includes quads. | 71 // A deep copy of the render pass that includes quads. |
| 71 std::unique_ptr<RenderPass> DeepCopy() const; | 72 std::unique_ptr<RenderPass> DeepCopy() const; |
| 72 | 73 |
| 73 // A deep copy of the render passes in the list including the quads. | 74 // A deep copy of the render passes in the list including the quads. |
| 74 static void CopyAll(const std::vector<std::unique_ptr<RenderPass>>& in, | 75 static void CopyAll(const std::vector<std::unique_ptr<RenderPass>>& in, |
| 75 std::vector<std::unique_ptr<RenderPass>>* out); | 76 std::vector<std::unique_ptr<RenderPass>>* out); |
| 76 | 77 |
| 77 void SetNew(RenderPassId id, | 78 void SetNew(RenderPassId id, |
| 78 const gfx::Rect& output_rect, | 79 const gfx::Rect& output_rect, |
| 79 const gfx::Rect& damage_rect, | 80 const gfx::Rect& damage_rect, |
| 80 const gfx::Transform& transform_to_root_target); | 81 const gfx::Transform& transform_to_root_target, |
| 82 const FilterOperations& filters, | |
| 83 const FilterOperations& background_filters); | |
| 81 | 84 |
| 82 void SetAll(RenderPassId id, | 85 void SetAll(RenderPassId id, |
| 83 const gfx::Rect& output_rect, | 86 const gfx::Rect& output_rect, |
| 84 const gfx::Rect& damage_rect, | 87 const gfx::Rect& damage_rect, |
| 85 const gfx::Transform& transform_to_root_target, | 88 const gfx::Transform& transform_to_root_target, |
| 89 const FilterOperations& filters, | |
| 90 const FilterOperations& background_filters, | |
| 86 bool has_transparent_background); | 91 bool has_transparent_background); |
| 87 | 92 |
| 88 void AsValueInto(base::trace_event::TracedValue* dict) const; | 93 void AsValueInto(base::trace_event::TracedValue* dict) const; |
| 89 | 94 |
| 90 SharedQuadState* CreateAndAppendSharedQuadState(); | 95 SharedQuadState* CreateAndAppendSharedQuadState(); |
| 91 | 96 |
| 92 template <typename DrawQuadType> | 97 template <typename DrawQuadType> |
| 93 DrawQuadType* CreateAndAppendDrawQuad() { | 98 DrawQuadType* CreateAndAppendDrawQuad() { |
| 94 return quad_list.AllocateAndConstruct<DrawQuadType>(); | 99 return quad_list.AllocateAndConstruct<DrawQuadType>(); |
| 95 } | 100 } |
| 96 | 101 |
| 97 RenderPassDrawQuad* CopyFromAndAppendRenderPassDrawQuad( | 102 RenderPassDrawQuad* CopyFromAndAppendRenderPassDrawQuad( |
| 98 const RenderPassDrawQuad* quad, | 103 const RenderPassDrawQuad* quad, |
| 99 const SharedQuadState* shared_quad_state, | 104 const SharedQuadState* shared_quad_state, |
| 100 RenderPassId render_pass_id); | 105 RenderPassId render_pass_id); |
| 101 DrawQuad* CopyFromAndAppendDrawQuad(const DrawQuad* quad, | 106 DrawQuad* CopyFromAndAppendDrawQuad(const DrawQuad* quad, |
| 102 const SharedQuadState* shared_quad_state); | 107 const SharedQuadState* shared_quad_state); |
| 103 | 108 |
| 104 // Uniquely identifies the render pass in the compositor's current frame. | 109 // Uniquely identifies the render pass in the compositor's current frame. |
| 105 RenderPassId id; | 110 RenderPassId id; |
| 106 | 111 |
| 107 // These are in the space of the render pass' physical pixels. | 112 // These are in the space of the render pass' physical pixels. |
| 108 gfx::Rect output_rect; | 113 gfx::Rect output_rect; |
| 109 gfx::Rect damage_rect; | 114 gfx::Rect damage_rect; |
| 110 | 115 |
| 111 // Transforms from the origin of the |output_rect| to the origin of the root | 116 // Transforms from the origin of the |output_rect| to the origin of the root |
| 112 // render pass' |output_rect|. | 117 // render pass' |output_rect|. |
| 113 gfx::Transform transform_to_root_target; | 118 gfx::Transform transform_to_root_target; |
| 114 | 119 |
| 120 // Post-processing filters, applied to the pixels in the render pass' texture. | |
| 121 FilterOperations filters; | |
| 122 | |
| 123 // Post-processing filters, applied to the pixels showing through the | |
| 124 // background of the render pass, from behind it. | |
| 125 FilterOperations background_filters; | |
| 126 | |
| 115 // If false, the pixels in the render pass' texture are all opaque. | 127 // If false, the pixels in the render pass' texture are all opaque. |
| 116 bool has_transparent_background; | 128 bool has_transparent_background; |
| 117 | 129 |
| 118 // If non-empty, the renderer should produce a copy of the render pass' | 130 // If non-empty, the renderer should produce a copy of the render pass' |
| 119 // contents as a bitmap, and give a copy of the bitmap to each callback in | 131 // contents as a bitmap, and give a copy of the bitmap to each callback in |
| 120 // this list. This property should not be serialized between compositors, as | 132 // this list. This property should not be serialized between compositors, as |
| 121 // it only makes sense in the root compositor. | 133 // it only makes sense in the root compositor. |
| 122 std::vector<std::unique_ptr<CopyOutputRequest>> copy_requests; | 134 std::vector<std::unique_ptr<CopyOutputRequest>> copy_requests; |
| 123 | 135 |
| 124 QuadList quad_list; | 136 QuadList quad_list; |
| 125 SharedQuadStateList shared_quad_state_list; | 137 SharedQuadStateList shared_quad_state_list; |
| 126 | 138 |
| 127 protected: | 139 protected: |
| 128 explicit RenderPass(size_t num_layers); | 140 explicit RenderPass(size_t num_layers); |
| 129 RenderPass(); | 141 RenderPass(); |
| 130 RenderPass(size_t shared_quad_state_list_size, size_t quad_list_size); | 142 RenderPass(size_t shared_quad_state_list_size, size_t quad_list_size); |
| 131 | 143 |
| 132 private: | 144 private: |
| 133 template <typename DrawQuadType> | 145 template <typename DrawQuadType> |
| 134 DrawQuadType* CopyFromAndAppendTypedDrawQuad(const DrawQuad* quad) { | 146 DrawQuadType* CopyFromAndAppendTypedDrawQuad(const DrawQuad* quad) { |
| 135 return quad_list.AllocateAndCopyFrom(DrawQuadType::MaterialCast(quad)); | 147 return quad_list.AllocateAndCopyFrom(DrawQuadType::MaterialCast(quad)); |
| 136 } | 148 } |
| 137 | 149 |
| 138 DISALLOW_COPY_AND_ASSIGN(RenderPass); | 150 DISALLOW_COPY_AND_ASSIGN(RenderPass); |
| 139 }; | 151 }; |
| 140 | 152 |
| 141 using RenderPassList = std::vector<std::unique_ptr<RenderPass>>; | 153 using RenderPassList = std::vector<std::unique_ptr<RenderPass>>; |
| 142 using RenderPassIdHashMap = | 154 using RenderPassIdHashMap = |
| 143 std::unordered_map<RenderPassId, RenderPass*, RenderPassIdHash>; | 155 std::unordered_map<RenderPassId, RenderPass*, RenderPassIdHash>; |
| 156 using RenderPassFilterList = | |
| 157 std::vector<std::pair<RenderPassId, FilterOperations>>; | |
|
ajuma
2016/11/30 18:40:54
I made this a vector since the number of render pa
danakj
2016/12/01 01:50:46
You would need hundreds (or thousands?) of entries
weiliangc
2016/12/01 19:04:31
Maybe overall just use FilterOperations* when not
weiliangc
2016/12/01 20:16:11
Also sort of unrelated to the CL, but isn't using
weiliangc
2016/12/01 20:23:09
Wait no just realized std::map will need to be bal
danakj
2016/12/01 21:14:34
also std::map is a pointery (ie terrible) data str
ajuma
2016/12/13 15:08:11
Changed to sorting the vector and using std::lower
| |
| 144 | 158 |
| 145 } // namespace cc | 159 } // namespace cc |
| 146 | 160 |
| 147 #endif // CC_QUADS_RENDER_PASS_H_ | 161 #endif // CC_QUADS_RENDER_PASS_H_ |
| OLD | NEW |