OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
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 "DMSrcSink.h" | 8 #include "DMSrcSink.h" |
9 #include "Resources.h" | 9 #include "Resources.h" |
10 #include "SkAndroidCodec.h" | 10 #include "SkAndroidCodec.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "SkImageGeneratorWIC.h" | 23 #include "SkImageGeneratorWIC.h" |
24 #include "SkLiteDL.h" | 24 #include "SkLiteDL.h" |
25 #include "SkLiteRecorder.h" | 25 #include "SkLiteRecorder.h" |
26 #include "SkMallocPixelRef.h" | 26 #include "SkMallocPixelRef.h" |
27 #include "SkMultiPictureDraw.h" | 27 #include "SkMultiPictureDraw.h" |
28 #include "SkNullCanvas.h" | 28 #include "SkNullCanvas.h" |
29 #include "SkOSFile.h" | 29 #include "SkOSFile.h" |
30 #include "SkOpts.h" | 30 #include "SkOpts.h" |
31 #include "SkPictureData.h" | 31 #include "SkPictureData.h" |
32 #include "SkPictureRecorder.h" | 32 #include "SkPictureRecorder.h" |
| 33 #include "SkPipe.h" |
33 #include "SkRandom.h" | 34 #include "SkRandom.h" |
34 #include "SkRecordDraw.h" | 35 #include "SkRecordDraw.h" |
35 #include "SkRecorder.h" | 36 #include "SkRecorder.h" |
36 #include "SkSVGCanvas.h" | 37 #include "SkSVGCanvas.h" |
37 #include "SkStream.h" | 38 #include "SkStream.h" |
38 #include "SkTLogic.h" | 39 #include "SkTLogic.h" |
39 #include "SkSwizzler.h" | 40 #include "SkSwizzler.h" |
40 #include <functional> | 41 #include <functional> |
41 | 42 |
42 #if defined(SK_BUILD_FOR_WIN) | 43 #if defined(SK_BUILD_FOR_WIN) |
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1234 | 1235 |
1235 XPSSink::XPSSink() {} | 1236 XPSSink::XPSSink() {} |
1236 | 1237 |
1237 Error XPSSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const
{ | 1238 Error XPSSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const
{ |
1238 sk_sp<SkDocument> doc(SkDocument::MakeXPS(dst)); | 1239 sk_sp<SkDocument> doc(SkDocument::MakeXPS(dst)); |
1239 if (!doc) { | 1240 if (!doc) { |
1240 return "SkDocument::MakeXPS() returned nullptr"; | 1241 return "SkDocument::MakeXPS() returned nullptr"; |
1241 } | 1242 } |
1242 return draw_skdocument(src, doc.get(), dst); | 1243 return draw_skdocument(src, doc.get(), dst); |
1243 } | 1244 } |
| 1245 |
| 1246 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
| 1247 |
| 1248 PipeSink::PipeSink() {} |
| 1249 |
| 1250 Error PipeSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const
{ |
| 1251 return src.draw(SkPipeSerializer().beginWrite(SkRect::Make(src.size()), dst)
); |
| 1252 } |
| 1253 |
1244 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 1254 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
1245 | 1255 |
1246 SKPSink::SKPSink() {} | 1256 SKPSink::SKPSink() {} |
1247 | 1257 |
1248 Error SKPSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const
{ | 1258 Error SKPSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const
{ |
1249 SkSize size; | 1259 SkSize size; |
1250 size = src.size(); | 1260 size = src.size(); |
1251 SkPictureRecorder recorder; | 1261 SkPictureRecorder recorder; |
1252 Error err = src.draw(recorder.beginRecording(size.width(), size.height())); | 1262 Error err = src.draw(recorder.beginRecording(size.width(), size.height())); |
1253 if (!err.isEmpty()) { | 1263 if (!err.isEmpty()) { |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1504 Error ViaDefer::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkStri
ng* log) const { | 1514 Error ViaDefer::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkStri
ng* log) const { |
1505 auto size = src.size(); | 1515 auto size = src.size(); |
1506 return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas
) -> Error { | 1516 return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas
) -> Error { |
1507 SkDeferredCanvas deferred(canvas); | 1517 SkDeferredCanvas deferred(canvas); |
1508 return src.draw(&deferred); | 1518 return src.draw(&deferred); |
1509 }); | 1519 }); |
1510 } | 1520 } |
1511 | 1521 |
1512 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 1522 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
1513 | 1523 |
| 1524 Error ViaPipe::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkStrin
g* log) const { |
| 1525 auto size = src.size(); |
| 1526 return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas
) -> Error { |
| 1527 SkDynamicMemoryWStream tmpStream; |
| 1528 Error err = src.draw(SkPipeSerializer().beginWrite(SkRect::Make(size), &
tmpStream)); |
| 1529 if (!err.isEmpty()) { |
| 1530 return err; |
| 1531 } |
| 1532 sk_sp<SkData> data = tmpStream.detachAsData(); |
| 1533 SkPipeDeserializer().playback(data->data(), data->size(), canvas); |
| 1534 return check_against_reference(bitmap, src, fSink); |
| 1535 }); |
| 1536 } |
| 1537 |
| 1538 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
| 1539 |
1514 // Draw the Src into two pictures, then draw the second picture into the wrapped
Sink. | 1540 // Draw the Src into two pictures, then draw the second picture into the wrapped
Sink. |
1515 // This tests that any shortcuts we may take while recording that second picture
are legal. | 1541 // This tests that any shortcuts we may take while recording that second picture
are legal. |
1516 Error ViaSecondPicture::draw( | 1542 Error ViaSecondPicture::draw( |
1517 const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) cons
t { | 1543 const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) cons
t { |
1518 auto size = src.size(); | 1544 auto size = src.size(); |
1519 return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas
) -> Error { | 1545 return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas
) -> Error { |
1520 SkPictureRecorder recorder; | 1546 SkPictureRecorder recorder; |
1521 sk_sp<SkPicture> pic; | 1547 sk_sp<SkPicture> pic; |
1522 for (int i = 0; i < 2; i++) { | 1548 for (int i = 0; i < 2; i++) { |
1523 Error err = src.draw(recorder.beginRecording(SkIntToScalar(size.widt
h()), | 1549 Error err = src.draw(recorder.beginRecording(SkIntToScalar(size.widt
h()), |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1635 Error err = src.draw(&rec); | 1661 Error err = src.draw(&rec); |
1636 if (!err.isEmpty()) { | 1662 if (!err.isEmpty()) { |
1637 return err; | 1663 return err; |
1638 } | 1664 } |
1639 dl->draw(canvas); | 1665 dl->draw(canvas); |
1640 return check_against_reference(bitmap, src, fSink); | 1666 return check_against_reference(bitmap, src, fSink); |
1641 }); | 1667 }); |
1642 } | 1668 } |
1643 | 1669 |
1644 } // namespace DM | 1670 } // namespace DM |
OLD | NEW |