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

Side by Side Diff: dm/DMSrcSink.cpp

Issue 1685963004: Revert of Make SkPicture/SkImageGenerator default to SkCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « bench/ETCBitmapBench.cpp ('k') | gyp/codec.gyp » ('j') | 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 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 "SkAndroidCodec.h" 9 #include "SkAndroidCodec.h"
10 #include "SkCodec.h" 10 #include "SkCodec.h"
(...skipping 22 matching lines...) Expand all
33 #include <functional> 33 #include <functional>
34 34
35 #ifdef SK_MOJO 35 #ifdef SK_MOJO
36 #include "SkMojo.mojom.h" 36 #include "SkMojo.mojom.h"
37 #endif 37 #endif
38 38
39 DEFINE_bool(multiPage, false, "For document-type backends, render the source" 39 DEFINE_bool(multiPage, false, "For document-type backends, render the source"
40 " into multiple pages"); 40 " into multiple pages");
41 DEFINE_bool(RAW_threading, true, "Allow RAW decodes to run on multiple threads?" ); 41 DEFINE_bool(RAW_threading, true, "Allow RAW decodes to run on multiple threads?" );
42 42
43 static bool lazy_decode_bitmap(const void* src, size_t size, SkBitmap* dst) {
44 SkAutoTUnref<SkData> encoded(SkData::NewWithCopy(src, size));
45 return encoded && SkDEPRECATED_InstallDiscardablePixelRef(encoded, dst);
46 }
47
43 namespace DM { 48 namespace DM {
44 49
45 GMSrc::GMSrc(skiagm::GMRegistry::Factory factory) : fFactory(factory) {} 50 GMSrc::GMSrc(skiagm::GMRegistry::Factory factory) : fFactory(factory) {}
46 51
47 Error GMSrc::draw(SkCanvas* canvas) const { 52 Error GMSrc::draw(SkCanvas* canvas) const {
48 SkAutoTDelete<skiagm::GM> gm(fFactory(nullptr)); 53 SkAutoTDelete<skiagm::GM> gm(fFactory(nullptr));
49 canvas->concat(gm->getInitialTransform()); 54 canvas->concat(gm->getInitialTransform());
50 gm->draw(canvas); 55 gm->draw(canvas);
51 return ""; 56 return "";
52 } 57 }
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 795
791 static const SkRect kSKPViewport = {0,0, 1000,1000}; 796 static const SkRect kSKPViewport = {0,0, 1000,1000};
792 797
793 SKPSrc::SKPSrc(Path path) : fPath(path) {} 798 SKPSrc::SKPSrc(Path path) : fPath(path) {}
794 799
795 Error SKPSrc::draw(SkCanvas* canvas) const { 800 Error SKPSrc::draw(SkCanvas* canvas) const {
796 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(fPath.c_str())); 801 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(fPath.c_str()));
797 if (!stream) { 802 if (!stream) {
798 return SkStringPrintf("Couldn't read %s.", fPath.c_str()); 803 return SkStringPrintf("Couldn't read %s.", fPath.c_str());
799 } 804 }
800 SkAutoTUnref<SkPicture> pic(SkPicture::CreateFromStream(stream)); 805 SkAutoTUnref<SkPicture> pic(SkPicture::CreateFromStream(stream, &lazy_decode _bitmap));
801 if (!pic) { 806 if (!pic) {
802 return SkStringPrintf("Couldn't decode %s as a picture.", fPath.c_str()) ; 807 return SkStringPrintf("Couldn't decode %s as a picture.", fPath.c_str()) ;
803 } 808 }
804 stream.reset((SkStream*)nullptr); // Might as well drop this when we're don e with it. 809 stream.reset((SkStream*)nullptr); // Might as well drop this when we're don e with it.
805 810
806 canvas->clipRect(kSKPViewport); 811 canvas->clipRect(kSKPViewport);
807 canvas->drawPicture(pic); 812 canvas->drawPicture(pic);
808 return ""; 813 return "";
809 } 814 }
810 815
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 SkIntToScalar(size.height()))); 1168 SkIntToScalar(size.height())));
1164 if (!err.isEmpty()) { 1169 if (!err.isEmpty()) {
1165 return err; 1170 return err;
1166 } 1171 }
1167 SkAutoTUnref<SkPicture> pic(recorder.endRecording()); 1172 SkAutoTUnref<SkPicture> pic(recorder.endRecording());
1168 1173
1169 // Serialize it and then deserialize it. 1174 // Serialize it and then deserialize it.
1170 SkDynamicMemoryWStream wStream; 1175 SkDynamicMemoryWStream wStream;
1171 pic->serialize(&wStream); 1176 pic->serialize(&wStream);
1172 SkAutoTDelete<SkStream> rStream(wStream.detachAsStream()); 1177 SkAutoTDelete<SkStream> rStream(wStream.detachAsStream());
1173 SkAutoTUnref<SkPicture> deserialized(SkPicture::CreateFromStream(rStream)); 1178 SkAutoTUnref<SkPicture> deserialized(SkPicture::CreateFromStream(rStream, &l azy_decode_bitmap));
1174 1179
1175 return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas ) { 1180 return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas ) {
1176 canvas->drawPicture(deserialized); 1181 canvas->drawPicture(deserialized);
1177 return check_against_reference(bitmap, src, fSink); 1182 return check_against_reference(bitmap, src, fSink);
1178 }); 1183 });
1179 } 1184 }
1180 1185
1181 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 1186 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
1182 1187
1183 ViaTiles::ViaTiles(int w, int h, SkBBHFactory* factory, Sink* sink) 1188 ViaTiles::ViaTiles(int w, int h, SkBBHFactory* factory, Sink* sink)
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1403 skr.visit<void>(i, drawsAsSingletonPictures); 1408 skr.visit<void>(i, drawsAsSingletonPictures);
1404 } 1409 }
1405 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); 1410 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture());
1406 1411
1407 canvas->drawPicture(macroPic); 1412 canvas->drawPicture(macroPic);
1408 return check_against_reference(bitmap, src, fSink); 1413 return check_against_reference(bitmap, src, fSink);
1409 }); 1414 });
1410 } 1415 }
1411 1416
1412 } // namespace DM 1417 } // namespace DM
OLDNEW
« no previous file with comments | « bench/ETCBitmapBench.cpp ('k') | gyp/codec.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698