OLD | NEW |
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 "SkPictureData.h" | 7 #include "SkPictureData.h" |
8 #include "SkPictureRecorder.h" | 8 #include "SkPictureRecorder.h" |
9 #include "SkRandom.h" | 9 #include "SkRandom.h" |
10 #include "SkStream.h" | 10 #include "SkStream.h" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 return err; | 190 return err; |
191 } | 191 } |
192 canvas->flush(); | 192 canvas->flush(); |
193 doc->endPage(); | 193 doc->endPage(); |
194 doc->close(); | 194 doc->close(); |
195 return ""; | 195 return ""; |
196 } | 196 } |
197 | 197 |
198 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 198 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
199 | 199 |
| 200 SKPSink::SKPSink() {} |
| 201 |
| 202 Error SKPSink::draw(const Src& src, SkBitmap*, SkWStream* dst) const { |
| 203 SkSize size; |
| 204 size = src.size(); |
| 205 SkPictureRecorder recorder; |
| 206 Error err = src.draw(recorder.beginRecording(size.width(), size.height())); |
| 207 if (!err.isEmpty()) { |
| 208 return err; |
| 209 } |
| 210 SkAutoTUnref<SkPicture> pic(recorder.endRecording()); |
| 211 pic->serialize(dst); |
| 212 return ""; |
| 213 } |
| 214 |
| 215 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
| 216 |
200 RasterSink::RasterSink(SkColorType colorType) : fColorType(colorType) {} | 217 RasterSink::RasterSink(SkColorType colorType) : fColorType(colorType) {} |
201 | 218 |
202 Error RasterSink::draw(const Src& src, SkBitmap* dst, SkWStream*) const { | 219 Error RasterSink::draw(const Src& src, SkBitmap* dst, SkWStream*) const { |
203 const SkISize size = limit_raster_dimensions(src.size()); | 220 const SkISize size = limit_raster_dimensions(src.size()); |
204 // If there's an appropriate alpha type for this color type, use it, otherwi
se use premul. | 221 // If there's an appropriate alpha type for this color type, use it, otherwi
se use premul. |
205 SkAlphaType alphaType = kPremul_SkAlphaType; | 222 SkAlphaType alphaType = kPremul_SkAlphaType; |
206 (void)SkColorTypeValidateAlphaType(fColorType, alphaType, &alphaType); | 223 (void)SkColorTypeValidateAlphaType(fColorType, alphaType, &alphaType); |
207 | 224 |
208 dst->allocPixels(SkImageInfo::Make(size.width(), size.height(), fColorType,
alphaType)); | 225 dst->allocPixels(SkImageInfo::Make(size.width(), size.height(), fColorType,
alphaType)); |
209 dst->eraseColor(SK_ColorTRANSPARENT); | 226 dst->eraseColor(SK_ColorTRANSPARENT); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 surfaces.unrefAll(); | 369 surfaces.unrefAll(); |
353 return ""; | 370 return ""; |
354 } | 371 } |
355 SkISize size() const SK_OVERRIDE { return fSize; } | 372 SkISize size() const SK_OVERRIDE { return fSize; } |
356 Name name() const SK_OVERRIDE { sk_throw(); return ""; } // No one shou
ld be calling this. | 373 Name name() const SK_OVERRIDE { sk_throw(); return ""; } // No one shou
ld be calling this. |
357 } proxy(fW, fH, pic, src.size()); | 374 } proxy(fW, fH, pic, src.size()); |
358 return fSink->draw(proxy, bitmap, stream); | 375 return fSink->draw(proxy, bitmap, stream); |
359 } | 376 } |
360 | 377 |
361 } // namespace DM | 378 } // namespace DM |
OLD | NEW |