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

Side by Side Diff: cc/render_pass_unittest.cc

Issue 11175009: Implement SkImageFilter support in the compositor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated to ToT (past the Great Renaming) Created 8 years, 2 months 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
« no previous file with comments | « cc/render_pass.cc ('k') | cc/render_surface_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "config.h" 5 #include "config.h"
6 6
7 #include "cc/render_pass.h" 7 #include "cc/render_pass.h"
8 8
9 #include "CCCheckerboardDrawQuad.h" 9 #include "CCCheckerboardDrawQuad.h"
10 #include "cc/test/geometry_test_utils.h" 10 #include "cc/test/geometry_test_utils.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "third_party/skia/include/effects/SkBlurImageFilter.h"
12 #include <public/WebFilterOperations.h> 13 #include <public/WebFilterOperations.h>
13 #include <public/WebTransformationMatrix.h> 14 #include <public/WebTransformationMatrix.h>
14 15
15 using WebKit::WebFilterOperation; 16 using WebKit::WebFilterOperation;
16 using WebKit::WebFilterOperations; 17 using WebKit::WebFilterOperations;
17 using WebKit::WebTransformationMatrix; 18 using WebKit::WebTransformationMatrix;
18 19
19 using namespace cc; 20 using namespace cc;
20 21
21 namespace { 22 namespace {
22 23
23 class TestRenderPass : public RenderPass { 24 class TestRenderPass : public RenderPass {
24 public: 25 public:
25 QuadList& quadList() { return m_quadList; } 26 QuadList& quadList() { return m_quadList; }
26 SharedQuadStateList& sharedQuadStateList() { return m_sharedQuadStateList; } 27 SharedQuadStateList& sharedQuadStateList() { return m_sharedQuadStateList; }
27 }; 28 };
28 29
29 struct RenderPassSize { 30 struct RenderPassSize {
30 // If you add a new field to this class, make sure to add it to the copy() t ests. 31 // If you add a new field to this class, make sure to add it to the copy() t ests.
31 RenderPass::Id m_id; 32 RenderPass::Id m_id;
32 QuadList m_quadList; 33 QuadList m_quadList;
33 SharedQuadStateList m_sharedQuadStateList; 34 SharedQuadStateList m_sharedQuadStateList;
34 WebKit::WebTransformationMatrix m_transformToRootTarget; 35 WebKit::WebTransformationMatrix m_transformToRootTarget;
35 gfx::Rect m_outputRect; 36 gfx::Rect m_outputRect;
36 gfx::RectF m_damageRect; 37 gfx::RectF m_damageRect;
37 bool m_hasTransparentBackground; 38 bool m_hasTransparentBackground;
38 bool m_hasOcclusionFromOutsideTargetSurface; 39 bool m_hasOcclusionFromOutsideTargetSurface;
39 WebKit::WebFilterOperations m_filters; 40 WebKit::WebFilterOperations m_filters;
40 WebKit::WebFilterOperations m_backgroundFilters; 41 WebKit::WebFilterOperations m_backgroundFilters;
42 SkImageFilter* m_filter;
41 }; 43 };
42 44
43 TEST(RenderPassTest, copyShouldBeIdenticalExceptIdAndQuads) 45 TEST(RenderPassTest, copyShouldBeIdenticalExceptIdAndQuads)
44 { 46 {
45 RenderPass::Id id(3, 2); 47 RenderPass::Id id(3, 2);
46 gfx::Rect outputRect(45, 22, 120, 13); 48 gfx::Rect outputRect(45, 22, 120, 13);
47 WebTransformationMatrix transformToRoot(1, 0.5, 0.5, -0.5, -1, 0); 49 WebTransformationMatrix transformToRoot(1, 0.5, 0.5, -0.5, -1, 0);
48 50
49 scoped_ptr<RenderPass> pass = RenderPass::create(id, outputRect, transformTo Root); 51 scoped_ptr<RenderPass> pass = RenderPass::create(id, outputRect, transformTo Root);
50 52
51 gfx::Rect damageRect(56, 123, 19, 43); 53 gfx::Rect damageRect(56, 123, 19, 43);
52 bool hasTransparentBackground = true; 54 bool hasTransparentBackground = true;
53 bool hasOcclusionFromOutsideTargetSurface = true; 55 bool hasOcclusionFromOutsideTargetSurface = true;
54 WebFilterOperations filters; 56 WebFilterOperations filters;
55 WebFilterOperations backgroundFilters; 57 WebFilterOperations backgroundFilters;
56 58
57 filters.append(WebFilterOperation::createGrayscaleFilter(0.2f)); 59 filters.append(WebFilterOperation::createGrayscaleFilter(0.2f));
58 backgroundFilters.append(WebFilterOperation::createInvertFilter(0.2f)); 60 backgroundFilters.append(WebFilterOperation::createInvertFilter(0.2f));
61 SkAutoTUnref<SkBlurImageFilter> filter(new SkBlurImageFilter(SK_Scalar1, SK_ Scalar1));
59 62
60 pass->setDamageRect(damageRect); 63 pass->setDamageRect(damageRect);
61 pass->setHasTransparentBackground(hasTransparentBackground); 64 pass->setHasTransparentBackground(hasTransparentBackground);
62 pass->setHasOcclusionFromOutsideTargetSurface(hasOcclusionFromOutsideTargetS urface); 65 pass->setHasOcclusionFromOutsideTargetSurface(hasOcclusionFromOutsideTargetS urface);
63 pass->setFilters(filters); 66 pass->setFilters(filters);
64 pass->setBackgroundFilters(backgroundFilters); 67 pass->setBackgroundFilters(backgroundFilters);
68 pass->setFilter(filter);
65 69
66 // Stick a quad in the pass, this should not get copied. 70 // Stick a quad in the pass, this should not get copied.
67 TestRenderPass* testPass = static_cast<TestRenderPass*>(pass.get()); 71 TestRenderPass* testPass = static_cast<TestRenderPass*>(pass.get());
68 testPass->sharedQuadStateList().append(SharedQuadState::create(WebTransforma tionMatrix(), gfx::Rect(), gfx::Rect(), 1, false)); 72 testPass->sharedQuadStateList().append(SharedQuadState::create(WebTransforma tionMatrix(), gfx::Rect(), gfx::Rect(), 1, false));
69 testPass->quadList().append(CheckerboardDrawQuad::create(testPass->sharedQua dStateList().last(), gfx::Rect(), SkColor()).PassAs<DrawQuad>()); 73 testPass->quadList().append(CheckerboardDrawQuad::create(testPass->sharedQua dStateList().last(), gfx::Rect(), SkColor()).PassAs<DrawQuad>());
70 74
71 RenderPass::Id newId(63, 4); 75 RenderPass::Id newId(63, 4);
72 76
73 scoped_ptr<RenderPass> copy = pass->copy(newId); 77 scoped_ptr<RenderPass> copy = pass->copy(newId);
74 EXPECT_EQ(newId, copy->id()); 78 EXPECT_EQ(newId, copy->id());
75 EXPECT_RECT_EQ(pass->outputRect(), copy->outputRect()); 79 EXPECT_RECT_EQ(pass->outputRect(), copy->outputRect());
76 EXPECT_EQ(pass->transformToRootTarget(), copy->transformToRootTarget()); 80 EXPECT_EQ(pass->transformToRootTarget(), copy->transformToRootTarget());
77 EXPECT_RECT_EQ(pass->damageRect(), copy->damageRect()); 81 EXPECT_RECT_EQ(pass->damageRect(), copy->damageRect());
78 EXPECT_EQ(pass->hasTransparentBackground(), copy->hasTransparentBackground() ); 82 EXPECT_EQ(pass->hasTransparentBackground(), copy->hasTransparentBackground() );
79 EXPECT_EQ(pass->hasOcclusionFromOutsideTargetSurface(), copy->hasOcclusionFr omOutsideTargetSurface()); 83 EXPECT_EQ(pass->hasOcclusionFromOutsideTargetSurface(), copy->hasOcclusionFr omOutsideTargetSurface());
80 EXPECT_EQ(pass->filters(), copy->filters()); 84 EXPECT_EQ(pass->filters(), copy->filters());
81 EXPECT_EQ(pass->backgroundFilters(), copy->backgroundFilters()); 85 EXPECT_EQ(pass->backgroundFilters(), copy->backgroundFilters());
86 EXPECT_EQ(pass->filter(), copy->filter());
82 EXPECT_EQ(0u, copy->quadList().size()); 87 EXPECT_EQ(0u, copy->quadList().size());
83 88
84 EXPECT_EQ(sizeof(RenderPassSize), sizeof(RenderPass)); 89 EXPECT_EQ(sizeof(RenderPassSize), sizeof(RenderPass));
85 } 90 }
86 91
87 } // namespace 92 } // namespace
OLDNEW
« no previous file with comments | « cc/render_pass.cc ('k') | cc/render_surface_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698