| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 #include "cc/quads/render_pass.h" | 5 #include "cc/quads/render_pass.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 struct RenderPassSize { | 22 struct RenderPassSize { |
| 23 // If you add a new field to this class, make sure to add it to the | 23 // If you add a new field to this class, make sure to add it to the |
| 24 // Copy() tests. | 24 // Copy() tests. |
| 25 int id; | 25 int id; |
| 26 gfx::Rect output_rect; | 26 gfx::Rect output_rect; |
| 27 gfx::Rect damage_rect; | 27 gfx::Rect damage_rect; |
| 28 gfx::Transform transform_to_root_target; | 28 gfx::Transform transform_to_root_target; |
| 29 FilterOperations filters; | 29 FilterOperations filters; |
| 30 FilterOperations background_filters; | 30 FilterOperations background_filters; |
| 31 gfx::ColorSpace color_space; |
| 31 bool has_transparent_background; | 32 bool has_transparent_background; |
| 32 std::vector<std::unique_ptr<CopyOutputRequest>> copy_callbacks; | 33 std::vector<std::unique_ptr<CopyOutputRequest>> copy_callbacks; |
| 33 QuadList quad_list; | 34 QuadList quad_list; |
| 34 SharedQuadStateList shared_quad_state_list; | 35 SharedQuadStateList shared_quad_state_list; |
| 35 }; | 36 }; |
| 36 | 37 |
| 37 static void CompareRenderPassLists(const RenderPassList& expected_list, | 38 static void CompareRenderPassLists(const RenderPassList& expected_list, |
| 38 const RenderPassList& actual_list) { | 39 const RenderPassList& actual_list) { |
| 39 EXPECT_EQ(expected_list.size(), actual_list.size()); | 40 EXPECT_EQ(expected_list.size(), actual_list.size()); |
| 40 for (size_t i = 0; i < actual_list.size(); ++i) { | 41 for (size_t i = 0; i < actual_list.size(); ++i) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 69 TEST(RenderPassTest, CopyShouldBeIdenticalExceptIdAndQuads) { | 70 TEST(RenderPassTest, CopyShouldBeIdenticalExceptIdAndQuads) { |
| 70 int id = 3; | 71 int id = 3; |
| 71 gfx::Rect output_rect(45, 22, 120, 13); | 72 gfx::Rect output_rect(45, 22, 120, 13); |
| 72 gfx::Transform transform_to_root = | 73 gfx::Transform transform_to_root = |
| 73 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0); | 74 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0); |
| 74 gfx::Rect damage_rect(56, 123, 19, 43); | 75 gfx::Rect damage_rect(56, 123, 19, 43); |
| 75 FilterOperations filters; | 76 FilterOperations filters; |
| 76 filters.Append(FilterOperation::CreateOpacityFilter(0.5)); | 77 filters.Append(FilterOperation::CreateOpacityFilter(0.5)); |
| 77 FilterOperations background_filters; | 78 FilterOperations background_filters; |
| 78 background_filters.Append(FilterOperation::CreateInvertFilter(1.0)); | 79 background_filters.Append(FilterOperation::CreateInvertFilter(1.0)); |
| 80 gfx::ColorSpace color_space = gfx::ColorSpace::CreateSRGB(); |
| 79 bool has_transparent_background = true; | 81 bool has_transparent_background = true; |
| 80 | 82 |
| 81 std::unique_ptr<RenderPass> pass = RenderPass::Create(); | 83 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
| 82 pass->SetAll(id, output_rect, damage_rect, transform_to_root, filters, | 84 pass->SetAll(id, output_rect, damage_rect, transform_to_root, filters, |
| 83 background_filters, has_transparent_background); | 85 background_filters, color_space, has_transparent_background); |
| 84 pass->copy_requests.push_back(CopyOutputRequest::CreateEmptyRequest()); | 86 pass->copy_requests.push_back(CopyOutputRequest::CreateEmptyRequest()); |
| 85 | 87 |
| 86 // Stick a quad in the pass, this should not get copied. | 88 // Stick a quad in the pass, this should not get copied. |
| 87 SharedQuadState* shared_state = pass->CreateAndAppendSharedQuadState(); | 89 SharedQuadState* shared_state = pass->CreateAndAppendSharedQuadState(); |
| 88 shared_state->SetAll(gfx::Transform(), gfx::Size(), gfx::Rect(), gfx::Rect(), | 90 shared_state->SetAll(gfx::Transform(), gfx::Size(), gfx::Rect(), gfx::Rect(), |
| 89 false, 1, SkBlendMode::kSrcOver, 0); | 91 false, 1, SkBlendMode::kSrcOver, 0); |
| 90 | 92 |
| 91 SolidColorDrawQuad* color_quad = | 93 SolidColorDrawQuad* color_quad = |
| 92 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 94 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| 93 color_quad->SetNew(pass->shared_quad_state_list.back(), gfx::Rect(), | 95 color_quad->SetNew(pass->shared_quad_state_list.back(), gfx::Rect(), |
| (...skipping 23 matching lines...) Expand all Loading... |
| 117 | 119 |
| 118 int id = 3; | 120 int id = 3; |
| 119 gfx::Rect output_rect(45, 22, 120, 13); | 121 gfx::Rect output_rect(45, 22, 120, 13); |
| 120 gfx::Transform transform_to_root = | 122 gfx::Transform transform_to_root = |
| 121 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0); | 123 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0); |
| 122 gfx::Rect damage_rect(56, 123, 19, 43); | 124 gfx::Rect damage_rect(56, 123, 19, 43); |
| 123 FilterOperations filters; | 125 FilterOperations filters; |
| 124 filters.Append(FilterOperation::CreateOpacityFilter(0.5)); | 126 filters.Append(FilterOperation::CreateOpacityFilter(0.5)); |
| 125 FilterOperations background_filters; | 127 FilterOperations background_filters; |
| 126 background_filters.Append(FilterOperation::CreateInvertFilter(1.0)); | 128 background_filters.Append(FilterOperation::CreateInvertFilter(1.0)); |
| 129 gfx::ColorSpace color_space = gfx::ColorSpace::CreateXYZD50(); |
| 127 bool has_transparent_background = true; | 130 bool has_transparent_background = true; |
| 128 | 131 |
| 129 std::unique_ptr<RenderPass> pass = RenderPass::Create(); | 132 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
| 130 pass->SetAll(id, output_rect, damage_rect, transform_to_root, filters, | 133 pass->SetAll(id, output_rect, damage_rect, transform_to_root, filters, |
| 131 background_filters, has_transparent_background); | 134 background_filters, color_space, has_transparent_background); |
| 132 | 135 |
| 133 // Two quads using one shared state. | 136 // Two quads using one shared state. |
| 134 SharedQuadState* shared_state1 = pass->CreateAndAppendSharedQuadState(); | 137 SharedQuadState* shared_state1 = pass->CreateAndAppendSharedQuadState(); |
| 135 shared_state1->SetAll(gfx::Transform(), gfx::Size(1, 1), gfx::Rect(), | 138 shared_state1->SetAll(gfx::Transform(), gfx::Size(1, 1), gfx::Rect(), |
| 136 gfx::Rect(), false, 1, SkBlendMode::kSrcOver, 0); | 139 gfx::Rect(), false, 1, SkBlendMode::kSrcOver, 0); |
| 137 | 140 |
| 138 SolidColorDrawQuad* color_quad1 = | 141 SolidColorDrawQuad* color_quad1 = |
| 139 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 142 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| 140 color_quad1->SetNew(pass->shared_quad_state_list.back(), | 143 color_quad1->SetNew(pass->shared_quad_state_list.back(), |
| 141 gfx::Rect(1, 1, 1, 1), gfx::Rect(1, 1, 1, 1), SkColor(), | 144 gfx::Rect(1, 1, 1, 1), gfx::Rect(1, 1, 1, 1), SkColor(), |
| (...skipping 25 matching lines...) Expand all Loading... |
| 167 // A second render pass with a quad. | 170 // A second render pass with a quad. |
| 168 int contrib_id = 4; | 171 int contrib_id = 4; |
| 169 gfx::Rect contrib_output_rect(10, 15, 12, 17); | 172 gfx::Rect contrib_output_rect(10, 15, 12, 17); |
| 170 gfx::Transform contrib_transform_to_root = | 173 gfx::Transform contrib_transform_to_root = |
| 171 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0); | 174 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0); |
| 172 gfx::Rect contrib_damage_rect(11, 16, 10, 15); | 175 gfx::Rect contrib_damage_rect(11, 16, 10, 15); |
| 173 FilterOperations contrib_filters; | 176 FilterOperations contrib_filters; |
| 174 contrib_filters.Append(FilterOperation::CreateSepiaFilter(0.5)); | 177 contrib_filters.Append(FilterOperation::CreateSepiaFilter(0.5)); |
| 175 FilterOperations contrib_background_filters; | 178 FilterOperations contrib_background_filters; |
| 176 contrib_background_filters.Append(FilterOperation::CreateSaturateFilter(1)); | 179 contrib_background_filters.Append(FilterOperation::CreateSaturateFilter(1)); |
| 180 gfx::ColorSpace contrib_color_space = gfx::ColorSpace::CreateSCRGBLinear(); |
| 177 bool contrib_has_transparent_background = true; | 181 bool contrib_has_transparent_background = true; |
| 178 | 182 |
| 179 std::unique_ptr<RenderPass> contrib = RenderPass::Create(); | 183 std::unique_ptr<RenderPass> contrib = RenderPass::Create(); |
| 180 contrib->SetAll(contrib_id, contrib_output_rect, contrib_damage_rect, | 184 contrib->SetAll(contrib_id, contrib_output_rect, contrib_damage_rect, |
| 181 contrib_transform_to_root, contrib_filters, | 185 contrib_transform_to_root, contrib_filters, |
| 182 contrib_background_filters, | 186 contrib_background_filters, contrib_color_space, |
| 183 contrib_has_transparent_background); | 187 contrib_has_transparent_background); |
| 184 | 188 |
| 185 SharedQuadState* contrib_shared_state = | 189 SharedQuadState* contrib_shared_state = |
| 186 contrib->CreateAndAppendSharedQuadState(); | 190 contrib->CreateAndAppendSharedQuadState(); |
| 187 contrib_shared_state->SetAll(gfx::Transform(), gfx::Size(2, 2), gfx::Rect(), | 191 contrib_shared_state->SetAll(gfx::Transform(), gfx::Size(2, 2), gfx::Rect(), |
| 188 gfx::Rect(), false, 1, SkBlendMode::kSrcOver, 0); | 192 gfx::Rect(), false, 1, SkBlendMode::kSrcOver, 0); |
| 189 | 193 |
| 190 SolidColorDrawQuad* contrib_quad = | 194 SolidColorDrawQuad* contrib_quad = |
| 191 contrib->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 195 contrib->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| 192 contrib_quad->SetNew(contrib->shared_quad_state_list.back(), | 196 contrib_quad->SetNew(contrib->shared_quad_state_list.back(), |
| (...skipping 22 matching lines...) Expand all Loading... |
| 215 | 219 |
| 216 int id = 3; | 220 int id = 3; |
| 217 gfx::Rect output_rect(45, 22, 120, 13); | 221 gfx::Rect output_rect(45, 22, 120, 13); |
| 218 gfx::Transform transform_to_root = | 222 gfx::Transform transform_to_root = |
| 219 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0); | 223 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0); |
| 220 gfx::Rect damage_rect(56, 123, 19, 43); | 224 gfx::Rect damage_rect(56, 123, 19, 43); |
| 221 FilterOperations filters; | 225 FilterOperations filters; |
| 222 filters.Append(FilterOperation::CreateOpacityFilter(0.5)); | 226 filters.Append(FilterOperation::CreateOpacityFilter(0.5)); |
| 223 FilterOperations background_filters; | 227 FilterOperations background_filters; |
| 224 background_filters.Append(FilterOperation::CreateInvertFilter(1.0)); | 228 background_filters.Append(FilterOperation::CreateInvertFilter(1.0)); |
| 229 gfx::ColorSpace color_space = gfx::ColorSpace::CreateSCRGBLinear(); |
| 225 bool has_transparent_background = true; | 230 bool has_transparent_background = true; |
| 226 | 231 |
| 227 std::unique_ptr<RenderPass> pass = RenderPass::Create(); | 232 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
| 228 pass->SetAll(id, output_rect, damage_rect, transform_to_root, filters, | 233 pass->SetAll(id, output_rect, damage_rect, transform_to_root, filters, |
| 229 background_filters, has_transparent_background); | 234 background_filters, color_space, has_transparent_background); |
| 230 | 235 |
| 231 // A shared state with a quad. | 236 // A shared state with a quad. |
| 232 SharedQuadState* shared_state1 = pass->CreateAndAppendSharedQuadState(); | 237 SharedQuadState* shared_state1 = pass->CreateAndAppendSharedQuadState(); |
| 233 shared_state1->SetAll(gfx::Transform(), gfx::Size(1, 1), gfx::Rect(), | 238 shared_state1->SetAll(gfx::Transform(), gfx::Size(1, 1), gfx::Rect(), |
| 234 gfx::Rect(), false, 1, SkBlendMode::kSrcOver, 0); | 239 gfx::Rect(), false, 1, SkBlendMode::kSrcOver, 0); |
| 235 | 240 |
| 236 SolidColorDrawQuad* color_quad1 = | 241 SolidColorDrawQuad* color_quad1 = |
| 237 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 242 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| 238 color_quad1->SetNew(pass->shared_quad_state_list.back(), | 243 color_quad1->SetNew(pass->shared_quad_state_list.back(), |
| 239 gfx::Rect(1, 1, 1, 1), gfx::Rect(1, 1, 1, 1), SkColor(), | 244 gfx::Rect(1, 1, 1, 1), gfx::Rect(1, 1, 1, 1), SkColor(), |
| (...skipping 24 matching lines...) Expand all Loading... |
| 264 | 269 |
| 265 // Make a copy with CopyAll(). | 270 // Make a copy with CopyAll(). |
| 266 RenderPassList copy_list; | 271 RenderPassList copy_list; |
| 267 RenderPass::CopyAll(pass_list, ©_list); | 272 RenderPass::CopyAll(pass_list, ©_list); |
| 268 | 273 |
| 269 CompareRenderPassLists(pass_list, copy_list); | 274 CompareRenderPassLists(pass_list, copy_list); |
| 270 } | 275 } |
| 271 | 276 |
| 272 } // namespace | 277 } // namespace |
| 273 } // namespace cc | 278 } // namespace cc |
| OLD | NEW |