Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: tests/PDFPrimitivesTest.cpp

Issue 1854023003: Update internal testing ImageFilters to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« gm/imagefiltersbase.cpp ('K') | « tests/ImageFilterTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2010 The Android Open Source Project 2 * Copyright 2010 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "Resources.h" 8 #include "Resources.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 TestObjectNumberMap(reporter); 357 TestObjectNumberMap(reporter);
358 TestObjectRef(reporter); 358 TestObjectRef(reporter);
359 TestSubstitute(reporter); 359 TestSubstitute(reporter);
360 test_issue1083(); 360 test_issue1083();
361 } 361 }
362 362
363 namespace { 363 namespace {
364 364
365 class DummyImageFilter : public SkImageFilter { 365 class DummyImageFilter : public SkImageFilter {
366 public: 366 public:
367 DummyImageFilter(bool visited = false) : SkImageFilter(0, nullptr), fVisited (visited) {} 367 static sk_sp<DummyImageFilter> Make(bool visited = false) {
368 ~DummyImageFilter() override {} 368 return sk_sp<DummyImageFilter>(new DummyImageFilter(visited));
369 }
370
371 SK_TO_STRING_OVERRIDE()
372 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(DummyImageFilter)
373 bool visited() const { return fVisited; }
374
375 protected:
369 bool onFilterImageDeprecated(Proxy*, const SkBitmap& src, const Context&, 376 bool onFilterImageDeprecated(Proxy*, const SkBitmap& src, const Context&,
370 SkBitmap* result, SkIPoint* offset) const overr ide { 377 SkBitmap* result, SkIPoint* offset) const overr ide {
371 fVisited = true; 378 fVisited = true;
372 offset->fX = offset->fY = 0; 379 offset->fX = offset->fY = 0;
373 *result = src; 380 *result = src;
374 return true; 381 return true;
375 } 382 }
376 SK_TO_STRING_OVERRIDE()
377 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(DummyImageFilter)
378 bool visited() const { return fVisited; }
379 383
380 private: 384 private:
385 DummyImageFilter(bool visited) : INHERITED(nullptr, 0, nullptr), fVisited(vi sited) {}
386
381 mutable bool fVisited; 387 mutable bool fVisited;
388
389 typedef SkImageFilter INHERITED;
382 }; 390 };
383 391
384 sk_sp<SkFlattenable> DummyImageFilter::CreateProc(SkReadBuffer& buffer) { 392 sk_sp<SkFlattenable> DummyImageFilter::CreateProc(SkReadBuffer& buffer) {
385 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 0); 393 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 0);
386 bool visited = buffer.readBool(); 394 bool visited = buffer.readBool();
387 return sk_make_sp<DummyImageFilter>(visited); 395 return DummyImageFilter::Make(visited);
388 } 396 }
389 397
390 #ifndef SK_IGNORE_TO_STRING 398 #ifndef SK_IGNORE_TO_STRING
391 void DummyImageFilter::toString(SkString* str) const { 399 void DummyImageFilter::toString(SkString* str) const {
392 str->appendf("DummyImageFilter: ("); 400 str->appendf("DummyImageFilter: (");
393 str->append(")"); 401 str->append(")");
394 } 402 }
395 #endif 403 #endif
396 404
397 }; 405 };
398 406
399 // Check that PDF rendering of image filters successfully falls back to 407 // Check that PDF rendering of image filters successfully falls back to
400 // CPU rasterization. 408 // CPU rasterization.
401 DEF_TEST(PDFImageFilter, reporter) { 409 DEF_TEST(PDFImageFilter, reporter) {
402 SkDynamicMemoryWStream stream; 410 SkDynamicMemoryWStream stream;
403 sk_sp<SkDocument> doc(SkDocument::CreatePDF(&stream)); 411 sk_sp<SkDocument> doc(SkDocument::CreatePDF(&stream));
404 SkCanvas* canvas = doc->beginPage(100.0f, 100.0f); 412 SkCanvas* canvas = doc->beginPage(100.0f, 100.0f);
405 413
406 sk_sp<DummyImageFilter> filter(new DummyImageFilter()); 414 sk_sp<DummyImageFilter> filter(DummyImageFilter::Make());
407 415
408 // Filter just created; should be unvisited. 416 // Filter just created; should be unvisited.
409 REPORTER_ASSERT(reporter, !filter->visited()); 417 REPORTER_ASSERT(reporter, !filter->visited());
410 SkPaint paint; 418 SkPaint paint;
411 paint.setImageFilter(filter.get()); 419 paint.setImageFilter(filter.get());
412 canvas->drawRect(SkRect::MakeWH(100, 100), paint); 420 canvas->drawRect(SkRect::MakeWH(100, 100), paint);
413 doc->close(); 421 doc->close();
414 422
415 // Filter was used in rendering; should be visited. 423 // Filter was used in rendering; should be visited.
416 REPORTER_ASSERT(reporter, filter->visited()); 424 REPORTER_ASSERT(reporter, filter->visited());
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 float alwaysCheck[] = { 482 float alwaysCheck[] = {
475 0.0f, -0.0f, 1.0f, -1.0f, SK_ScalarPI, 0.1f, FLT_MIN, FLT_MAX, 483 0.0f, -0.0f, 1.0f, -1.0f, SK_ScalarPI, 0.1f, FLT_MIN, FLT_MAX,
476 -FLT_MIN, -FLT_MAX, FLT_MIN / 16.0f, -FLT_MIN / 16.0f, 484 -FLT_MIN, -FLT_MAX, FLT_MIN / 16.0f, -FLT_MIN / 16.0f,
477 SK_FloatNaN, SK_FloatInfinity, SK_FloatNegativeInfinity, 485 SK_FloatNaN, SK_FloatInfinity, SK_FloatNegativeInfinity,
478 -FLT_MIN / 8388608.0 486 -FLT_MIN / 8388608.0
479 }; 487 };
480 for (float inputFloat: alwaysCheck) { 488 for (float inputFloat: alwaysCheck) {
481 check_pdf_scalar_serialization(reporter, inputFloat); 489 check_pdf_scalar_serialization(reporter, inputFloat);
482 } 490 }
483 } 491 }
OLDNEW
« gm/imagefiltersbase.cpp ('K') | « tests/ImageFilterTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698