| 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 "cc/base/math_util.h" |    7 #include "cc/base/math_util.h" | 
|    8 #include "cc/base/scoped_ptr_vector.h" |    8 #include "cc/base/scoped_ptr_vector.h" | 
|    9 #include "cc/output/copy_output_request.h" |    9 #include "cc/output/copy_output_request.h" | 
|   10 #include "cc/quads/checkerboard_draw_quad.h" |  | 
|   11 #include "cc/quads/render_pass_draw_quad.h" |   10 #include "cc/quads/render_pass_draw_quad.h" | 
 |   11 #include "cc/quads/solid_color_draw_quad.h" | 
|   12 #include "cc/test/geometry_test_utils.h" |   12 #include "cc/test/geometry_test_utils.h" | 
|   13 #include "cc/test/render_pass_test_common.h" |   13 #include "cc/test/render_pass_test_common.h" | 
|   14 #include "testing/gtest/include/gtest/gtest.h" |   14 #include "testing/gtest/include/gtest/gtest.h" | 
|   15 #include "third_party/skia/include/effects/SkBlurImageFilter.h" |   15 #include "third_party/skia/include/effects/SkBlurImageFilter.h" | 
|   16 #include "ui/gfx/transform.h" |   16 #include "ui/gfx/transform.h" | 
|   17  |   17  | 
|   18 using cc::TestRenderPass; |   18 using cc::TestRenderPass; | 
|   19  |   19  | 
|   20 namespace cc { |   20 namespace cc { | 
|   21 namespace { |   21 namespace { | 
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   85   SharedQuadState* shared_state = pass->CreateAndAppendSharedQuadState(); |   85   SharedQuadState* shared_state = pass->CreateAndAppendSharedQuadState(); | 
|   86   shared_state->SetAll(gfx::Transform(), |   86   shared_state->SetAll(gfx::Transform(), | 
|   87                        gfx::Size(), |   87                        gfx::Size(), | 
|   88                        gfx::Rect(), |   88                        gfx::Rect(), | 
|   89                        gfx::Rect(), |   89                        gfx::Rect(), | 
|   90                        false, |   90                        false, | 
|   91                        1, |   91                        1, | 
|   92                        SkXfermode::kSrcOver_Mode, |   92                        SkXfermode::kSrcOver_Mode, | 
|   93                        0); |   93                        0); | 
|   94  |   94  | 
|   95   CheckerboardDrawQuad* checkerboard_quad = |   95   SolidColorDrawQuad* color_quad = | 
|   96       pass->CreateAndAppendDrawQuad<CheckerboardDrawQuad>(); |   96       pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 
|   97   checkerboard_quad->SetNew(pass->shared_quad_state_list.back(), gfx::Rect(), |   97   color_quad->SetNew(pass->shared_quad_state_list.back(), gfx::Rect(), | 
|   98                             gfx::Rect(), SkColor(), 1.f); |   98                      gfx::Rect(), SkColor(), false); | 
|   99  |   99  | 
|  100   RenderPassId new_id(63, 4); |  100   RenderPassId new_id(63, 4); | 
|  101  |  101  | 
|  102   scoped_ptr<RenderPass> copy = pass->Copy(new_id); |  102   scoped_ptr<RenderPass> copy = pass->Copy(new_id); | 
|  103   EXPECT_EQ(new_id, copy->id); |  103   EXPECT_EQ(new_id, copy->id); | 
|  104   EXPECT_EQ(pass->output_rect, copy->output_rect); |  104   EXPECT_EQ(pass->output_rect, copy->output_rect); | 
|  105   EXPECT_EQ(pass->transform_to_root_target, copy->transform_to_root_target); |  105   EXPECT_EQ(pass->transform_to_root_target, copy->transform_to_root_target); | 
|  106   EXPECT_EQ(pass->damage_rect, copy->damage_rect); |  106   EXPECT_EQ(pass->damage_rect, copy->damage_rect); | 
|  107   EXPECT_EQ(pass->has_transparent_background, copy->has_transparent_background); |  107   EXPECT_EQ(pass->has_transparent_background, copy->has_transparent_background); | 
|  108   EXPECT_EQ(0u, copy->quad_list.size()); |  108   EXPECT_EQ(0u, copy->quad_list.size()); | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
|  136   SharedQuadState* shared_state1 = pass->CreateAndAppendSharedQuadState(); |  136   SharedQuadState* shared_state1 = pass->CreateAndAppendSharedQuadState(); | 
|  137   shared_state1->SetAll(gfx::Transform(), |  137   shared_state1->SetAll(gfx::Transform(), | 
|  138                         gfx::Size(1, 1), |  138                         gfx::Size(1, 1), | 
|  139                         gfx::Rect(), |  139                         gfx::Rect(), | 
|  140                         gfx::Rect(), |  140                         gfx::Rect(), | 
|  141                         false, |  141                         false, | 
|  142                         1, |  142                         1, | 
|  143                         SkXfermode::kSrcOver_Mode, |  143                         SkXfermode::kSrcOver_Mode, | 
|  144                         0); |  144                         0); | 
|  145  |  145  | 
|  146   CheckerboardDrawQuad* checkerboard_quad1 = |  146   SolidColorDrawQuad* color_quad1 = | 
|  147       pass->CreateAndAppendDrawQuad<CheckerboardDrawQuad>(); |  147       pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 
|  148   checkerboard_quad1->SetNew(pass->shared_quad_state_list.back(), |  148   color_quad1->SetNew(pass->shared_quad_state_list.back(), | 
|  149                              gfx::Rect(1, 1, 1, 1), gfx::Rect(1, 1, 1, 1), |  149                       gfx::Rect(1, 1, 1, 1), gfx::Rect(1, 1, 1, 1), SkColor(), | 
|  150                              SkColor(), 1.f); |  150                       false); | 
|  151  |  151  | 
|  152   CheckerboardDrawQuad* checkerboard_quad2 = |  152   SolidColorDrawQuad* color_quad2 = | 
|  153       pass->CreateAndAppendDrawQuad<CheckerboardDrawQuad>(); |  153       pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 
|  154   checkerboard_quad2->SetNew(pass->shared_quad_state_list.back(), |  154   color_quad2->SetNew(pass->shared_quad_state_list.back(), | 
|  155                              gfx::Rect(2, 2, 2, 2), gfx::Rect(2, 2, 2, 2), |  155                       gfx::Rect(2, 2, 2, 2), gfx::Rect(2, 2, 2, 2), SkColor(), | 
|  156                              SkColor(), 1.f); |  156                       false); | 
|  157  |  157  | 
|  158   // And two quads using another shared state. |  158   // And two quads using another shared state. | 
|  159   SharedQuadState* shared_state2 = pass->CreateAndAppendSharedQuadState(); |  159   SharedQuadState* shared_state2 = pass->CreateAndAppendSharedQuadState(); | 
|  160   shared_state2->SetAll(gfx::Transform(), |  160   shared_state2->SetAll(gfx::Transform(), | 
|  161                         gfx::Size(2, 2), |  161                         gfx::Size(2, 2), | 
|  162                         gfx::Rect(), |  162                         gfx::Rect(), | 
|  163                         gfx::Rect(), |  163                         gfx::Rect(), | 
|  164                         false, |  164                         false, | 
|  165                         1, |  165                         1, | 
|  166                         SkXfermode::kSrcOver_Mode, |  166                         SkXfermode::kSrcOver_Mode, | 
|  167                         0); |  167                         0); | 
|  168  |  168  | 
|  169   CheckerboardDrawQuad* checkerboard_quad3 = |  169   SolidColorDrawQuad* color_quad3 = | 
|  170       pass->CreateAndAppendDrawQuad<CheckerboardDrawQuad>(); |  170       pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 
|  171   checkerboard_quad3->SetNew(pass->shared_quad_state_list.back(), |  171   color_quad3->SetNew(pass->shared_quad_state_list.back(), | 
|  172                              gfx::Rect(3, 3, 3, 3), gfx::Rect(3, 3, 3, 3), |  172                       gfx::Rect(3, 3, 3, 3), gfx::Rect(3, 3, 3, 3), SkColor(), | 
|  173                              SkColor(), 1.f); |  173                       false); | 
|  174  |  174  | 
|  175   CheckerboardDrawQuad* checkerboard_quad4 = |  175   SolidColorDrawQuad* color_quad4 = | 
|  176       pass->CreateAndAppendDrawQuad<CheckerboardDrawQuad>(); |  176       pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 
|  177   checkerboard_quad4->SetNew(pass->shared_quad_state_list.back(), |  177   color_quad4->SetNew(pass->shared_quad_state_list.back(), | 
|  178                              gfx::Rect(4, 4, 4, 4), gfx::Rect(4, 4, 4, 4), |  178                       gfx::Rect(4, 4, 4, 4), gfx::Rect(4, 4, 4, 4), SkColor(), | 
|  179                              SkColor(), 1.f); |  179                       false); | 
|  180  |  180  | 
|  181   // A second render pass with a quad. |  181   // A second render pass with a quad. | 
|  182   RenderPassId contrib_id(4, 1); |  182   RenderPassId contrib_id(4, 1); | 
|  183   gfx::Rect contrib_output_rect(10, 15, 12, 17); |  183   gfx::Rect contrib_output_rect(10, 15, 12, 17); | 
|  184   gfx::Transform contrib_transform_to_root = |  184   gfx::Transform contrib_transform_to_root = | 
|  185       gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0); |  185       gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0); | 
|  186   gfx::Rect contrib_damage_rect(11, 16, 10, 15); |  186   gfx::Rect contrib_damage_rect(11, 16, 10, 15); | 
|  187   bool contrib_has_transparent_background = true; |  187   bool contrib_has_transparent_background = true; | 
|  188  |  188  | 
|  189   scoped_ptr<TestRenderPass> contrib = TestRenderPass::Create(); |  189   scoped_ptr<TestRenderPass> contrib = TestRenderPass::Create(); | 
|  190   contrib->SetAll(contrib_id, |  190   contrib->SetAll(contrib_id, | 
|  191                   contrib_output_rect, |  191                   contrib_output_rect, | 
|  192                   contrib_damage_rect, |  192                   contrib_damage_rect, | 
|  193                   contrib_transform_to_root, |  193                   contrib_transform_to_root, | 
|  194                   contrib_has_transparent_background); |  194                   contrib_has_transparent_background); | 
|  195  |  195  | 
|  196   SharedQuadState* contrib_shared_state = |  196   SharedQuadState* contrib_shared_state = | 
|  197       contrib->CreateAndAppendSharedQuadState(); |  197       contrib->CreateAndAppendSharedQuadState(); | 
|  198   contrib_shared_state->SetAll(gfx::Transform(), |  198   contrib_shared_state->SetAll(gfx::Transform(), | 
|  199                                gfx::Size(2, 2), |  199                                gfx::Size(2, 2), | 
|  200                                gfx::Rect(), |  200                                gfx::Rect(), | 
|  201                                gfx::Rect(), |  201                                gfx::Rect(), | 
|  202                                false, |  202                                false, | 
|  203                                1, |  203                                1, | 
|  204                                SkXfermode::kSrcOver_Mode, |  204                                SkXfermode::kSrcOver_Mode, | 
|  205                                0); |  205                                0); | 
|  206  |  206  | 
|  207   CheckerboardDrawQuad* contrib_quad = |  207   SolidColorDrawQuad* contrib_quad = | 
|  208       contrib->CreateAndAppendDrawQuad<CheckerboardDrawQuad>(); |  208       contrib->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 
|  209   contrib_quad->SetNew(contrib->shared_quad_state_list.back(), |  209   contrib_quad->SetNew(contrib->shared_quad_state_list.back(), | 
|  210                        gfx::Rect(3, 3, 3, 3), gfx::Rect(3, 3, 3, 3), SkColor(), |  210                        gfx::Rect(3, 3, 3, 3), gfx::Rect(3, 3, 3, 3), SkColor(), | 
|  211                        1.f); |  211                        false); | 
|  212  |  212  | 
|  213   // And a RenderPassDrawQuad for the contributing pass. |  213   // And a RenderPassDrawQuad for the contributing pass. | 
|  214   scoped_ptr<RenderPassDrawQuad> pass_quad = |  214   scoped_ptr<RenderPassDrawQuad> pass_quad = | 
|  215       make_scoped_ptr(new RenderPassDrawQuad); |  215       make_scoped_ptr(new RenderPassDrawQuad); | 
|  216   pass_quad->SetNew(pass->shared_quad_state_list.back(), |  216   pass_quad->SetNew(pass->shared_quad_state_list.back(), | 
|  217                     contrib_output_rect, |  217                     contrib_output_rect, | 
|  218                     contrib_output_rect, |  218                     contrib_output_rect, | 
|  219                     contrib_id, |  219                     contrib_id, | 
|  220                     0, |  220                     0, | 
|  221                     gfx::Vector2dF(), |  221                     gfx::Vector2dF(), | 
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  255   SharedQuadState* shared_state1 = pass->CreateAndAppendSharedQuadState(); |  255   SharedQuadState* shared_state1 = pass->CreateAndAppendSharedQuadState(); | 
|  256   shared_state1->SetAll(gfx::Transform(), |  256   shared_state1->SetAll(gfx::Transform(), | 
|  257                         gfx::Size(1, 1), |  257                         gfx::Size(1, 1), | 
|  258                         gfx::Rect(), |  258                         gfx::Rect(), | 
|  259                         gfx::Rect(), |  259                         gfx::Rect(), | 
|  260                         false, |  260                         false, | 
|  261                         1, |  261                         1, | 
|  262                         SkXfermode::kSrcOver_Mode, |  262                         SkXfermode::kSrcOver_Mode, | 
|  263                         0); |  263                         0); | 
|  264  |  264  | 
|  265   CheckerboardDrawQuad* checkerboard_quad1 = |  265   SolidColorDrawQuad* color_quad1 = | 
|  266       pass->CreateAndAppendDrawQuad<CheckerboardDrawQuad>(); |  266       pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 
|  267   checkerboard_quad1->SetNew(pass->shared_quad_state_list.back(), |  267   color_quad1->SetNew(pass->shared_quad_state_list.back(), | 
|  268                              gfx::Rect(1, 1, 1, 1), gfx::Rect(1, 1, 1, 1), |  268                       gfx::Rect(1, 1, 1, 1), gfx::Rect(1, 1, 1, 1), SkColor(), | 
|  269                              SkColor(), 1.f); |  269                       false); | 
|  270  |  270  | 
|  271   // A shared state with no quads, they were culled. |  271   // A shared state with no quads, they were culled. | 
|  272   SharedQuadState* shared_state2 = pass->CreateAndAppendSharedQuadState(); |  272   SharedQuadState* shared_state2 = pass->CreateAndAppendSharedQuadState(); | 
|  273   shared_state2->SetAll(gfx::Transform(), |  273   shared_state2->SetAll(gfx::Transform(), | 
|  274                         gfx::Size(2, 2), |  274                         gfx::Size(2, 2), | 
|  275                         gfx::Rect(), |  275                         gfx::Rect(), | 
|  276                         gfx::Rect(), |  276                         gfx::Rect(), | 
|  277                         false, |  277                         false, | 
|  278                         1, |  278                         1, | 
|  279                         SkXfermode::kSrcOver_Mode, |  279                         SkXfermode::kSrcOver_Mode, | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
|  294   SharedQuadState* shared_state4 = pass->CreateAndAppendSharedQuadState(); |  294   SharedQuadState* shared_state4 = pass->CreateAndAppendSharedQuadState(); | 
|  295   shared_state4->SetAll(gfx::Transform(), |  295   shared_state4->SetAll(gfx::Transform(), | 
|  296                         gfx::Size(2, 2), |  296                         gfx::Size(2, 2), | 
|  297                         gfx::Rect(), |  297                         gfx::Rect(), | 
|  298                         gfx::Rect(), |  298                         gfx::Rect(), | 
|  299                         false, |  299                         false, | 
|  300                         1, |  300                         1, | 
|  301                         SkXfermode::kSrcOver_Mode, |  301                         SkXfermode::kSrcOver_Mode, | 
|  302                         0); |  302                         0); | 
|  303  |  303  | 
|  304   CheckerboardDrawQuad* checkerboard_quad2 = |  304   SolidColorDrawQuad* color_quad2 = | 
|  305       pass->CreateAndAppendDrawQuad<CheckerboardDrawQuad>(); |  305       pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 
|  306   checkerboard_quad2->SetNew(pass->shared_quad_state_list.back(), |  306   color_quad2->SetNew(pass->shared_quad_state_list.back(), | 
|  307                              gfx::Rect(3, 3, 3, 3), gfx::Rect(3, 3, 3, 3), |  307                       gfx::Rect(3, 3, 3, 3), gfx::Rect(3, 3, 3, 3), SkColor(), | 
|  308                              SkColor(), 1.f); |  308                       false); | 
|  309  |  309  | 
|  310   pass_list.push_back(pass.Pass()); |  310   pass_list.push_back(pass.Pass()); | 
|  311  |  311  | 
|  312   // Make a copy with CopyAll(). |  312   // Make a copy with CopyAll(). | 
|  313   RenderPassList copy_list; |  313   RenderPassList copy_list; | 
|  314   RenderPass::CopyAll(pass_list, ©_list); |  314   RenderPass::CopyAll(pass_list, ©_list); | 
|  315  |  315  | 
|  316   CompareRenderPassLists(pass_list, copy_list); |  316   CompareRenderPassLists(pass_list, copy_list); | 
|  317 } |  317 } | 
|  318  |  318  | 
|  319 }  // namespace |  319 }  // namespace | 
|  320 }  // namespace cc |  320 }  // namespace cc | 
| OLD | NEW |