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

Side by Side Diff: dm/DMSrcSink.cpp

Issue 891823002: DM: paths as implict strings too. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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 | « dm/DMSrcSink.h ('k') | 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 "SkDocument.h" 4 #include "SkDocument.h"
5 #include "SkMultiPictureDraw.h" 5 #include "SkMultiPictureDraw.h"
6 #include "SkOSFile.h" 6 #include "SkOSFile.h"
7 #include "SkPictureRecorder.h" 7 #include "SkPictureRecorder.h"
8 #include "SkRandom.h" 8 #include "SkRandom.h"
9 #include "SkStream.h" 9 #include "SkStream.h"
10 10
(...skipping 13 matching lines...) Expand all
24 return gm->getISize(); 24 return gm->getISize();
25 } 25 }
26 26
27 Name GMSrc::name() const { 27 Name GMSrc::name() const {
28 SkAutoTDelete<skiagm::GM> gm(fFactory(NULL)); 28 SkAutoTDelete<skiagm::GM> gm(fFactory(NULL));
29 return gm->getName(); 29 return gm->getName();
30 } 30 }
31 31
32 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 32 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
33 33
34 ImageSrc::ImageSrc(SkString path, int subsets) : fPath(path), fSubsets(subsets) {} 34 ImageSrc::ImageSrc(Path path, int subsets) : fPath(path), fSubsets(subsets) {}
35 35
36 Error ImageSrc::draw(SkCanvas* canvas) const { 36 Error ImageSrc::draw(SkCanvas* canvas) const {
37 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str())); 37 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str()));
38 if (!encoded) { 38 if (!encoded) {
39 return SkStringPrintf("Couldn't read %s.", fPath.c_str()); 39 return SkStringPrintf("Couldn't read %s.", fPath.c_str());
40 } 40 }
41 if (fSubsets == 0) { 41 if (fSubsets == 0) {
42 // Decode the full image. 42 // Decode the full image.
43 SkBitmap bitmap; 43 SkBitmap bitmap;
44 if (!SkImageDecoder::DecodeMemory(encoded->data(), encoded->size(), &bit map)) { 44 if (!SkImageDecoder::DecodeMemory(encoded->data(), encoded->size(), &bit map)) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 if (fSubsets > 0) { 96 if (fSubsets > 0) {
97 name.appendf("-%d-subsets", fSubsets); 97 name.appendf("-%d-subsets", fSubsets);
98 } 98 }
99 return name; 99 return name;
100 } 100 }
101 101
102 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 102 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
103 103
104 static const SkRect kSKPViewport = {0,0, 1000,1000}; 104 static const SkRect kSKPViewport = {0,0, 1000,1000};
105 105
106 SKPSrc::SKPSrc(SkString path) : fPath(path) {} 106 SKPSrc::SKPSrc(Path path) : fPath(path) {}
107 107
108 Error SKPSrc::draw(SkCanvas* canvas) const { 108 Error SKPSrc::draw(SkCanvas* canvas) const {
109 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(fPath.c_str())); 109 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(fPath.c_str()));
110 if (!stream) { 110 if (!stream) {
111 return SkStringPrintf("Couldn't read %s.", fPath.c_str()); 111 return SkStringPrintf("Couldn't read %s.", fPath.c_str());
112 } 112 }
113 SkAutoTUnref<SkPicture> pic(SkPicture::CreateFromStream(stream)); 113 SkAutoTUnref<SkPicture> pic(SkPicture::CreateFromStream(stream));
114 if (!pic) { 114 if (!pic) {
115 return SkStringPrintf("Couldn't decode %s as a picture.", fPath.c_str()) ; 115 return SkStringPrintf("Couldn't decode %s as a picture.", fPath.c_str()) ;
116 } 116 }
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 surfaces.unrefAll(); 381 surfaces.unrefAll();
382 return ""; 382 return "";
383 } 383 }
384 SkISize size() const SK_OVERRIDE { return fSize; } 384 SkISize size() const SK_OVERRIDE { return fSize; }
385 Name name() const SK_OVERRIDE { sk_throw(); return ""; } // No one shou ld be calling this. 385 Name name() const SK_OVERRIDE { sk_throw(); return ""; } // No one shou ld be calling this.
386 } proxy(fW, fH, pic, src.size()); 386 } proxy(fW, fH, pic, src.size());
387 return fSink->draw(proxy, bitmap, stream); 387 return fSink->draw(proxy, bitmap, stream);
388 } 388 }
389 389
390 } // namespace DM 390 } // namespace DM
OLDNEW
« no previous file with comments | « dm/DMSrcSink.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698