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 "SkCodec.h" | 10 #include "SkCodec.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 } | 127 } |
128 decodeInfo = decodeInfo.makeWH(size.width(), size.height()); | 128 decodeInfo = decodeInfo.makeWH(size.width(), size.height()); |
129 | 129 |
130 // Construct a color table for the decode if necessary | 130 // Construct a color table for the decode if necessary |
131 SkAutoTUnref<SkColorTable> colorTable(NULL); | 131 SkAutoTUnref<SkColorTable> colorTable(NULL); |
132 SkPMColor* colorPtr = NULL; | 132 SkPMColor* colorPtr = NULL; |
133 int* colorCountPtr = NULL; | 133 int* colorCountPtr = NULL; |
134 int maxColors = 256; | 134 int maxColors = 256; |
135 if (kIndex_8_SkColorType == decodeInfo.colorType()) { | 135 if (kIndex_8_SkColorType == decodeInfo.colorType()) { |
136 SkPMColor colors[256]; | 136 SkPMColor colors[256]; |
137 colorTable.reset(SkNEW_ARGS(SkColorTable, (colors, maxColors))); | 137 colorTable.reset(new SkColorTable(colors, maxColors)); |
138 colorPtr = const_cast<SkPMColor*>(colorTable->readColors()); | 138 colorPtr = const_cast<SkPMColor*>(colorTable->readColors()); |
139 colorCountPtr = &maxColors; | 139 colorCountPtr = &maxColors; |
140 } | 140 } |
141 | 141 |
142 // FIXME: Currently we cannot draw unpremultiplied sources. | 142 // FIXME: Currently we cannot draw unpremultiplied sources. |
143 if (decodeInfo.alphaType() == kUnpremul_SkAlphaType) { | 143 if (decodeInfo.alphaType() == kUnpremul_SkAlphaType) { |
144 decodeInfo = decodeInfo.makeAlphaType(kPremul_SkAlphaType); | 144 decodeInfo = decodeInfo.makeAlphaType(kPremul_SkAlphaType); |
145 } | 145 } |
146 | 146 |
147 SkBitmap bitmap; | 147 SkBitmap bitmap; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 * subsets. | 213 * subsets. |
214 */ | 214 */ |
215 SkImageInfo largestSubsetDecodeInfo = | 215 SkImageInfo largestSubsetDecodeInfo = |
216 decodeInfo.makeWH(subsetWidth + extraX, subsetHeight + extra
Y); | 216 decodeInfo.makeWH(subsetWidth + extraX, subsetHeight + extra
Y); |
217 SkBitmap largestSubsetBm; | 217 SkBitmap largestSubsetBm; |
218 if (!largestSubsetBm.tryAllocPixels(largestSubsetDecodeInfo, NULL, c
olorTable.get())) { | 218 if (!largestSubsetBm.tryAllocPixels(largestSubsetDecodeInfo, NULL, c
olorTable.get())) { |
219 return SkStringPrintf("Image(%s) is too large (%d x %d)\n", fPat
h.c_str(), | 219 return SkStringPrintf("Image(%s) is too large (%d x %d)\n", fPat
h.c_str(), |
220 largestSubsetDecodeInfo.width(), largestSubsetDecodeInfo
.height()); | 220 largestSubsetDecodeInfo.width(), largestSubsetDecodeInfo
.height()); |
221 } | 221 } |
222 const size_t rowBytes = decodeInfo.minRowBytes(); | 222 const size_t rowBytes = decodeInfo.minRowBytes(); |
223 char* buffer = SkNEW_ARRAY(char, largestSubsetDecodeInfo.height() *
rowBytes); | 223 char* buffer = new char[largestSubsetDecodeInfo.height() * rowBytes]
; |
224 SkAutoTDeleteArray<char> lineDeleter(buffer); | 224 SkAutoTDeleteArray<char> lineDeleter(buffer); |
225 for (int col = 0; col < divisor; col++) { | 225 for (int col = 0; col < divisor; col++) { |
226 //currentSubsetWidth may be larger than subsetWidth for rightmos
t subsets | 226 //currentSubsetWidth may be larger than subsetWidth for rightmos
t subsets |
227 const int currentSubsetWidth = (col + 1 == divisor) ? | 227 const int currentSubsetWidth = (col + 1 == divisor) ? |
228 subsetWidth + extraX : subsetWidth; | 228 subsetWidth + extraX : subsetWidth; |
229 const int x = col * subsetWidth; | 229 const int x = col * subsetWidth; |
230 for (int row = 0; row < divisor; row++) { | 230 for (int row = 0; row < divisor; row++) { |
231 //currentSubsetHeight may be larger than subsetHeight for bo
ttom subsets | 231 //currentSubsetHeight may be larger than subsetHeight for bo
ttom subsets |
232 const int currentSubsetHeight = (row + 1 == divisor) ? | 232 const int currentSubsetHeight = (row + 1 == divisor) ? |
233 subsetHeight + extraY : subsetHeight; | 233 subsetHeight + extraY : subsetHeight; |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 SkAutoTUnref<SkPicture> pic(recorder.endRecording()); | 760 SkAutoTUnref<SkPicture> pic(recorder.endRecording()); |
761 pic->serialize(dst); | 761 pic->serialize(dst); |
762 return ""; | 762 return ""; |
763 } | 763 } |
764 | 764 |
765 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 765 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
766 | 766 |
767 SVGSink::SVGSink() {} | 767 SVGSink::SVGSink() {} |
768 | 768 |
769 Error SVGSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const
{ | 769 Error SVGSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const
{ |
770 SkAutoTDelete<SkXMLWriter> xmlWriter(SkNEW_ARGS(SkXMLStreamWriter, (dst))); | 770 SkAutoTDelete<SkXMLWriter> xmlWriter(new SkXMLStreamWriter(dst)); |
771 SkAutoTUnref<SkCanvas> canvas(SkSVGCanvas::Create( | 771 SkAutoTUnref<SkCanvas> canvas(SkSVGCanvas::Create( |
772 SkRect::MakeWH(SkIntToScalar(src.size().width()), SkIntToScalar(src.size
().height())), | 772 SkRect::MakeWH(SkIntToScalar(src.size().width()), SkIntToScalar(src.size
().height())), |
773 xmlWriter)); | 773 xmlWriter)); |
774 return src.draw(canvas); | 774 return src.draw(canvas); |
775 } | 775 } |
776 | 776 |
777 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 777 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
778 | 778 |
779 RasterSink::RasterSink(SkColorType colorType) : fColorType(colorType) {} | 779 RasterSink::RasterSink(SkColorType colorType) : fColorType(colorType) {} |
780 | 780 |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1064 skr.visit<void>(i, drawsAsSingletonPictures); | 1064 skr.visit<void>(i, drawsAsSingletonPictures); |
1065 } | 1065 } |
1066 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); | 1066 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); |
1067 | 1067 |
1068 canvas->drawPicture(macroPic); | 1068 canvas->drawPicture(macroPic); |
1069 return ""; | 1069 return ""; |
1070 }); | 1070 }); |
1071 } | 1071 } |
1072 | 1072 |
1073 } // namespace DM | 1073 } // namespace DM |
OLD | NEW |