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

Side by Side Diff: dm/DMSrcSink.cpp

Issue 986103002: DM: allow SKPs to be smaller than 1000x1000 (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 5 years, 9 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include "DMSrcSink.h" 1 #include "DMSrcSink.h"
2 #include "SamplePipeControllers.h" 2 #include "SamplePipeControllers.h"
3 #include "SkCommonFlags.h" 3 #include "SkCommonFlags.h"
4 #include "SkCodec.h" 4 #include "SkCodec.h"
5 #include "SkDocument.h" 5 #include "SkDocument.h"
6 #include "SkError.h" 6 #include "SkError.h"
7 #include "SkMultiPictureDraw.h" 7 #include "SkMultiPictureDraw.h"
8 #include "SkNullCanvas.h" 8 #include "SkNullCanvas.h"
9 #include "SkOSFile.h" 9 #include "SkOSFile.h"
10 #include "SkPictureData.h"
10 #include "SkPictureRecorder.h" 11 #include "SkPictureRecorder.h"
11 #include "SkRandom.h" 12 #include "SkRandom.h"
12 #include "SkSVGCanvas.h" 13 #include "SkSVGCanvas.h"
13 #include "SkStream.h" 14 #include "SkStream.h"
14 #include "SkXMLWriter.h" 15 #include "SkXMLWriter.h"
15 16
16 DEFINE_bool(codec, false, "Use SkCodec instead of SkImageDecoder"); 17 DEFINE_bool(codec, false, "Use SkCodec instead of SkImageDecoder");
17 18
18 namespace DM { 19 namespace DM {
19 20
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 if (!pic) { 171 if (!pic) {
171 return SkStringPrintf("Couldn't decode %s as a picture.", fPath.c_str()) ; 172 return SkStringPrintf("Couldn't decode %s as a picture.", fPath.c_str()) ;
172 } 173 }
173 stream.reset((SkStream*)NULL); // Might as well drop this when we're done w ith it. 174 stream.reset((SkStream*)NULL); // Might as well drop this when we're done w ith it.
174 canvas->clipRect(kSKPViewport); 175 canvas->clipRect(kSKPViewport);
175 canvas->drawPicture(pic); 176 canvas->drawPicture(pic);
176 return ""; 177 return "";
177 } 178 }
178 179
179 SkISize SKPSrc::size() const { 180 SkISize SKPSrc::size() const {
180 // This may be unnecessarily large. 181 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(fPath.c_str()));
181 return kSKPViewport.roundOut().size(); 182 if (!stream) {
183 return SkISize::Make(0,0);
184 }
185 SkPictInfo info;
186 if (!SkPicture::InternalOnly_StreamIsSKP(stream, &info)) {
187 return SkISize::Make(0,0);
188 }
189 SkRect viewport = kSKPViewport;
190 if (!viewport.intersect(info.fCullRect)) {
191 return SkISize::Make(0,0);
192 }
193 return viewport.roundOut().size();
182 } 194 }
183 195
184 Name SKPSrc::name() const { return SkOSPath::Basename(fPath.c_str()); } 196 Name SKPSrc::name() const { return SkOSPath::Basename(fPath.c_str()); }
185 197
186 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 198 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
187 199
188 Error NullSink::draw(const Src& src, SkBitmap*, SkWStream*, SkString*) const { 200 Error NullSink::draw(const Src& src, SkBitmap*, SkWStream*, SkString*) const {
189 SkAutoTDelete<SkCanvas> canvas(SkCreateNullCanvas()); 201 SkAutoTDelete<SkCanvas> canvas(SkCreateNullCanvas());
190 return src.draw(canvas); 202 return src.draw(canvas);
191 } 203 }
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 surfaces.unrefAll(); 545 surfaces.unrefAll();
534 return ""; 546 return "";
535 } 547 }
536 SkISize size() const SK_OVERRIDE { return fSize; } 548 SkISize size() const SK_OVERRIDE { return fSize; }
537 Name name() const SK_OVERRIDE { sk_throw(); return ""; } // No one shou ld be calling this. 549 Name name() const SK_OVERRIDE { sk_throw(); return ""; } // No one shou ld be calling this.
538 } proxy(fW, fH, pic, src.size()); 550 } proxy(fW, fH, pic, src.size());
539 return fSink->draw(proxy, bitmap, stream, log); 551 return fSink->draw(proxy, bitmap, stream, log);
540 } 552 }
541 553
542 } // namespace DM 554 } // namespace DM
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698