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 14 matching lines...) Expand all Loading... |
25 #define DUMMY_TEXT "DCT compessed stream." | 25 #define DUMMY_TEXT "DCT compessed stream." |
26 | 26 |
27 namespace { | 27 namespace { |
28 struct Catalog { | 28 struct Catalog { |
29 SkPDFSubstituteMap substitutes; | 29 SkPDFSubstituteMap substitutes; |
30 SkPDFObjNumMap numbers; | 30 SkPDFObjNumMap numbers; |
31 }; | 31 }; |
32 } // namespace | 32 } // namespace |
33 | 33 |
34 template <typename T> | 34 template <typename T> |
35 static SkString emit_to_string(T& obj, Catalog* catPtr = NULL) { | 35 static SkString emit_to_string(T& obj, Catalog* catPtr = nullptr) { |
36 Catalog catalog; | 36 Catalog catalog; |
37 SkDynamicMemoryWStream buffer; | 37 SkDynamicMemoryWStream buffer; |
38 if (!catPtr) { | 38 if (!catPtr) { |
39 catPtr = &catalog; | 39 catPtr = &catalog; |
40 } | 40 } |
41 obj.emitObject(&buffer, catPtr->numbers, catPtr->substitutes); | 41 obj.emitObject(&buffer, catPtr->numbers, catPtr->substitutes); |
42 SkAutoTDelete<SkStreamAsset> asset(buffer.detachAsStream()); | 42 SkAutoTDelete<SkStreamAsset> asset(buffer.detachAsStream()); |
43 SkString tmp(asset->getLength()); | 43 SkString tmp(asset->getLength()); |
44 asset->read(tmp.writable_str(), asset->getLength()); | 44 asset->read(tmp.writable_str(), asset->getLength()); |
45 return tmp; | 45 return tmp; |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, NULL), fVisited(vi
sited) {} | 367 DummyImageFilter(bool visited = false) : SkImageFilter(0, nullptr), fVisited
(visited) {} |
368 ~DummyImageFilter() override {} | 368 ~DummyImageFilter() override {} |
369 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, | 369 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, |
370 SkBitmap* result, SkIPoint* offset) const overrid
e { | 370 SkBitmap* result, SkIPoint* offset) const overrid
e { |
371 fVisited = true; | 371 fVisited = true; |
372 offset->fX = offset->fY = 0; | 372 offset->fX = offset->fY = 0; |
373 *result = src; | 373 *result = src; |
374 return true; | 374 return true; |
375 } | 375 } |
376 SK_TO_STRING_OVERRIDE() | 376 SK_TO_STRING_OVERRIDE() |
377 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(DummyImageFilter) | 377 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(DummyImageFilter) |
(...skipping 30 matching lines...) Expand all Loading... |
408 // Filter just created; should be unvisited. | 408 // Filter just created; should be unvisited. |
409 REPORTER_ASSERT(reporter, !filter->visited()); | 409 REPORTER_ASSERT(reporter, !filter->visited()); |
410 SkPaint paint; | 410 SkPaint paint; |
411 paint.setImageFilter(filter.get()); | 411 paint.setImageFilter(filter.get()); |
412 canvas->drawRect(SkRect::MakeWH(100, 100), paint); | 412 canvas->drawRect(SkRect::MakeWH(100, 100), paint); |
413 doc->close(); | 413 doc->close(); |
414 | 414 |
415 // Filter was used in rendering; should be visited. | 415 // Filter was used in rendering; should be visited. |
416 REPORTER_ASSERT(reporter, filter->visited()); | 416 REPORTER_ASSERT(reporter, filter->visited()); |
417 } | 417 } |
OLD | NEW |