| 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 20 matching lines...) Expand all Loading... |
| 31 namespace { | 31 namespace { |
| 32 | 32 |
| 33 TEST(DrawQuadTest, CopySharedQuadState) { | 33 TEST(DrawQuadTest, CopySharedQuadState) { |
| 34 gfx::Transform quad_transform = gfx::Transform(1.0, 0.0, 0.5, 1.0, 0.5, 0.0); | 34 gfx::Transform quad_transform = gfx::Transform(1.0, 0.0, 0.5, 1.0, 0.5, 0.0); |
| 35 gfx::Size content_bounds(26, 28); | 35 gfx::Size content_bounds(26, 28); |
| 36 gfx::Rect visible_content_rect(10, 12, 14, 16); | 36 gfx::Rect visible_content_rect(10, 12, 14, 16); |
| 37 gfx::Rect clip_rect(19, 21, 23, 25); | 37 gfx::Rect clip_rect(19, 21, 23, 25); |
| 38 bool is_clipped = true; | 38 bool is_clipped = true; |
| 39 float opacity = 0.25f; | 39 float opacity = 0.25f; |
| 40 SkXfermode::Mode blend_mode = SkXfermode::kMultiply_Mode; | 40 SkXfermode::Mode blend_mode = SkXfermode::kMultiply_Mode; |
| 41 int sorting_context_id = 65536; |
| 41 | 42 |
| 42 scoped_ptr<SharedQuadState> state(new SharedQuadState); | 43 scoped_ptr<SharedQuadState> state(new SharedQuadState); |
| 43 state->SetAll(quad_transform, | 44 state->SetAll(quad_transform, |
| 44 content_bounds, | 45 content_bounds, |
| 45 visible_content_rect, | 46 visible_content_rect, |
| 46 clip_rect, | 47 clip_rect, |
| 47 is_clipped, | 48 is_clipped, |
| 48 opacity, | 49 opacity, |
| 49 blend_mode); | 50 blend_mode, |
| 51 sorting_context_id); |
| 50 | 52 |
| 51 scoped_ptr<SharedQuadState> copy(new SharedQuadState); | 53 scoped_ptr<SharedQuadState> copy(new SharedQuadState); |
| 52 copy->CopyFrom(state.get()); | 54 copy->CopyFrom(state.get()); |
| 53 EXPECT_EQ(quad_transform, copy->content_to_target_transform); | 55 EXPECT_EQ(quad_transform, copy->content_to_target_transform); |
| 54 EXPECT_RECT_EQ(visible_content_rect, copy->visible_content_rect); | 56 EXPECT_RECT_EQ(visible_content_rect, copy->visible_content_rect); |
| 55 EXPECT_EQ(opacity, copy->opacity); | 57 EXPECT_EQ(opacity, copy->opacity); |
| 56 EXPECT_RECT_EQ(clip_rect, copy->clip_rect); | 58 EXPECT_RECT_EQ(clip_rect, copy->clip_rect); |
| 57 EXPECT_EQ(is_clipped, copy->is_clipped); | 59 EXPECT_EQ(is_clipped, copy->is_clipped); |
| 58 EXPECT_EQ(blend_mode, copy->blend_mode); | 60 EXPECT_EQ(blend_mode, copy->blend_mode); |
| 59 } | 61 } |
| 60 | 62 |
| 61 scoped_ptr<SharedQuadState> CreateSharedQuadState() { | 63 scoped_ptr<SharedQuadState> CreateSharedQuadState() { |
| 62 gfx::Transform quad_transform = gfx::Transform(1.0, 0.0, 0.5, 1.0, 0.5, 0.0); | 64 gfx::Transform quad_transform = gfx::Transform(1.0, 0.0, 0.5, 1.0, 0.5, 0.0); |
| 63 gfx::Size content_bounds(26, 28); | 65 gfx::Size content_bounds(26, 28); |
| 64 gfx::Rect visible_content_rect(10, 12, 14, 16); | 66 gfx::Rect visible_content_rect(10, 12, 14, 16); |
| 65 gfx::Rect clip_rect(19, 21, 23, 25); | 67 gfx::Rect clip_rect(19, 21, 23, 25); |
| 66 bool is_clipped = false; | 68 bool is_clipped = false; |
| 67 float opacity = 1.f; | 69 float opacity = 1.f; |
| 70 int sorting_context_id = 65536; |
| 68 SkXfermode::Mode blend_mode = SkXfermode::kSrcOver_Mode; | 71 SkXfermode::Mode blend_mode = SkXfermode::kSrcOver_Mode; |
| 69 | 72 |
| 70 scoped_ptr<SharedQuadState> state(new SharedQuadState); | 73 scoped_ptr<SharedQuadState> state(new SharedQuadState); |
| 71 state->SetAll(quad_transform, | 74 state->SetAll(quad_transform, |
| 72 content_bounds, | 75 content_bounds, |
| 73 visible_content_rect, | 76 visible_content_rect, |
| 74 clip_rect, | 77 clip_rect, |
| 75 is_clipped, | 78 is_clipped, |
| 76 opacity, | 79 opacity, |
| 77 blend_mode); | 80 blend_mode, |
| 81 sorting_context_id); |
| 78 return state.Pass(); | 82 return state.Pass(); |
| 79 } | 83 } |
| 80 | 84 |
| 81 void CompareDrawQuad(DrawQuad* quad, | 85 void CompareDrawQuad(DrawQuad* quad, |
| 82 DrawQuad* copy, | 86 DrawQuad* copy, |
| 83 SharedQuadState* copy_shared_state) { | 87 SharedQuadState* copy_shared_state) { |
| 84 EXPECT_EQ(quad->material, copy->material); | 88 EXPECT_EQ(quad->material, copy->material); |
| 85 EXPECT_RECT_EQ(quad->rect, copy->rect); | 89 EXPECT_RECT_EQ(quad->rect, copy->rect); |
| 86 EXPECT_RECT_EQ(quad->visible_rect, copy->visible_rect); | 90 EXPECT_RECT_EQ(quad->visible_rect, copy->visible_rect); |
| 87 EXPECT_RECT_EQ(quad->opaque_rect, copy->opaque_rect); | 91 EXPECT_RECT_EQ(quad->opaque_rect, copy->opaque_rect); |
| (...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 904 texture_size, | 908 texture_size, |
| 905 texture_format, | 909 texture_format, |
| 906 content_rect, | 910 content_rect, |
| 907 contents_scale, | 911 contents_scale, |
| 908 picture_pile); | 912 picture_pile); |
| 909 EXPECT_EQ(0, IterateAndCount(quad_new.get())); | 913 EXPECT_EQ(0, IterateAndCount(quad_new.get())); |
| 910 } | 914 } |
| 911 | 915 |
| 912 } // namespace | 916 } // namespace |
| 913 } // namespace cc | 917 } // namespace cc |
| OLD | NEW |