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/SkPicture.h" | 9 #include "third_party/skia/include/core/SkPicture.h" |
10 #include "third_party/skia/include/core/SkPictureRecorder.h" | 10 #include "third_party/skia/include/core/SkPictureRecorder.h" |
(...skipping 165 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 = skia::AdoptRef(SkOffsetImageFilter::Creat
e(10, 10)); | 186 skia::RefPtr<SkImageFilter> filter = |
| 187 skia::AdoptRef(SkOffsetImageFilter::Create(10, 10)); |
187 paint.setImageFilter(filter.get()); | 188 paint.setImageFilter(filter.get()); |
188 canvas.drawRect(SkRect::MakeWH(255, 255), paint); | 189 canvas.drawRect(SkRect::MakeWH(255, 255), paint); |
189 | 190 |
190 SkColor outputColor; | 191 SkColor outputColor; |
191 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); | 192 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); |
192 } | 193 } |
193 | 194 |
194 TEST(AnalysisCanvasTest, ClipPath) { | 195 TEST(AnalysisCanvasTest, ClipPath) { |
195 skia::AnalysisCanvas canvas(255, 255); | 196 skia::AnalysisCanvas canvas(255, 255); |
196 | 197 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 | 338 |
338 SkPaint paint; | 339 SkPaint paint; |
339 paint.setColor(SkColorSetARGB(255, 255, 255, 255)); | 340 paint.setColor(SkColorSetARGB(255, 255, 255, 255)); |
340 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); | 341 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); |
341 | 342 |
342 record_canvas->drawRect(SkRect::MakeWH(256, 256), paint); | 343 record_canvas->drawRect(SkRect::MakeWH(256, 256), paint); |
343 record_canvas->drawRect(SkRect::MakeWH(256, 256), paint); | 344 record_canvas->drawRect(SkRect::MakeWH(256, 256), paint); |
344 record_canvas->drawText( | 345 record_canvas->drawText( |
345 text.c_str(), text.length(), point.fX, point.fY, paint); | 346 text.c_str(), text.length(), point.fX, point.fY, paint); |
346 | 347 |
347 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording()); | 348 skia::RefPtr<SkPicture> picture = |
| 349 skia::AdoptRef(recorder.endRecordingAsPicture()); |
348 | 350 |
349 // Draw the picture into the analysis canvas, using the canvas as a callback | 351 // Draw the picture into the analysis canvas, using the canvas as a callback |
350 // as well. | 352 // as well. |
351 skia::AnalysisCanvas canvas(256, 256); | 353 skia::AnalysisCanvas canvas(256, 256); |
352 picture->playback(&canvas, &canvas); | 354 picture->playback(&canvas, &canvas); |
353 | 355 |
354 // Ensure that canvas is not solid. | 356 // Ensure that canvas is not solid. |
355 SkColor output_color; | 357 SkColor output_color; |
356 EXPECT_FALSE(canvas.GetColorIfSolid(&output_color)); | 358 EXPECT_FALSE(canvas.GetColorIfSolid(&output_color)); |
357 | 359 |
358 // Verify that we aborted drawing. | 360 // Verify that we aborted drawing. |
359 EXPECT_TRUE(canvas.abortDrawing()); | 361 EXPECT_TRUE(canvas.abortDrawing()); |
360 | |
361 } | 362 } |
362 | 363 |
363 TEST(AnalysisCanvasTest, ClipComplexRegion) { | 364 TEST(AnalysisCanvasTest, ClipComplexRegion) { |
364 skia::AnalysisCanvas canvas(255, 255); | 365 skia::AnalysisCanvas canvas(255, 255); |
365 | 366 |
366 SkPath path; | 367 SkPath path; |
367 path.moveTo(0, 0); | 368 path.moveTo(0, 0); |
368 path.lineTo(128, 50); | 369 path.lineTo(128, 50); |
369 path.lineTo(255, 0); | 370 path.lineTo(255, 0); |
370 path.lineTo(255, 255); | 371 path.lineTo(255, 255); |
(...skipping 14 matching lines...) Expand all Loading... |
385 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); | 386 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); |
386 | 387 |
387 canvas.restore(); | 388 canvas.restore(); |
388 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); | 389 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); |
389 | 390 |
390 SolidColorFill(canvas); | 391 SolidColorFill(canvas); |
391 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); | 392 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); |
392 } | 393 } |
393 | 394 |
394 } // namespace skia | 395 } // namespace skia |
OLD | NEW |