| 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/draw_quad.h" | 5 #include "cc/quads/draw_quad.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "cc/test/geometry_test_utils.h" | 27 #include "cc/test/geometry_test_utils.h" |
| 28 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 29 #include "third_party/skia/include/effects/SkBlurImageFilter.h" | 29 #include "third_party/skia/include/effects/SkBlurImageFilter.h" |
| 30 #include "ui/gfx/transform.h" | 30 #include "ui/gfx/transform.h" |
| 31 | 31 |
| 32 namespace cc { | 32 namespace cc { |
| 33 namespace { | 33 namespace { |
| 34 | 34 |
| 35 TEST(DrawQuadTest, CopySharedQuadState) { | 35 TEST(DrawQuadTest, CopySharedQuadState) { |
| 36 gfx::Transform quad_transform = gfx::Transform(1.0, 0.0, 0.5, 1.0, 0.5, 0.0); | 36 gfx::Transform quad_transform = gfx::Transform(1.0, 0.0, 0.5, 1.0, 0.5, 0.0); |
| 37 gfx::Size content_bounds(26, 28); | 37 gfx::Size layer_bounds(26, 28); |
| 38 gfx::Rect visible_content_rect(10, 12, 14, 16); | 38 gfx::Rect visible_layer_rect(10, 12, 14, 16); |
| 39 gfx::Rect clip_rect(19, 21, 23, 25); | 39 gfx::Rect clip_rect(19, 21, 23, 25); |
| 40 bool is_clipped = true; | 40 bool is_clipped = true; |
| 41 float opacity = 0.25f; | 41 float opacity = 0.25f; |
| 42 SkXfermode::Mode blend_mode = SkXfermode::kMultiply_Mode; | 42 SkXfermode::Mode blend_mode = SkXfermode::kMultiply_Mode; |
| 43 int sorting_context_id = 65536; | 43 int sorting_context_id = 65536; |
| 44 | 44 |
| 45 scoped_ptr<SharedQuadState> state(new SharedQuadState); | 45 scoped_ptr<SharedQuadState> state(new SharedQuadState); |
| 46 state->SetAll(quad_transform, | 46 state->SetAll(quad_transform, layer_bounds, visible_layer_rect, clip_rect, |
| 47 content_bounds, | 47 is_clipped, opacity, blend_mode, sorting_context_id); |
| 48 visible_content_rect, | |
| 49 clip_rect, | |
| 50 is_clipped, | |
| 51 opacity, | |
| 52 blend_mode, | |
| 53 sorting_context_id); | |
| 54 | 48 |
| 55 scoped_ptr<SharedQuadState> copy(new SharedQuadState); | 49 scoped_ptr<SharedQuadState> copy(new SharedQuadState); |
| 56 copy->CopyFrom(state.get()); | 50 copy->CopyFrom(state.get()); |
| 57 EXPECT_EQ(quad_transform, copy->content_to_target_transform); | 51 EXPECT_EQ(quad_transform, copy->quad_to_target_transform); |
| 58 EXPECT_EQ(visible_content_rect, copy->visible_content_rect); | 52 EXPECT_EQ(visible_layer_rect, copy->visible_quad_layer_rect); |
| 59 EXPECT_EQ(opacity, copy->opacity); | 53 EXPECT_EQ(opacity, copy->opacity); |
| 60 EXPECT_EQ(clip_rect, copy->clip_rect); | 54 EXPECT_EQ(clip_rect, copy->clip_rect); |
| 61 EXPECT_EQ(is_clipped, copy->is_clipped); | 55 EXPECT_EQ(is_clipped, copy->is_clipped); |
| 62 EXPECT_EQ(blend_mode, copy->blend_mode); | 56 EXPECT_EQ(blend_mode, copy->blend_mode); |
| 63 } | 57 } |
| 64 | 58 |
| 65 SharedQuadState* CreateSharedQuadState(RenderPass* render_pass) { | 59 SharedQuadState* CreateSharedQuadState(RenderPass* render_pass) { |
| 66 gfx::Transform quad_transform = gfx::Transform(1.0, 0.0, 0.5, 1.0, 0.5, 0.0); | 60 gfx::Transform quad_transform = gfx::Transform(1.0, 0.0, 0.5, 1.0, 0.5, 0.0); |
| 67 gfx::Size content_bounds(26, 28); | 61 gfx::Size layer_bounds(26, 28); |
| 68 gfx::Rect visible_content_rect(10, 12, 14, 16); | 62 gfx::Rect visible_layer_rect(10, 12, 14, 16); |
| 69 gfx::Rect clip_rect(19, 21, 23, 25); | 63 gfx::Rect clip_rect(19, 21, 23, 25); |
| 70 bool is_clipped = false; | 64 bool is_clipped = false; |
| 71 float opacity = 1.f; | 65 float opacity = 1.f; |
| 72 int sorting_context_id = 65536; | 66 int sorting_context_id = 65536; |
| 73 SkXfermode::Mode blend_mode = SkXfermode::kSrcOver_Mode; | 67 SkXfermode::Mode blend_mode = SkXfermode::kSrcOver_Mode; |
| 74 | 68 |
| 75 SharedQuadState* state = render_pass->CreateAndAppendSharedQuadState(); | 69 SharedQuadState* state = render_pass->CreateAndAppendSharedQuadState(); |
| 76 state->SetAll(quad_transform, | 70 state->SetAll(quad_transform, layer_bounds, visible_layer_rect, clip_rect, |
| 77 content_bounds, | 71 is_clipped, opacity, blend_mode, sorting_context_id); |
| 78 visible_content_rect, | |
| 79 clip_rect, | |
| 80 is_clipped, | |
| 81 opacity, | |
| 82 blend_mode, | |
| 83 sorting_context_id); | |
| 84 return state; | 72 return state; |
| 85 } | 73 } |
| 86 | 74 |
| 87 void CompareDrawQuad(DrawQuad* quad, | 75 void CompareDrawQuad(DrawQuad* quad, |
| 88 DrawQuad* copy, | 76 DrawQuad* copy, |
| 89 SharedQuadState* copy_shared_state) { | 77 SharedQuadState* copy_shared_state) { |
| 90 EXPECT_EQ(quad->material, copy->material); | 78 EXPECT_EQ(quad->material, copy->material); |
| 91 EXPECT_EQ(quad->rect, copy->rect); | 79 EXPECT_EQ(quad->rect, copy->rect); |
| 92 EXPECT_EQ(quad->visible_rect, copy->visible_rect); | 80 EXPECT_EQ(quad->visible_rect, copy->visible_rect); |
| 93 EXPECT_EQ(quad->opaque_rect, copy->opaque_rect); | 81 EXPECT_EQ(quad->opaque_rect, copy->opaque_rect); |
| (...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1058 LOG(ERROR) << "YUVVideoDrawQuad " << sizeof(YUVVideoDrawQuad); | 1046 LOG(ERROR) << "YUVVideoDrawQuad " << sizeof(YUVVideoDrawQuad); |
| 1059 break; | 1047 break; |
| 1060 case DrawQuad::INVALID: | 1048 case DrawQuad::INVALID: |
| 1061 break; | 1049 break; |
| 1062 } | 1050 } |
| 1063 } | 1051 } |
| 1064 } | 1052 } |
| 1065 | 1053 |
| 1066 } // namespace | 1054 } // namespace |
| 1067 } // namespace cc | 1055 } // namespace cc |
| OLD | NEW |