| OLD | NEW |
| 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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkData.h" | 10 #include "SkData.h" |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 public: | 436 public: |
| 437 DummyImageFilter(bool visited = false) : SkImageFilter(0, NULL), fVisited(vi
sited) {} | 437 DummyImageFilter(bool visited = false) : SkImageFilter(0, NULL), fVisited(vi
sited) {} |
| 438 virtual ~DummyImageFilter() SK_OVERRIDE {} | 438 virtual ~DummyImageFilter() SK_OVERRIDE {} |
| 439 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, | 439 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, |
| 440 SkBitmap* result, SkIPoint* offset) const { | 440 SkBitmap* result, SkIPoint* offset) const { |
| 441 fVisited = true; | 441 fVisited = true; |
| 442 offset->fX = offset->fY = 0; | 442 offset->fX = offset->fY = 0; |
| 443 *result = src; | 443 *result = src; |
| 444 return true; | 444 return true; |
| 445 } | 445 } |
| 446 SK_TO_STRING_OVERRIDE() |
| 446 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(DummyImageFilter) | 447 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(DummyImageFilter) |
| 447 bool visited() const { return fVisited; } | 448 bool visited() const { return fVisited; } |
| 448 | 449 |
| 449 private: | 450 private: |
| 450 mutable bool fVisited; | 451 mutable bool fVisited; |
| 451 }; | 452 }; |
| 452 | 453 |
| 453 SkFlattenable* DummyImageFilter::CreateProc(SkReadBuffer& buffer) { | 454 SkFlattenable* DummyImageFilter::CreateProc(SkReadBuffer& buffer) { |
| 454 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 0); | 455 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 0); |
| 455 bool visited = buffer.readBool(); | 456 bool visited = buffer.readBool(); |
| 456 return SkNEW_ARGS(DummyImageFilter, (visited)); | 457 return SkNEW_ARGS(DummyImageFilter, (visited)); |
| 457 } | 458 } |
| 458 | 459 |
| 460 #ifndef SK_IGNORE_TO_STRING |
| 461 void DummyImageFilter::toString(SkString* str) const { |
| 462 str->appendf("DummyImageFilter: ("); |
| 463 str->append(")"); |
| 464 } |
| 465 #endif |
| 466 |
| 459 }; | 467 }; |
| 460 | 468 |
| 461 // Check that PDF rendering of image filters successfully falls back to | 469 // Check that PDF rendering of image filters successfully falls back to |
| 462 // CPU rasterization. | 470 // CPU rasterization. |
| 463 DEF_TEST(PDFImageFilter, reporter) { | 471 DEF_TEST(PDFImageFilter, reporter) { |
| 464 SkISize pageSize = SkISize::Make(100, 100); | 472 SkISize pageSize = SkISize::Make(100, 100); |
| 465 SkAutoTUnref<SkPDFDevice> device(new SkPDFDevice(pageSize, pageSize, SkMatri
x::I())); | 473 SkAutoTUnref<SkPDFDevice> device(new SkPDFDevice(pageSize, pageSize, SkMatri
x::I())); |
| 466 SkCanvas canvas(device.get()); | 474 SkCanvas canvas(device.get()); |
| 467 SkAutoTUnref<DummyImageFilter> filter(new DummyImageFilter()); | 475 SkAutoTUnref<DummyImageFilter> filter(new DummyImageFilter()); |
| 468 | 476 |
| 469 // Filter just created; should be unvisited. | 477 // Filter just created; should be unvisited. |
| 470 REPORTER_ASSERT(reporter, !filter->visited()); | 478 REPORTER_ASSERT(reporter, !filter->visited()); |
| 471 SkPaint paint; | 479 SkPaint paint; |
| 472 paint.setImageFilter(filter.get()); | 480 paint.setImageFilter(filter.get()); |
| 473 canvas.drawRect(SkRect::MakeWH(100, 100), paint); | 481 canvas.drawRect(SkRect::MakeWH(100, 100), paint); |
| 474 | 482 |
| 475 // Filter was used in rendering; should be visited. | 483 // Filter was used in rendering; should be visited. |
| 476 REPORTER_ASSERT(reporter, filter->visited()); | 484 REPORTER_ASSERT(reporter, filter->visited()); |
| 477 } | 485 } |
| OLD | NEW |