Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Side by Side Diff: cc/render_pass_unittest.cc

Issue 11618026: Move filters to RenderPassDrawQuad (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/render_pass.h" 5 #include "cc/render_pass.h"
6 6
7 #include <public/WebFilterOperations.h>
8
9 #include "cc/checkerboard_draw_quad.h" 7 #include "cc/checkerboard_draw_quad.h"
10 #include "cc/math_util.h" 8 #include "cc/math_util.h"
11 #include "cc/test/geometry_test_utils.h" 9 #include "cc/test/geometry_test_utils.h"
12 #include "cc/test/render_pass_test_common.h" 10 #include "cc/test/render_pass_test_common.h"
13 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
14 #include "third_party/skia/include/effects/SkBlurImageFilter.h" 12 #include "third_party/skia/include/effects/SkBlurImageFilter.h"
15 #include "ui/gfx/transform.h" 13 #include "ui/gfx/transform.h"
16 14
17 using WebKit::WebFilterOperation;
18 using WebKit::WebFilterOperations;
19 using cc::TestRenderPass; 15 using cc::TestRenderPass;
20 16
21 namespace cc { 17 namespace cc {
22 namespace { 18 namespace {
23 19
24 struct RenderPassSize { 20 struct RenderPassSize {
25 // If you add a new field to this class, make sure to add it to the copy() t ests. 21 // If you add a new field to this class, make sure to add it to the copy() t ests.
26 RenderPass::Id m_id; 22 RenderPass::Id m_id;
27 QuadList m_quadList; 23 QuadList m_quadList;
28 SharedQuadStateList m_sharedQuadStateList; 24 SharedQuadStateList m_sharedQuadStateList;
29 gfx::Transform m_transformToRootTarget; 25 gfx::Transform m_transformToRootTarget;
30 gfx::Rect m_outputRect; 26 gfx::Rect m_outputRect;
31 gfx::RectF m_damageRect; 27 gfx::RectF m_damageRect;
32 bool m_hasTransparentBackground; 28 bool m_hasTransparentBackground;
33 bool m_hasOcclusionFromOutsideTargetSurface; 29 bool m_hasOcclusionFromOutsideTargetSurface;
34 WebKit::WebFilterOperations m_filters;
35 WebKit::WebFilterOperations m_backgroundFilters;
36 SkImageFilter* m_filter;
37 }; 30 };
38 31
39 TEST(RenderPassTest, copyShouldBeIdenticalExceptIdAndQuads) 32 TEST(RenderPassTest, copyShouldBeIdenticalExceptIdAndQuads)
40 { 33 {
41 RenderPass::Id id(3, 2); 34 RenderPass::Id id(3, 2);
42 gfx::Rect outputRect(45, 22, 120, 13); 35 gfx::Rect outputRect(45, 22, 120, 13);
43 gfx::Transform transformToRoot = MathUtil::createGfxTransform(1, 0.5, 0.5, - 0.5, -1, 0); 36 gfx::Transform transformToRoot = MathUtil::createGfxTransform(1, 0.5, 0.5, - 0.5, -1, 0);
44 gfx::Rect damageRect(56, 123, 19, 43); 37 gfx::Rect damageRect(56, 123, 19, 43);
45 bool hasTransparentBackground = true; 38 bool hasTransparentBackground = true;
46 bool hasOcclusionFromOutsideTargetSurface = true; 39 bool hasOcclusionFromOutsideTargetSurface = true;
47 WebFilterOperations filters;
48 WebFilterOperations backgroundFilters;
49
50 filters.append(WebFilterOperation::createGrayscaleFilter(0.2f));
51 backgroundFilters.append(WebFilterOperation::createInvertFilter(0.2f));
52 skia::RefPtr<SkImageFilter> filter = skia::AdoptRef(new SkBlurImageFilter(SK _Scalar1, SK_Scalar1));
53 40
54 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); 41 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create();
55 pass->SetAll(id, 42 pass->SetAll(id,
56 outputRect, 43 outputRect,
57 damageRect, 44 damageRect,
58 transformToRoot, 45 transformToRoot,
59 hasTransparentBackground, 46 hasTransparentBackground,
60 hasOcclusionFromOutsideTargetSurface, 47 hasOcclusionFromOutsideTargetSurface);
61 filters,
62 filter,
63 backgroundFilters);
64 48
65 // Stick a quad in the pass, this should not get copied. 49 // Stick a quad in the pass, this should not get copied.
66 scoped_ptr<SharedQuadState> sharedState = SharedQuadState::Create(); 50 scoped_ptr<SharedQuadState> sharedState = SharedQuadState::Create();
67 sharedState->SetAll(gfx::Transform(), gfx::Rect(), gfx::Rect(), gfx::Rect(), false, 1); 51 sharedState->SetAll(gfx::Transform(), gfx::Rect(), gfx::Rect(), gfx::Rect(), false, 1);
68 pass->AppendSharedQuadState(sharedState.Pass()); 52 pass->AppendSharedQuadState(sharedState.Pass());
69 53
70 scoped_ptr<CheckerboardDrawQuad> checkerboardQuad = CheckerboardDrawQuad::Cr eate(); 54 scoped_ptr<CheckerboardDrawQuad> checkerboardQuad = CheckerboardDrawQuad::Cr eate();
71 checkerboardQuad->SetNew(pass->shared_quad_state_list.last(), gfx::Rect(), S kColor()); 55 checkerboardQuad->SetNew(pass->shared_quad_state_list.last(), gfx::Rect(), S kColor());
72 pass->quad_list.append(checkerboardQuad.PassAs<DrawQuad>()); 56 pass->quad_list.append(checkerboardQuad.PassAs<DrawQuad>());
73 57
74 RenderPass::Id newId(63, 4); 58 RenderPass::Id newId(63, 4);
75 59
76 scoped_ptr<RenderPass> copy = pass->Copy(newId); 60 scoped_ptr<RenderPass> copy = pass->Copy(newId);
77 EXPECT_EQ(newId, copy->id); 61 EXPECT_EQ(newId, copy->id);
78 EXPECT_RECT_EQ(pass->output_rect, copy->output_rect); 62 EXPECT_RECT_EQ(pass->output_rect, copy->output_rect);
79 EXPECT_EQ(pass->transform_to_root_target, copy->transform_to_root_target); 63 EXPECT_EQ(pass->transform_to_root_target, copy->transform_to_root_target);
80 EXPECT_RECT_EQ(pass->damage_rect, copy->damage_rect); 64 EXPECT_RECT_EQ(pass->damage_rect, copy->damage_rect);
81 EXPECT_EQ(pass->has_transparent_background, copy->has_transparent_background ); 65 EXPECT_EQ(pass->has_transparent_background, copy->has_transparent_background );
82 EXPECT_EQ(pass->has_occlusion_from_outside_target_surface, copy->has_occlusi on_from_outside_target_surface); 66 EXPECT_EQ(pass->has_occlusion_from_outside_target_surface, copy->has_occlusi on_from_outside_target_surface);
83 EXPECT_EQ(pass->filters, copy->filters);
84 EXPECT_EQ(pass->filter, copy->filter);
85 EXPECT_EQ(pass->background_filters, copy->background_filters);
86 EXPECT_EQ(0u, copy->quad_list.size()); 67 EXPECT_EQ(0u, copy->quad_list.size());
87 68
88 EXPECT_EQ(sizeof(RenderPassSize), sizeof(RenderPass)); 69 EXPECT_EQ(sizeof(RenderPassSize), sizeof(RenderPass));
89 } 70 }
90 71
91 } // namespace 72 } // namespace
92 } // namespace cc 73 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698