| OLD | NEW |
| 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 "SamplePipeControllers.h" | 9 #include "SamplePipeControllers.h" |
| 10 #include "SkAndroidCodec.h" | 10 #include "SkAndroidCodec.h" |
| 11 #include "SkCodec.h" | 11 #include "SkCodec.h" |
| 12 #include "SkCommonFlags.h" | 12 #include "SkCommonFlags.h" |
| 13 #include "SkData.h" | 13 #include "SkData.h" |
| 14 #include "SkDocument.h" | 14 #include "SkDocument.h" |
| 15 #include "SkError.h" | 15 #include "SkError.h" |
| 16 #include "SkImageGenerator.h" | 16 #include "SkImageGenerator.h" |
| 17 #include "SkMallocPixelRef.h" |
| 17 #include "SkMultiPictureDraw.h" | 18 #include "SkMultiPictureDraw.h" |
| 18 #include "SkNullCanvas.h" | 19 #include "SkNullCanvas.h" |
| 19 #include "SkOSFile.h" | 20 #include "SkOSFile.h" |
| 20 #include "SkPictureData.h" | 21 #include "SkPictureData.h" |
| 21 #include "SkPictureRecorder.h" | 22 #include "SkPictureRecorder.h" |
| 22 #include "SkRandom.h" | 23 #include "SkRandom.h" |
| 23 #include "SkRecordDraw.h" | 24 #include "SkRecordDraw.h" |
| 24 #include "SkRecorder.h" | 25 #include "SkRecorder.h" |
| 25 #include "SkRemote.h" | 26 #include "SkRemote.h" |
| 26 #include "SkSVGCanvas.h" | 27 #include "SkSVGCanvas.h" |
| (...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 966 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 967 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
| 967 | 968 |
| 968 RasterSink::RasterSink(SkColorType colorType) : fColorType(colorType) {} | 969 RasterSink::RasterSink(SkColorType colorType) : fColorType(colorType) {} |
| 969 | 970 |
| 970 Error RasterSink::draw(const Src& src, SkBitmap* dst, SkWStream*, SkString*) con
st { | 971 Error RasterSink::draw(const Src& src, SkBitmap* dst, SkWStream*, SkString*) con
st { |
| 971 const SkISize size = src.size(); | 972 const SkISize size = src.size(); |
| 972 // If there's an appropriate alpha type for this color type, use it, otherwi
se use premul. | 973 // If there's an appropriate alpha type for this color type, use it, otherwi
se use premul. |
| 973 SkAlphaType alphaType = kPremul_SkAlphaType; | 974 SkAlphaType alphaType = kPremul_SkAlphaType; |
| 974 (void)SkColorTypeValidateAlphaType(fColorType, alphaType, &alphaType); | 975 (void)SkColorTypeValidateAlphaType(fColorType, alphaType, &alphaType); |
| 975 | 976 |
| 976 dst->allocPixels(SkImageInfo::Make(size.width(), size.height(), fColorType,
alphaType)); | 977 SkMallocPixelRef::ZeroedPRFactory factory; |
| 977 dst->eraseColor(SK_ColorTRANSPARENT); | 978 dst->allocPixels(SkImageInfo::Make(size.width(), size.height(), fColorType,
alphaType), |
| 979 &factory, |
| 980 nullptr/*colortable*/); |
| 978 SkCanvas canvas(*dst); | 981 SkCanvas canvas(*dst); |
| 979 return src.draw(&canvas); | 982 return src.draw(&canvas); |
| 980 } | 983 } |
| 981 | 984 |
| 982 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 985 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
| 983 | 986 |
| 984 // Handy for front-patching a Src. Do whatever up-front work you need, then cal
l draw_to_canvas(), | 987 // Handy for front-patching a Src. Do whatever up-front work you need, then cal
l draw_to_canvas(), |
| 985 // passing the Sink draw() arguments, a size, and a function draws into an SkCan
vas. | 988 // passing the Sink draw() arguments, a size, and a function draws into an SkCan
vas. |
| 986 // Several examples below. | 989 // Several examples below. |
| 987 | 990 |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1261 skr.visit<void>(i, drawsAsSingletonPictures); | 1264 skr.visit<void>(i, drawsAsSingletonPictures); |
| 1262 } | 1265 } |
| 1263 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); | 1266 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); |
| 1264 | 1267 |
| 1265 canvas->drawPicture(macroPic); | 1268 canvas->drawPicture(macroPic); |
| 1266 return ""; | 1269 return ""; |
| 1267 }); | 1270 }); |
| 1268 } | 1271 } |
| 1269 | 1272 |
| 1270 } // namespace DM | 1273 } // namespace DM |
| OLD | NEW |