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

Side by Side Diff: dm/DMSrcSink.cpp

Issue 1699183004: Make SkPicture/SkImageGenerator default to SkCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix rebase bug 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
48 namespace DM { 43 namespace DM {
49 44
50 GMSrc::GMSrc(skiagm::GMRegistry::Factory factory) : fFactory(factory) {} 45 GMSrc::GMSrc(skiagm::GMRegistry::Factory factory) : fFactory(factory) {}
51 46
52 Error GMSrc::draw(SkCanvas* canvas) const { 47 Error GMSrc::draw(SkCanvas* canvas) const {
53 SkAutoTDelete<skiagm::GM> gm(fFactory(nullptr)); 48 SkAutoTDelete<skiagm::GM> gm(fFactory(nullptr));
54 canvas->concat(gm->getInitialTransform()); 49 canvas->concat(gm->getInitialTransform());
55 gm->draw(canvas); 50 gm->draw(canvas);
56 return ""; 51 return "";
57 } 52 }
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 793
799 static const SkRect kSKPViewport = {0,0, 1000,1000}; 794 static const SkRect kSKPViewport = {0,0, 1000,1000};
800 795
801 SKPSrc::SKPSrc(Path path) : fPath(path) {} 796 SKPSrc::SKPSrc(Path path) : fPath(path) {}
802 797
803 Error SKPSrc::draw(SkCanvas* canvas) const { 798 Error SKPSrc::draw(SkCanvas* canvas) const {
804 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(fPath.c_str())); 799 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(fPath.c_str()));
805 if (!stream) { 800 if (!stream) {
806 return SkStringPrintf("Couldn't read %s.", fPath.c_str()); 801 return SkStringPrintf("Couldn't read %s.", fPath.c_str());
807 } 802 }
808 SkAutoTUnref<SkPicture> pic(SkPicture::CreateFromStream(stream, &lazy_decode _bitmap)); 803 SkAutoTUnref<SkPicture> pic(SkPicture::CreateFromStream(stream));
809 if (!pic) { 804 if (!pic) {
810 return SkStringPrintf("Couldn't decode %s as a picture.", fPath.c_str()) ; 805 return SkStringPrintf("Couldn't decode %s as a picture.", fPath.c_str()) ;
811 } 806 }
812 stream.reset((SkStream*)nullptr); // Might as well drop this when we're don e with it. 807 stream.reset((SkStream*)nullptr); // Might as well drop this when we're don e with it.
813 808
814 canvas->clipRect(kSKPViewport); 809 canvas->clipRect(kSKPViewport);
815 canvas->drawPicture(pic); 810 canvas->drawPicture(pic);
816 return ""; 811 return "";
817 } 812 }
818 813
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 SkIntToScalar(size.height()))); 1166 SkIntToScalar(size.height())));
1172 if (!err.isEmpty()) { 1167 if (!err.isEmpty()) {
1173 return err; 1168 return err;
1174 } 1169 }
1175 SkAutoTUnref<SkPicture> pic(recorder.endRecording()); 1170 SkAutoTUnref<SkPicture> pic(recorder.endRecording());
1176 1171
1177 // Serialize it and then deserialize it. 1172 // Serialize it and then deserialize it.
1178 SkDynamicMemoryWStream wStream; 1173 SkDynamicMemoryWStream wStream;
1179 pic->serialize(&wStream); 1174 pic->serialize(&wStream);
1180 SkAutoTDelete<SkStream> rStream(wStream.detachAsStream()); 1175 SkAutoTDelete<SkStream> rStream(wStream.detachAsStream());
1181 SkAutoTUnref<SkPicture> deserialized(SkPicture::CreateFromStream(rStream, &l azy_decode_bitmap)); 1176 SkAutoTUnref<SkPicture> deserialized(SkPicture::CreateFromStream(rStream));
1182 1177
1183 return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas ) { 1178 return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas ) {
1184 canvas->drawPicture(deserialized); 1179 canvas->drawPicture(deserialized);
1185 return check_against_reference(bitmap, src, fSink); 1180 return check_against_reference(bitmap, src, fSink);
1186 }); 1181 });
1187 } 1182 }
1188 1183
1189 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 1184 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
1190 1185
1191 ViaTiles::ViaTiles(int w, int h, SkBBHFactory* factory, Sink* sink) 1186 ViaTiles::ViaTiles(int w, int h, SkBBHFactory* factory, Sink* sink)
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1411 skr.visit<void>(i, drawsAsSingletonPictures); 1406 skr.visit<void>(i, drawsAsSingletonPictures);
1412 } 1407 }
1413 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); 1408 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture());
1414 1409
1415 canvas->drawPicture(macroPic); 1410 canvas->drawPicture(macroPic);
1416 return check_against_reference(bitmap, src, fSink); 1411 return check_against_reference(bitmap, src, fSink);
1417 }); 1412 });
1418 } 1413 }
1419 1414
1420 } // namespace DM 1415 } // 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