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 "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "third_party/skia/include/core/SkShader.h" | 8 #include "third_party/skia/include/core/SkShader.h" |
9 | 9 |
10 namespace { | 10 namespace { |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 canvas.translate(128, 128); | 225 canvas.translate(128, 128); |
226 color = SkColorSetARGB(255, 11, 22, 33); | 226 color = SkColorSetARGB(255, 11, 22, 33); |
227 paint.setColor(color); | 227 paint.setColor(color); |
228 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); | 228 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); |
229 canvas.drawRect(SkRect::MakeWH(255, 255), paint); | 229 canvas.drawRect(SkRect::MakeWH(255, 255), paint); |
230 | 230 |
231 EXPECT_TRUE(canvas.getColorIfSolid(&outputColor)); | 231 EXPECT_TRUE(canvas.getColorIfSolid(&outputColor)); |
232 EXPECT_FALSE(canvas.isTransparent()); | 232 EXPECT_FALSE(canvas.isTransparent()); |
233 EXPECT_EQ(color, outputColor); | 233 EXPECT_EQ(color, outputColor); |
234 | 234 |
| 235 // Paint with the same color, tile should remain solid. |
235 canvas.rotate(50); | 236 canvas.rotate(50); |
236 canvas.drawRect(SkRect::MakeWH(255, 255), paint); | 237 canvas.drawRect(SkRect::MakeWH(255, 255), paint); |
237 | 238 |
| 239 EXPECT_TRUE(canvas.getColorIfSolid(&outputColor)); |
| 240 EXPECT_FALSE(canvas.isTransparent()); |
| 241 EXPECT_EQ(color, outputColor); |
| 242 |
| 243 color = SkColorSetARGB(255, 12, 23, 34); |
| 244 paint.setColor(color); |
| 245 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); |
| 246 canvas.drawRect(SkRect::MakeWH(255, 255), paint); |
238 EXPECT_FALSE(canvas.getColorIfSolid(&outputColor)); | 247 EXPECT_FALSE(canvas.getColorIfSolid(&outputColor)); |
239 EXPECT_FALSE(canvas.isTransparent()); | 248 EXPECT_FALSE(canvas.isTransparent()); |
240 } | 249 } |
241 | 250 |
242 TEST(AnalysisCanvasTest, ClipPath) { | 251 TEST(AnalysisCanvasTest, ClipPath) { |
243 SkBitmap emptyBitmap; | 252 SkBitmap emptyBitmap; |
244 emptyBitmap.setConfig(SkBitmap::kNo_Config, 255, 255); | 253 emptyBitmap.setConfig(SkBitmap::kNo_Config, 255, 255); |
245 skia::AnalysisDevice device(emptyBitmap); | 254 skia::AnalysisDevice device(emptyBitmap); |
246 skia::AnalysisCanvas canvas(&device); | 255 skia::AnalysisCanvas canvas(&device); |
247 | 256 |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 canvas.drawText(text, byteLength, point.fX, point.fY, paint); | 565 canvas.drawText(text, byteLength, point.fX, point.fY, paint); |
557 // Analysis device does not do any clipping. | 566 // Analysis device does not do any clipping. |
558 // So even when text is outside the clip region, | 567 // So even when text is outside the clip region, |
559 // it is marked as having the text. | 568 // it is marked as having the text. |
560 // TODO(alokp): We may be able to do some trivial rejection. | 569 // TODO(alokp): We may be able to do some trivial rejection. |
561 EXPECT_TRUE(canvas.hasText()); | 570 EXPECT_TRUE(canvas.hasText()); |
562 } | 571 } |
563 } | 572 } |
564 | 573 |
565 } // namespace skia | 574 } // namespace skia |
OLD | NEW |