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& dstDim, const SkISize& srcDim, |
26 int* sampleSizeX, int* sampleSizeY); | 26 int* sampleSizeX, int* sampleSizeY); |
27 | 27 |
28 protected: | 28 protected: |
| 29 bool onRewind() override; |
| 30 |
29 /** | 31 /** |
30 * Recommend a set of destination dimensions given a requested scale | 32 * Recommend a set of destination dimensions given a requested scale |
31 */ | 33 */ |
32 SkISize onGetScaledDimensions(float desiredScale) const override; | 34 SkISize onGetScaledDimensions(float desiredScale) const override; |
33 bool onDimensionsSupported(const SkISize&) override; | 35 bool onDimensionsSupported(const SkISize&) override; |
34 | 36 |
35 Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, SkPMCo
lor*, int*) | 37 Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, SkPMCo
lor*, int*) |
36 override; | 38 override; |
37 SkEncodedFormat onGetEncodedFormat() const override { | 39 SkEncodedFormat onGetEncodedFormat() const override { |
38 return fCodec->getEncodedFormat(); | 40 return fCodec->getEncodedFormat(); |
39 } | 41 } |
40 | 42 |
41 bool onReallyHasAlpha() const override { | 43 bool onReallyHasAlpha() const override { |
42 return fCodec->reallyHasAlpha(); | 44 return fCodec->reallyHasAlpha(); |
43 } | 45 } |
44 | 46 |
45 private: | 47 private: |
46 | 48 |
47 SkAutoTDelete<SkCodec> fCodec; | 49 SkAutoTDelete<SkCodec> fCodec; |
48 | 50 |
49 explicit SkScaledCodec(SkCodec*); | 51 explicit SkScaledCodec(SkCodec*); |
50 | 52 |
51 typedef SkCodec INHERITED; | 53 typedef SkCodec INHERITED; |
52 }; | 54 }; |
53 #endif // SkScaledCodec_DEFINED | 55 #endif // SkScaledCodec_DEFINED |
OLD | NEW |