OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "DecodeFile.h" |
8 #include "SampleCode.h" | 9 #include "SampleCode.h" |
9 #include "SkDumpCanvas.h" | 10 #include "SkDumpCanvas.h" |
10 #include "SkView.h" | 11 #include "SkView.h" |
11 #include "SkCanvas.h" | 12 #include "SkCanvas.h" |
12 #include "SkGradientShader.h" | 13 #include "SkGradientShader.h" |
13 #include "SkGraphics.h" | 14 #include "SkGraphics.h" |
14 #include "SkImageDecoder.h" | |
15 #include "SkOSFile.h" | 15 #include "SkOSFile.h" |
16 #include "SkPath.h" | 16 #include "SkPath.h" |
17 #include "SkPicture.h" | 17 #include "SkPicture.h" |
18 #include "SkPictureRecorder.h" | 18 #include "SkPictureRecorder.h" |
19 #include "SkRandom.h" | 19 #include "SkRandom.h" |
20 #include "SkRegion.h" | 20 #include "SkRegion.h" |
21 #include "SkShader.h" | 21 #include "SkShader.h" |
22 #include "SkUtils.h" | 22 #include "SkUtils.h" |
23 #include "SkColorPriv.h" | 23 #include "SkColorPriv.h" |
24 #include "SkColorFilter.h" | 24 #include "SkColorFilter.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 SkString fFilename; | 146 SkString fFilename; |
147 SkPicture* fPictures[kBBoxTypeCount]; | 147 SkPicture* fPictures[kBBoxTypeCount]; |
148 BBoxType fBBox; | 148 BBoxType fBBox; |
149 SkSize fTileSize; | 149 SkSize fTileSize; |
150 int fCount; | 150 int fCount; |
151 | 151 |
152 sk_sp<SkPicture> LoadPicture(const char path[], BBoxType bbox) { | 152 sk_sp<SkPicture> LoadPicture(const char path[], BBoxType bbox) { |
153 sk_sp<SkPicture> pic; | 153 sk_sp<SkPicture> pic; |
154 | 154 |
155 SkBitmap bm; | 155 SkBitmap bm; |
156 if (SkImageDecoder::DecodeFile(path, &bm)) { | 156 if (decode_file(path, &bm)) { |
157 bm.setImmutable(); | 157 bm.setImmutable(); |
158 SkPictureRecorder recorder; | 158 SkPictureRecorder recorder; |
159 SkCanvas* can = recorder.beginRecording(SkIntToScalar(bm.width()), | 159 SkCanvas* can = recorder.beginRecording(SkIntToScalar(bm.width()), |
160 SkIntToScalar(bm.height()), | 160 SkIntToScalar(bm.height()), |
161 nullptr, 0); | 161 nullptr, 0); |
162 can->drawBitmap(bm, 0, 0, nullptr); | 162 can->drawBitmap(bm, 0, 0, nullptr); |
163 pic = recorder.finishRecordingAsPicture(); | 163 pic = recorder.finishRecordingAsPicture(); |
164 } else { | 164 } else { |
165 SkFILEStream stream(path); | 165 SkFILEStream stream(path); |
166 if (stream.isValid()) { | 166 if (stream.isValid()) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 SampleView* CreateSamplePictFileView(const char filename[]) { | 213 SampleView* CreateSamplePictFileView(const char filename[]) { |
214 return new PictFileView(filename); | 214 return new PictFileView(filename); |
215 } | 215 } |
216 | 216 |
217 ////////////////////////////////////////////////////////////////////////////// | 217 ////////////////////////////////////////////////////////////////////////////// |
218 | 218 |
219 #if 0 | 219 #if 0 |
220 static SkView* MyFactory() { return new PictFileView; } | 220 static SkView* MyFactory() { return new PictFileView; } |
221 static SkViewRegister reg(MyFactory); | 221 static SkViewRegister reg(MyFactory); |
222 #endif | 222 #endif |
OLD | NEW |