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

Side by Side Diff: dm/DMSrcSink.cpp

Issue 1671193002: Make SkPicture/SkImageGenerator default to SkCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add references to bugs 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 | « no previous file | gyp/codec.gyp » ('j') | include/core/SkPicture.h » ('J')
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 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 790
796 static const SkRect kSKPViewport = {0,0, 1000,1000}; 791 static const SkRect kSKPViewport = {0,0, 1000,1000};
797 792
798 SKPSrc::SKPSrc(Path path) : fPath(path) {} 793 SKPSrc::SKPSrc(Path path) : fPath(path) {}
799 794
800 Error SKPSrc::draw(SkCanvas* canvas) const { 795 Error SKPSrc::draw(SkCanvas* canvas) const {
801 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(fPath.c_str())); 796 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(fPath.c_str()));
802 if (!stream) { 797 if (!stream) {
803 return SkStringPrintf("Couldn't read %s.", fPath.c_str()); 798 return SkStringPrintf("Couldn't read %s.", fPath.c_str());
804 } 799 }
805 SkAutoTUnref<SkPicture> pic(SkPicture::CreateFromStream(stream, &lazy_decode _bitmap)); 800 SkAutoTUnref<SkPicture> pic(SkPicture::CreateFromStream(stream));
806 if (!pic) { 801 if (!pic) {
807 return SkStringPrintf("Couldn't decode %s as a picture.", fPath.c_str()) ; 802 return SkStringPrintf("Couldn't decode %s as a picture.", fPath.c_str()) ;
808 } 803 }
809 stream.reset((SkStream*)nullptr); // Might as well drop this when we're don e with it. 804 stream.reset((SkStream*)nullptr); // Might as well drop this when we're don e with it.
810 805
811 canvas->clipRect(kSKPViewport); 806 canvas->clipRect(kSKPViewport);
812 canvas->drawPicture(pic); 807 canvas->drawPicture(pic);
813 return ""; 808 return "";
814 } 809 }
815 810
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 SkIntToScalar(size.height()))); 1163 SkIntToScalar(size.height())));
1169 if (!err.isEmpty()) { 1164 if (!err.isEmpty()) {
1170 return err; 1165 return err;
1171 } 1166 }
1172 SkAutoTUnref<SkPicture> pic(recorder.endRecording()); 1167 SkAutoTUnref<SkPicture> pic(recorder.endRecording());
1173 1168
1174 // Serialize it and then deserialize it. 1169 // Serialize it and then deserialize it.
1175 SkDynamicMemoryWStream wStream; 1170 SkDynamicMemoryWStream wStream;
1176 pic->serialize(&wStream); 1171 pic->serialize(&wStream);
1177 SkAutoTDelete<SkStream> rStream(wStream.detachAsStream()); 1172 SkAutoTDelete<SkStream> rStream(wStream.detachAsStream());
1178 SkAutoTUnref<SkPicture> deserialized(SkPicture::CreateFromStream(rStream, &l azy_decode_bitmap)); 1173 SkAutoTUnref<SkPicture> deserialized(SkPicture::CreateFromStream(rStream));
1179 1174
1180 return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas ) { 1175 return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas ) {
1181 canvas->drawPicture(deserialized); 1176 canvas->drawPicture(deserialized);
1182 return check_against_reference(bitmap, src, fSink); 1177 return check_against_reference(bitmap, src, fSink);
1183 }); 1178 });
1184 } 1179 }
1185 1180
1186 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 1181 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
1187 1182
1188 ViaTiles::ViaTiles(int w, int h, SkBBHFactory* factory, Sink* sink) 1183 ViaTiles::ViaTiles(int w, int h, SkBBHFactory* factory, Sink* sink)
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1408 skr.visit<void>(i, drawsAsSingletonPictures); 1403 skr.visit<void>(i, drawsAsSingletonPictures);
1409 } 1404 }
1410 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); 1405 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture());
1411 1406
1412 canvas->drawPicture(macroPic); 1407 canvas->drawPicture(macroPic);
1413 return check_against_reference(bitmap, src, fSink); 1408 return check_against_reference(bitmap, src, fSink);
1414 }); 1409 });
1415 } 1410 }
1416 1411
1417 } // namespace DM 1412 } // namespace DM
OLDNEW
« no previous file with comments | « no previous file | gyp/codec.gyp » ('j') | include/core/SkPicture.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698