| 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 "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 Loading... |
| 37 return NewFromStream(new SkMemoryStream(data)); | 37 return NewFromStream(new SkMemoryStream(data)); |
| 38 } | 38 } |
| 39 | 39 |
| 40 SkScaledCodec::SkScaledCodec(SkCodec* codec) | 40 SkScaledCodec::SkScaledCodec(SkCodec* codec) |
| 41 : INHERITED(codec->getInfo(), nullptr) | 41 : INHERITED(codec->getInfo(), nullptr) |
| 42 , fCodec(codec) | 42 , fCodec(codec) |
| 43 {} | 43 {} |
| 44 | 44 |
| 45 SkScaledCodec::~SkScaledCodec() {} | 45 SkScaledCodec::~SkScaledCodec() {} |
| 46 | 46 |
| 47 bool SkScaledCodec::onRewind() { |
| 48 return fCodec->onRewind(); |
| 49 } |
| 50 |
| 47 static SkISize best_scaled_dimensions(const SkISize& origDims, const SkISize& na
tiveDims, | 51 static SkISize best_scaled_dimensions(const SkISize& origDims, const SkISize& na
tiveDims, |
| 48 const SkISize& scaledCodecDims, float desi
redScale) { | 52 const SkISize& scaledCodecDims, float desi
redScale) { |
| 49 if (nativeDims == scaledCodecDims) { | 53 if (nativeDims == scaledCodecDims) { |
| 50 // does not matter which to return if equal. Return here to skip below c
alculations | 54 // does not matter which to return if equal. Return here to skip below c
alculations |
| 51 return nativeDims; | 55 return nativeDims; |
| 52 } | 56 } |
| 53 float idealWidth = origDims.width() * desiredScale; | 57 float idealWidth = origDims.width() * desiredScale; |
| 54 float idealHeight = origDims.height() * desiredScale; | 58 float idealHeight = origDims.height() * desiredScale; |
| 55 | 59 |
| 56 // calculate difference between native dimensions and ideal dimensions | 60 // calculate difference between native dimensions and ideal dimensions |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 storagePtr += sampleY * rowBytes; | 296 storagePtr += sampleY * rowBytes; |
| 293 dst = SkTAddOffset<void>(dst, rowBytes); | 297 dst = SkTAddOffset<void>(dst, rowBytes); |
| 294 } | 298 } |
| 295 return result; | 299 return result; |
| 296 } | 300 } |
| 297 default: | 301 default: |
| 298 SkASSERT(false); | 302 SkASSERT(false); |
| 299 return kUnimplemented; | 303 return kUnimplemented; |
| 300 } | 304 } |
| 301 } | 305 } |
| OLD | NEW |