OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2015 Google Inc. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license that can be | |
5 * found in the LICENSE file. | |
6 */ | |
7 #ifndef SkScaledCodec_DEFINED | |
8 #define SkScaledCodec_DEFINED | |
9 | |
10 #include "SkCodec.h" | |
11 | |
12 class SkStream; | |
13 | |
14 /** | |
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
. | |
17 */ | |
18 class SkScaledCodec : public SkCodec { | |
19 public: | |
20 static SkCodec* NewFromStream(SkStream*); | |
21 static SkCodec* NewFromData(SkData*); | |
22 | |
23 virtual ~SkScaledCodec(); | |
24 | |
25 static void ComputeSampleSize(const SkISize& dstDim, const SkISize& srcDim, | |
26 int* sampleSizeX, int* sampleSizeY); | |
27 | |
28 protected: | |
29 bool onRewind() override; | |
30 | |
31 /** | |
32 * Recommend a set of destination dimensions given a requested scale | |
33 */ | |
34 SkISize onGetScaledDimensions(float desiredScale) const override; | |
35 bool onDimensionsSupported(const SkISize&) override; | |
36 | |
37 Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, SkPMCo
lor*, int*, int*) | |
38 override; | |
39 SkEncodedFormat onGetEncodedFormat() const override { | |
40 return fCodec->getEncodedFormat(); | |
41 } | |
42 | |
43 bool onReallyHasAlpha() const override { | |
44 return fCodec->reallyHasAlpha(); | |
45 } | |
46 | |
47 uint32_t onGetFillValue(SkColorType colorType, SkAlphaType alphaType) const
override; | |
48 | |
49 SkScanlineOrder onGetScanlineOrder() const override; | |
50 | |
51 private: | |
52 | |
53 SkAutoTDelete<SkCodec> fCodec; | |
54 | |
55 explicit SkScaledCodec(SkCodec*); | |
56 | |
57 typedef SkCodec INHERITED; | |
58 }; | |
59 #endif // SkScaledCodec_DEFINED | |
OLD | NEW |