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

Side by Side Diff: src/codec/SkScaledCodec.cpp

Issue 1305123002: Scanline decoding for gifs (Closed) Base URL: https://skia.googlesource.com/skia.git@real-bmp-scan
Patch Set: Make kScanline_Mode test kOutOfOrder correctly in dm Created 5 years, 3 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
OLDNEW
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 "SkCodecPriv.h" 8 #include "SkCodecPriv.h"
9 #include "SkScaledCodec.h" 9 #include "SkScaledCodec.h"
10 #include "SkStream.h" 10 #include "SkStream.h"
(...skipping 26 matching lines...) Expand all
37 return NewFromStream(new SkMemoryStream(data)); 37 return NewFromStream(new SkMemoryStream(data));
38 } 38 }
39 39
40 SkScaledCodec::SkScaledCodec(SkScanlineDecoder* scanlineDecoder) 40 SkScaledCodec::SkScaledCodec(SkScanlineDecoder* scanlineDecoder)
41 : INHERITED(scanlineDecoder->getInfo(), nullptr) 41 : INHERITED(scanlineDecoder->getInfo(), nullptr)
42 , fScanlineDecoder(scanlineDecoder) 42 , fScanlineDecoder(scanlineDecoder)
43 {} 43 {}
44 44
45 SkScaledCodec::~SkScaledCodec() {} 45 SkScaledCodec::~SkScaledCodec() {}
46 46
47 // returns a scaled dimension based on the original dimension and the sampleSize
48 // NOTE: we round down here for scaled dimension to match the behavior of SkImag eDecoder
49 static int get_scaled_dimension(int srcDimension, int sampleSize) {
50 if (sampleSize > srcDimension) {
51 return 1;
52 }
53 return srcDimension / sampleSize;
54 }
55
56 static SkISize best_scaled_dimensions(const SkISize& origDims, const SkISize& na tiveDims, 47 static SkISize best_scaled_dimensions(const SkISize& origDims, const SkISize& na tiveDims,
57 const SkISize& scaledCodecDims, float desi redScale) { 48 const SkISize& scaledCodecDims, float desi redScale) {
58 if (nativeDims == scaledCodecDims) { 49 if (nativeDims == scaledCodecDims) {
59 // does not matter which to return if equal. Return here to skip below c alculations 50 // does not matter which to return if equal. Return here to skip below c alculations
60 return nativeDims; 51 return nativeDims;
61 } 52 }
62 float idealWidth = origDims.width() * desiredScale; 53 float idealWidth = origDims.width() * desiredScale;
63 float idealHeight = origDims.height() * desiredScale; 54 float idealHeight = origDims.height() * desiredScale;
64 55
65 // calculate difference between native dimensions and ideal dimensions 56 // calculate difference between native dimensions and ideal dimensions
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 SkPMColor ctable[], int* ctableCount) { 181 SkPMColor ctable[], int* ctableCount) {
191 182
192 if (options.fSubset) { 183 if (options.fSubset) {
193 // Subsets are not supported. 184 // Subsets are not supported.
194 return kUnimplemented; 185 return kUnimplemented;
195 } 186 }
196 187
197 Result result = fScanlineDecoder->start(requestedInfo, &options, ctable, cta bleCount); 188 Result result = fScanlineDecoder->start(requestedInfo, &options, ctable, cta bleCount);
198 if (kSuccess == result) { 189 if (kSuccess == result) {
199 // native decode supported 190 // native decode supported
200 return fScanlineDecoder->getScanlines(dst, requestedInfo.height(), rowBy tes); 191 switch (fScanlineDecoder->getScanlineOrder()) {
192 case SkScanlineDecoder::kTopDown_SkScanlineOrder:
193 case SkScanlineDecoder::kBottomUp_SkScanlineOrder:
194 case SkScanlineDecoder::kNone_SkScanlineOrder:
195 return fScanlineDecoder->getScanlines(dst, requestedInfo.height( ), rowBytes);
196 case SkScanlineDecoder::kOutOfOrder_SkScanlineOrder: {
197 for (int y = 0; y < requestedInfo.height(); y++) {
198 int dstY = fScanlineDecoder->getY();
199 void* dstPtr = SkTAddOffset<void>(dst, rowBytes * dstY);
200 result = fScanlineDecoder->getScanlines(dstPtr, 1, rowBytes) ;
201 if (kSuccess != result && kIncompleteInput != result) {
scroggo 2015/09/02 22:45:48 Again, I am concerned about accepting kIncomplete
msarett 2015/09/03 17:13:31 I would agree that we should return result at the
scroggo 2015/09/04 18:42:09 I'm happy with a FIXME. I think I understand what'
msarett 2015/09/04 19:52:47 I think we can improve on this... FIXME sounds go
202 return result;
203 }
204 }
205 return kSuccess;
206 }
207 }
201 } 208 }
202 209
203 if (kInvalidScale != result) { 210 if (kInvalidScale != result) {
204 // no scaling requested 211 // no scaling requested
205 return result; 212 return result;
206 } 213 }
207 214
208 // scaling requested 215 // scaling requested
209 int sampleX; 216 int sampleX;
210 int sampleY; 217 int sampleY;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 storagePtr += sampleY * rowBytes; 287 storagePtr += sampleY * rowBytes;
281 dst = SkTAddOffset<void>(dst, rowBytes); 288 dst = SkTAddOffset<void>(dst, rowBytes);
282 } 289 }
283 return kSuccess; 290 return kSuccess;
284 } 291 }
285 default: 292 default:
286 SkASSERT(false); 293 SkASSERT(false);
287 return kUnimplemented; 294 return kUnimplemented;
288 } 295 }
289 } 296 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698