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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 color = SkColorSetARGB(255, 11, 22, 33); | 241 color = SkColorSetARGB(255, 11, 22, 33); |
242 paint.setColor(color); | 242 paint.setColor(color); |
243 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); | 243 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); |
244 canvas.drawRect(SkRect::MakeWH(255, 255), paint); | 244 canvas.drawRect(SkRect::MakeWH(255, 255), paint); |
245 | 245 |
246 EXPECT_TRUE(canvas.getColorIfSolid(&outputColor)); | 246 EXPECT_TRUE(canvas.getColorIfSolid(&outputColor)); |
247 EXPECT_FALSE(canvas.isTransparent()); | 247 EXPECT_FALSE(canvas.isTransparent()); |
248 EXPECT_TRUE(canvas.isCheap()); | 248 EXPECT_TRUE(canvas.isCheap()); |
249 EXPECT_EQ(color, outputColor); | 249 EXPECT_EQ(color, outputColor); |
250 | 250 |
| 251 // Paint with the same color, tile should remain solid. |
251 canvas.rotate(50); | 252 canvas.rotate(50); |
252 canvas.drawRect(SkRect::MakeWH(255, 255), paint); | 253 canvas.drawRect(SkRect::MakeWH(255, 255), paint); |
253 | 254 |
| 255 EXPECT_TRUE(canvas.getColorIfSolid(&outputColor)); |
| 256 EXPECT_FALSE(canvas.isTransparent()); |
| 257 EXPECT_TRUE(canvas.isCheap()); |
| 258 EXPECT_EQ(color, outputColor); |
| 259 |
| 260 color = SkColorSetARGB(255, 12, 23, 34); |
| 261 paint.setColor(color); |
| 262 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); |
| 263 canvas.drawRect(SkRect::MakeWH(255, 255), paint); |
254 EXPECT_FALSE(canvas.getColorIfSolid(&outputColor)); | 264 EXPECT_FALSE(canvas.getColorIfSolid(&outputColor)); |
255 EXPECT_FALSE(canvas.isTransparent()); | 265 EXPECT_FALSE(canvas.isTransparent()); |
256 EXPECT_TRUE(canvas.isCheap()); | |
257 } | 266 } |
258 | 267 |
259 TEST(AnalysisCanvasTest, ClipPath) { | 268 TEST(AnalysisCanvasTest, ClipPath) { |
260 SkBitmap emptyBitmap; | 269 SkBitmap emptyBitmap; |
261 emptyBitmap.setConfig(SkBitmap::kNo_Config, 255, 255); | 270 emptyBitmap.setConfig(SkBitmap::kNo_Config, 255, 255); |
262 skia::AnalysisDevice device(emptyBitmap); | 271 skia::AnalysisDevice device(emptyBitmap); |
263 skia::AnalysisCanvas canvas(&device); | 272 skia::AnalysisCanvas canvas(&device); |
264 | 273 |
265 SkPath path; | 274 SkPath path; |
266 path.moveTo(0, 0); | 275 path.moveTo(0, 0); |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 canvas.drawText(text, byteLength, point.fX, point.fY, paint); | 582 canvas.drawText(text, byteLength, point.fX, point.fY, paint); |
574 // Analysis device does not do any clipping. | 583 // Analysis device does not do any clipping. |
575 // So even when text is outside the clip region, | 584 // So even when text is outside the clip region, |
576 // it is marked as having the text. | 585 // it is marked as having the text. |
577 // TODO(alokp): We may be able to do some trivial rejection. | 586 // TODO(alokp): We may be able to do some trivial rejection. |
578 EXPECT_TRUE(canvas.hasText()); | 587 EXPECT_TRUE(canvas.hasText()); |
579 } | 588 } |
580 } | 589 } |
581 | 590 |
582 } // namespace skia | 591 } // namespace skia |
OLD | NEW |