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 #ifndef SkScaledCodec_DEFINED | 7 #ifndef SkScaledCodec_DEFINED |
8 #define SkScaledCodec_DEFINED | 8 #define SkScaledCodec_DEFINED |
9 | 9 |
10 #include "SkCodec.h" | 10 #include "SkCodec.h" |
11 | 11 |
12 class SkStream; | 12 class SkStream; |
13 | 13 |
14 /** | 14 /** |
15 * This class implements scaling, by sampling scanlines in the y direction. | 15 * This class implements scaling, by sampling scanlines in the y direction. |
16 * x-wise sampling is implemented in the swizzler, when getScanlines() is called
. | 16 * x-wise sampling is implemented in the swizzler, when getScanlines() is called
. |
17 */ | 17 */ |
18 class SkScaledCodec : public SkCodec { | 18 class SkScaledCodec : public SkCodec { |
19 public: | 19 public: |
20 static SkCodec* NewFromStream(SkStream*); | 20 static SkCodec* NewFromStream(SkStream*); |
21 static SkCodec* NewFromData(SkData*); | 21 static SkCodec* NewFromData(SkData*); |
22 | 22 |
23 virtual ~SkScaledCodec(); | 23 virtual ~SkScaledCodec(); |
24 | 24 |
25 static void ComputeSampleSize(const SkISize& dstDim, const SkISize& srcDim, | 25 static void ComputeSampleSize(const SkISize& dstSize, const SkISize& srcSize
, |
26 int* sampleSizeX, int* sampleSizeY); | 26 int* sampleSizeX, int* sampleSizeY); |
27 | 27 |
28 protected: | 28 protected: |
29 bool onRewind() override; | 29 bool onRewind() override; |
30 | 30 |
31 /** | 31 /** |
32 * Recommend a set of destination dimensions given a requested scale | 32 * Recommend a set of destination dimensions given a requested scale |
33 */ | 33 */ |
34 SkISize onGetScaledDimensions(float desiredScale) const override; | 34 SkISize onGetScaledDimensions(float desiredScale) const override; |
35 bool onDimensionsSupported(const SkISize&) override; | 35 bool onDimensionsSupported(const SkISize&) override; |
36 | 36 |
| 37 bool onGetScaledSubsetDimensions(float desiredScale, Options* options) const
override; |
| 38 |
37 Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, SkPMCo
lor*, int*, int*) | 39 Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, SkPMCo
lor*, int*, int*) |
38 override; | 40 override; |
39 SkEncodedFormat onGetEncodedFormat() const override { | 41 SkEncodedFormat onGetEncodedFormat() const override { |
40 return fCodec->getEncodedFormat(); | 42 return fCodec->getEncodedFormat(); |
41 } | 43 } |
42 | 44 |
43 bool onReallyHasAlpha() const override { | 45 bool onReallyHasAlpha() const override { |
44 return fCodec->reallyHasAlpha(); | 46 return fCodec->reallyHasAlpha(); |
45 } | 47 } |
46 | 48 |
47 uint32_t onGetFillValue(SkColorType colorType, SkAlphaType alphaType) const
override; | 49 uint32_t onGetFillValue(SkColorType colorType, SkAlphaType alphaType) const
override; |
48 | 50 |
49 SkScanlineOrder onGetScanlineOrder() const override; | 51 SkScanlineOrder onGetScanlineOrder() const override; |
50 | 52 |
51 private: | 53 private: |
52 | 54 |
| 55 Result nativeDecode(const SkImageInfo& scaledInfo, void* dst, size_t rowByte
s, |
| 56 const SkIRect& scaledSubsetRect, ZeroInitialized zeroInit, int* rows
Decoded); |
| 57 |
| 58 Result sampledDecode(const SkImageInfo& decodeInfo, void* dst, size_t rowByt
es, |
| 59 const SkIRect& subsetRect, const SkIRect& scaledSubsetRect, int samp
leX, int sampleY, |
| 60 ZeroInitialized zeroInit, int* rowsDecoded); |
| 61 |
53 SkAutoTDelete<SkCodec> fCodec; | 62 SkAutoTDelete<SkCodec> fCodec; |
54 | 63 |
55 explicit SkScaledCodec(SkCodec*); | 64 explicit SkScaledCodec(SkCodec*); |
56 | 65 |
57 typedef SkCodec INHERITED; | 66 typedef SkCodec INHERITED; |
58 }; | 67 }; |
59 #endif // SkScaledCodec_DEFINED | 68 #endif // SkScaledCodec_DEFINED |
OLD | NEW |