| 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 18 matching lines...) Expand all Loading... |
| 29 namespace cc { | 29 namespace cc { |
| 30 namespace { | 30 namespace { |
| 31 | 31 |
| 32 TEST(DrawQuadTest, CopySharedQuadState) { | 32 TEST(DrawQuadTest, CopySharedQuadState) { |
| 33 gfx::Transform quad_transform = gfx::Transform(1.0, 0.0, 0.5, 1.0, 0.5, 0.0); | 33 gfx::Transform quad_transform = gfx::Transform(1.0, 0.0, 0.5, 1.0, 0.5, 0.0); |
| 34 gfx::Size content_bounds(26, 28); | 34 gfx::Size content_bounds(26, 28); |
| 35 gfx::Rect visible_content_rect(10, 12, 14, 16); | 35 gfx::Rect visible_content_rect(10, 12, 14, 16); |
| 36 gfx::Rect clip_rect(19, 21, 23, 25); | 36 gfx::Rect clip_rect(19, 21, 23, 25); |
| 37 bool is_clipped = true; | 37 bool is_clipped = true; |
| 38 float opacity = 0.25f; | 38 float opacity = 0.25f; |
| 39 SkXfermode::Mode blend_mode = SkXfermode::kMultiply_Mode; |
| 39 | 40 |
| 40 scoped_ptr<SharedQuadState> state(SharedQuadState::Create()); | 41 scoped_ptr<SharedQuadState> state(SharedQuadState::Create()); |
| 41 state->SetAll(quad_transform, | 42 state->SetAll(quad_transform, |
| 42 content_bounds, | 43 content_bounds, |
| 43 visible_content_rect, | 44 visible_content_rect, |
| 44 clip_rect, | 45 clip_rect, |
| 45 is_clipped, | 46 is_clipped, |
| 46 opacity); | 47 opacity, |
| 48 blend_mode); |
| 47 | 49 |
| 48 scoped_ptr<SharedQuadState> copy(state->Copy()); | 50 scoped_ptr<SharedQuadState> copy(state->Copy()); |
| 49 EXPECT_EQ(quad_transform, copy->content_to_target_transform); | 51 EXPECT_EQ(quad_transform, copy->content_to_target_transform); |
| 50 EXPECT_RECT_EQ(visible_content_rect, copy->visible_content_rect); | 52 EXPECT_RECT_EQ(visible_content_rect, copy->visible_content_rect); |
| 51 EXPECT_EQ(opacity, copy->opacity); | 53 EXPECT_EQ(opacity, copy->opacity); |
| 52 EXPECT_RECT_EQ(clip_rect, copy->clip_rect); | 54 EXPECT_RECT_EQ(clip_rect, copy->clip_rect); |
| 53 EXPECT_EQ(is_clipped, copy->is_clipped); | 55 EXPECT_EQ(is_clipped, copy->is_clipped); |
| 56 EXPECT_EQ(blend_mode, copy->blend_mode); |
| 54 } | 57 } |
| 55 | 58 |
| 56 scoped_ptr<SharedQuadState> CreateSharedQuadState() { | 59 scoped_ptr<SharedQuadState> CreateSharedQuadState() { |
| 57 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); |
| 58 gfx::Size content_bounds(26, 28); | 61 gfx::Size content_bounds(26, 28); |
| 59 gfx::Rect visible_content_rect(10, 12, 14, 16); | 62 gfx::Rect visible_content_rect(10, 12, 14, 16); |
| 60 gfx::Rect clip_rect(19, 21, 23, 25); | 63 gfx::Rect clip_rect(19, 21, 23, 25); |
| 61 bool is_clipped = false; | 64 bool is_clipped = false; |
| 62 float opacity = 1.f; | 65 float opacity = 1.f; |
| 66 SkXfermode::Mode blend_mode = SkXfermode::kSrcOver_Mode; |
| 63 | 67 |
| 64 scoped_ptr<SharedQuadState> state(SharedQuadState::Create()); | 68 scoped_ptr<SharedQuadState> state(SharedQuadState::Create()); |
| 65 state->SetAll(quad_transform, | 69 state->SetAll(quad_transform, |
| 66 content_bounds, | 70 content_bounds, |
| 67 visible_content_rect, | 71 visible_content_rect, |
| 68 clip_rect, | 72 clip_rect, |
| 69 is_clipped, | 73 is_clipped, |
| 70 opacity); | 74 opacity, |
| 75 blend_mode); |
| 71 return state.Pass(); | 76 return state.Pass(); |
| 72 } | 77 } |
| 73 | 78 |
| 74 void CompareDrawQuad(DrawQuad* quad, | 79 void CompareDrawQuad(DrawQuad* quad, |
| 75 DrawQuad* copy, | 80 DrawQuad* copy, |
| 76 SharedQuadState* copy_shared_state) { | 81 SharedQuadState* copy_shared_state) { |
| 77 EXPECT_EQ(quad->material, copy->material); | 82 EXPECT_EQ(quad->material, copy->material); |
| 78 EXPECT_RECT_EQ(quad->rect, copy->rect); | 83 EXPECT_RECT_EQ(quad->rect, copy->rect); |
| 79 EXPECT_RECT_EQ(quad->visible_rect, copy->visible_rect); | 84 EXPECT_RECT_EQ(quad->visible_rect, copy->visible_rect); |
| 80 EXPECT_RECT_EQ(quad->opaque_rect, copy->opaque_rect); | 85 EXPECT_RECT_EQ(quad->opaque_rect, copy->opaque_rect); |
| (...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 texture_format, | 825 texture_format, |
| 821 content_rect, | 826 content_rect, |
| 822 contents_scale, | 827 contents_scale, |
| 823 can_draw_direct_to_backbuffer, | 828 can_draw_direct_to_backbuffer, |
| 824 picture_pile); | 829 picture_pile); |
| 825 EXPECT_EQ(0, IterateAndCount(quad_new.get())); | 830 EXPECT_EQ(0, IterateAndCount(quad_new.get())); |
| 826 } | 831 } |
| 827 | 832 |
| 828 } // namespace | 833 } // namespace |
| 829 } // namespace cc | 834 } // namespace cc |
| OLD | NEW |