| 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 "SamplePipeControllers.h" |     9 #include "SamplePipeControllers.h" | 
|    10 #include "SkAndroidCodec.h" |    10 #include "SkAndroidCodec.h" | 
|    11 #include "SkBitmapRegionDecoderPriv.h" |    11 #include "SkBitmapRegionDecoderPriv.h" | 
|    12 #include "SkCodec.h" |    12 #include "SkCodec.h" | 
|    13 #include "SkCommonFlags.h" |    13 #include "SkCommonFlags.h" | 
|    14 #include "SkData.h" |    14 #include "SkData.h" | 
|    15 #include "SkDocument.h" |    15 #include "SkDocument.h" | 
|    16 #include "SkError.h" |    16 #include "SkError.h" | 
|    17 #include "SkFunction.h" |  | 
|    18 #include "SkImageGenerator.h" |    17 #include "SkImageGenerator.h" | 
|    19 #include "SkMultiPictureDraw.h" |    18 #include "SkMultiPictureDraw.h" | 
|    20 #include "SkNullCanvas.h" |    19 #include "SkNullCanvas.h" | 
|    21 #include "SkOSFile.h" |    20 #include "SkOSFile.h" | 
|    22 #include "SkPictureData.h" |    21 #include "SkPictureData.h" | 
|    23 #include "SkPictureRecorder.h" |    22 #include "SkPictureRecorder.h" | 
|    24 #include "SkRandom.h" |    23 #include "SkRandom.h" | 
|    25 #include "SkRecordDraw.h" |    24 #include "SkRecordDraw.h" | 
|    26 #include "SkRecorder.h" |    25 #include "SkRecorder.h" | 
|    27 #include "SkRemote.h" |    26 #include "SkRemote.h" | 
|    28 #include "SkSVGCanvas.h" |    27 #include "SkSVGCanvas.h" | 
|    29 #include "SkStream.h" |    28 #include "SkStream.h" | 
|    30 #include "SkTLogic.h" |    29 #include "SkTLogic.h" | 
|    31 #include "SkXMLWriter.h" |    30 #include "SkXMLWriter.h" | 
|    32 #include "SkSwizzler.h" |    31 #include "SkSwizzler.h" | 
 |    32 #include <functional> | 
|    33  |    33  | 
|    34 DEFINE_bool(multiPage, false, "For document-type backends, render the source" |    34 DEFINE_bool(multiPage, false, "For document-type backends, render the source" | 
|    35             " into multiple pages"); |    35             " into multiple pages"); | 
|    36  |    36  | 
|    37 static bool lazy_decode_bitmap(const void* src, size_t size, SkBitmap* dst) { |    37 static bool lazy_decode_bitmap(const void* src, size_t size, SkBitmap* dst) { | 
|    38     SkAutoTUnref<SkData> encoded(SkData::NewWithCopy(src, size)); |    38     SkAutoTUnref<SkData> encoded(SkData::NewWithCopy(src, size)); | 
|    39     return encoded && SkDEPRECATED_InstallDiscardablePixelRef(encoded, dst); |    39     return encoded && SkDEPRECATED_InstallDiscardablePixelRef(encoded, dst); | 
|    40 } |    40 } | 
|    41  |    41  | 
|    42 namespace DM { |    42 namespace DM { | 
| (...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1051     return src.draw(&canvas); |  1051     return src.draw(&canvas); | 
|  1052 } |  1052 } | 
|  1053  |  1053  | 
|  1054 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      ~~~~~~~~~~~~~~~~*/ |  1054 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      ~~~~~~~~~~~~~~~~*/ | 
|  1055  |  1055  | 
|  1056 // Handy for front-patching a Src.  Do whatever up-front work you need, then cal
      l draw_to_canvas(), |  1056 // Handy for front-patching a Src.  Do whatever up-front work you need, then cal
      l draw_to_canvas(), | 
|  1057 // passing the Sink draw() arguments, a size, and a function draws into an SkCan
      vas. |  1057 // passing the Sink draw() arguments, a size, and a function draws into an SkCan
      vas. | 
|  1058 // Several examples below. |  1058 // Several examples below. | 
|  1059  |  1059  | 
|  1060 static Error draw_to_canvas(Sink* sink, SkBitmap* bitmap, SkWStream* stream, SkS
      tring* log, |  1060 static Error draw_to_canvas(Sink* sink, SkBitmap* bitmap, SkWStream* stream, SkS
      tring* log, | 
|  1061                             SkISize size, SkFunction<Error(SkCanvas*)> draw) { |  1061                             SkISize size, std::function<Error(SkCanvas*)> draw) 
      { | 
|  1062     class ProxySrc : public Src { |  1062     class ProxySrc : public Src { | 
|  1063     public: |  1063     public: | 
|  1064         ProxySrc(SkISize size, SkFunction<Error(SkCanvas*)> draw) : fSize(size),
       fDraw(draw) {} |  1064         ProxySrc(SkISize size, std::function<Error(SkCanvas*)> draw) : fSize(siz
      e), fDraw(draw) {} | 
|  1065         Error   draw(SkCanvas* canvas) const override { return fDraw(canvas); } |  1065         Error   draw(SkCanvas* canvas) const override { return fDraw(canvas); } | 
|  1066         Name                    name() const override { sk_throw(); return ""; }
       // Won't be called. |  1066         Name                    name() const override { sk_throw(); return ""; }
       // Won't be called. | 
|  1067         SkISize                 size() const override { return fSize; } |  1067         SkISize                 size() const override { return fSize; } | 
|  1068     private: |  1068     private: | 
|  1069         SkISize                      fSize; |  1069         SkISize                         fSize; | 
|  1070         SkFunction<Error(SkCanvas*)> fDraw; |  1070         std::function<Error(SkCanvas*)> fDraw; | 
|  1071     }; |  1071     }; | 
|  1072     return sink->draw(ProxySrc(size, draw), bitmap, stream, log); |  1072     return sink->draw(ProxySrc(size, draw), bitmap, stream, log); | 
|  1073 } |  1073 } | 
|  1074  |  1074  | 
|  1075 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      ~~~~~~~~~~~~~~~~*/ |  1075 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      ~~~~~~~~~~~~~~~~*/ | 
|  1076  |  1076  | 
|  1077 static SkISize auto_compute_translate(SkMatrix* matrix, int srcW, int srcH) { |  1077 static SkISize auto_compute_translate(SkMatrix* matrix, int srcW, int srcH) { | 
|  1078     SkRect bounds = SkRect::MakeIWH(srcW, srcH); |  1078     SkRect bounds = SkRect::MakeIWH(srcW, srcH); | 
|  1079     matrix->mapRect(&bounds); |  1079     matrix->mapRect(&bounds); | 
|  1080     matrix->postTranslate(-bounds.x(), -bounds.y()); |  1080     matrix->postTranslate(-bounds.x(), -bounds.y()); | 
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1333             skr.visit<void>(i, drawsAsSingletonPictures); |  1333             skr.visit<void>(i, drawsAsSingletonPictures); | 
|  1334         } |  1334         } | 
|  1335         SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); |  1335         SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); | 
|  1336  |  1336  | 
|  1337         canvas->drawPicture(macroPic); |  1337         canvas->drawPicture(macroPic); | 
|  1338         return ""; |  1338         return ""; | 
|  1339     }); |  1339     }); | 
|  1340 } |  1340 } | 
|  1341  |  1341  | 
|  1342 }  // namespace DM |  1342 }  // namespace DM | 
| OLD | NEW |