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" | 7 #include "skia/ext/refptr.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "third_party/skia/include/core/SkShader.h" | 9 #include "third_party/skia/include/core/SkShader.h" |
10 #include "third_party/skia/include/effects/SkOffsetImageFilter.h" | 10 #include "third_party/skia/include/effects/SkOffsetImageFilter.h" |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 SkColor outputColor; | 228 SkColor outputColor; |
229 SolidColorFill(canvas); | 229 SolidColorFill(canvas); |
230 EXPECT_TRUE(canvas.GetColorIfSolid(&outputColor)); | 230 EXPECT_TRUE(canvas.GetColorIfSolid(&outputColor)); |
231 | 231 |
232 SkRect bounds = SkRect::MakeWH(255, 255); | 232 SkRect bounds = SkRect::MakeWH(255, 255); |
233 SkPaint paint; | 233 SkPaint paint; |
234 paint.setColor(SkColorSetARGB(255, 255, 255, 255)); | 234 paint.setColor(SkColorSetARGB(255, 255, 255, 255)); |
235 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); | 235 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); |
236 | 236 |
237 // This should force non-transparency | 237 // This should force non-transparency |
238 canvas.saveLayer(&bounds, &paint, SkCanvas::kMatrix_SaveFlag); | 238 canvas.saveLayer(&bounds, &paint); |
239 EXPECT_TRUE(canvas.GetColorIfSolid(&outputColor)); | 239 EXPECT_TRUE(canvas.GetColorIfSolid(&outputColor)); |
240 EXPECT_NE(static_cast<SkColor>(SK_ColorTRANSPARENT), outputColor); | 240 EXPECT_NE(static_cast<SkColor>(SK_ColorTRANSPARENT), outputColor); |
241 | 241 |
242 TransparentFill(canvas); | 242 TransparentFill(canvas); |
243 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); | 243 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); |
244 | 244 |
245 SolidColorFill(canvas); | 245 SolidColorFill(canvas); |
246 EXPECT_TRUE(canvas.GetColorIfSolid(&outputColor)); | 246 EXPECT_TRUE(canvas.GetColorIfSolid(&outputColor)); |
247 EXPECT_NE(static_cast<SkColor>(SK_ColorTRANSPARENT), outputColor); | 247 EXPECT_NE(static_cast<SkColor>(SK_ColorTRANSPARENT), outputColor); |
248 | 248 |
249 paint.setXfermodeMode(SkXfermode::kDst_Mode); | 249 paint.setXfermodeMode(SkXfermode::kDst_Mode); |
250 | 250 |
251 // This should force non-solid color | 251 // This should force non-solid color |
252 canvas.saveLayer(&bounds, &paint, SkCanvas::kMatrix_SaveFlag); | 252 canvas.saveLayer(&bounds, &paint); |
253 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); | 253 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); |
254 | 254 |
255 TransparentFill(canvas); | 255 TransparentFill(canvas); |
256 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); | 256 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); |
257 | 257 |
258 SolidColorFill(canvas); | 258 SolidColorFill(canvas); |
259 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); | 259 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); |
260 | 260 |
261 canvas.restore(); | 261 canvas.restore(); |
262 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); | 262 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 canvas.drawText(text, byteLength, point.fX, point.fY, paint); | 385 canvas.drawText(text, byteLength, point.fX, point.fY, paint); |
386 // Analysis device does not do any clipping. | 386 // Analysis device does not do any clipping. |
387 // So even when text is outside the clip region, | 387 // So even when text is outside the clip region, |
388 // it is marked as having the text. | 388 // it is marked as having the text. |
389 // TODO(alokp): We may be able to do some trivial rejection. | 389 // TODO(alokp): We may be able to do some trivial rejection. |
390 EXPECT_TRUE(canvas.HasText()); | 390 EXPECT_TRUE(canvas.HasText()); |
391 } | 391 } |
392 } | 392 } |
393 | 393 |
394 } // namespace skia | 394 } // namespace skia |
OLD | NEW |