OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
6 #include "skia/ext/analysis_canvas.h" | 6 #include "skia/ext/analysis_canvas.h" |
7 #include "skia/ext/refptr.h" | |
8 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "third_party/skia/include/core/SkPicture.h" | 8 #include "third_party/skia/include/core/SkPicture.h" |
10 #include "third_party/skia/include/core/SkPictureRecorder.h" | 9 #include "third_party/skia/include/core/SkPictureRecorder.h" |
| 10 #include "third_party/skia/include/core/SkRefCnt.h" |
11 #include "third_party/skia/include/core/SkShader.h" | 11 #include "third_party/skia/include/core/SkShader.h" |
12 #include "third_party/skia/include/effects/SkOffsetImageFilter.h" | 12 #include "third_party/skia/include/effects/SkOffsetImageFilter.h" |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 void SolidColorFill(skia::AnalysisCanvas& canvas) { | 16 void SolidColorFill(skia::AnalysisCanvas& canvas) { |
17 canvas.clear(SkColorSetARGB(255, 255, 255, 255)); | 17 canvas.clear(SkColorSetARGB(255, 255, 255, 255)); |
18 } | 18 } |
19 | 19 |
20 void TransparentFill(skia::AnalysisCanvas& canvas) { | 20 void TransparentFill(skia::AnalysisCanvas& canvas) { |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 canvas.rotate(50); | 176 canvas.rotate(50); |
177 canvas.drawRect(SkRect::MakeWH(255, 255), paint); | 177 canvas.drawRect(SkRect::MakeWH(255, 255), paint); |
178 | 178 |
179 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); | 179 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); |
180 } | 180 } |
181 | 181 |
182 TEST(AnalysisCanvasTest, FilterPaint) { | 182 TEST(AnalysisCanvasTest, FilterPaint) { |
183 skia::AnalysisCanvas canvas(255, 255); | 183 skia::AnalysisCanvas canvas(255, 255); |
184 SkPaint paint; | 184 SkPaint paint; |
185 | 185 |
186 skia::RefPtr<SkImageFilter> filter = | 186 paint.setImageFilter(SkOffsetImageFilter::Make(10, 10, nullptr)); |
187 skia::AdoptRef(SkOffsetImageFilter::Create(10, 10)); | |
188 paint.setImageFilter(filter.get()); | |
189 canvas.drawRect(SkRect::MakeWH(255, 255), paint); | 187 canvas.drawRect(SkRect::MakeWH(255, 255), paint); |
190 | 188 |
191 SkColor outputColor; | 189 SkColor outputColor; |
192 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); | 190 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); |
193 } | 191 } |
194 | 192 |
195 TEST(AnalysisCanvasTest, ClipPath) { | 193 TEST(AnalysisCanvasTest, ClipPath) { |
196 skia::AnalysisCanvas canvas(255, 255); | 194 skia::AnalysisCanvas canvas(255, 255); |
197 | 195 |
198 // Skia will look for paths that are actually rects and treat | 196 // Skia will look for paths that are actually rects and treat |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); | 382 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); |
385 | 383 |
386 canvas.restore(); | 384 canvas.restore(); |
387 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); | 385 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); |
388 | 386 |
389 SolidColorFill(canvas); | 387 SolidColorFill(canvas); |
390 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); | 388 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); |
391 } | 389 } |
392 | 390 |
393 } // namespace skia | 391 } // namespace skia |
OLD | NEW |