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 #ifndef SkCodec_DEFINED | 8 #ifndef SkCodec_DEFINED |
9 #define SkCodec_DEFINED | 9 #define SkCodec_DEFINED |
10 | 10 |
11 #include "SkImageGenerator.h" | 11 #include "SkImageGenerator.h" |
12 #include "SkImageInfo.h" | 12 #include "SkImageInfo.h" |
13 #include "SkSize.h" | 13 #include "SkSize.h" |
| 14 #include "SkStream.h" |
14 #include "SkTemplates.h" | 15 #include "SkTemplates.h" |
15 #include "SkTypes.h" | 16 #include "SkTypes.h" |
16 | 17 |
17 class SkData; | 18 class SkData; |
18 class SkStream; | |
19 | 19 |
20 /** | 20 /** |
21 * Abstraction layer directly on top of an image codec. | 21 * Abstraction layer directly on top of an image codec. |
22 */ | 22 */ |
23 class SkCodec : public SkImageGenerator { | 23 class SkCodec : public SkImageGenerator { |
24 public: | 24 public: |
25 /** | 25 /** |
26 * If this stream represents an encoded image that we know how to decode, | 26 * If this stream represents an encoded image that we know how to decode, |
27 * return an SkCodec that can decode it. Otherwise return NULL. | 27 * return an SkCodec that can decode it. Otherwise return NULL. |
28 * | 28 * |
(...skipping 10 matching lines...) Expand all Loading... |
39 */ | 39 */ |
40 static SkCodec* NewFromData(SkData*); | 40 static SkCodec* NewFromData(SkData*); |
41 | 41 |
42 /** | 42 /** |
43 * Return a size that approximately supports the desired scale factor. | 43 * Return a size that approximately supports the desired scale factor. |
44 * The codec may not be able to scale efficiently to the exact scale | 44 * The codec may not be able to scale efficiently to the exact scale |
45 * factor requested, so return a size that approximates that scale. | 45 * factor requested, so return a size that approximates that scale. |
46 * | 46 * |
47 * FIXME: Move to SkImageGenerator? | 47 * FIXME: Move to SkImageGenerator? |
48 */ | 48 */ |
49 SkISize getScaledDimensions(float desiredScale) const; | 49 SkISize getScaledDimensions(float desiredScale) const { |
| 50 return this->onGetScaledDimensions(desiredScale); |
| 51 } |
50 | 52 |
51 protected: | 53 protected: |
52 SkCodec(const SkImageInfo&, SkStream*); | 54 SkCodec(const SkImageInfo&, SkStream*); |
53 | 55 |
54 /** | 56 /** |
55 * The SkAlphaType is a conservative answer. i.e. it is possible that it | 57 * The SkAlphaType is a conservative answer. i.e. it is possible that it |
56 * initially returns a non-opaque answer, but completing the decode | 58 * initially returns a non-opaque answer, but completing the decode |
57 * reveals that the image is actually opaque. | 59 * reveals that the image is actually opaque. |
58 */ | 60 */ |
59 bool onGetInfo(SkImageInfo* info) SK_OVERRIDE { | 61 bool onGetInfo(SkImageInfo* info) SK_OVERRIDE { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 SkStream* stream() { | 94 SkStream* stream() { |
93 return fStream.get(); | 95 return fStream.get(); |
94 } | 96 } |
95 | 97 |
96 private: | 98 private: |
97 const SkImageInfo fInfo; | 99 const SkImageInfo fInfo; |
98 SkAutoTDelete<SkStream> fStream; | 100 SkAutoTDelete<SkStream> fStream; |
99 bool fNeedsRewind; | 101 bool fNeedsRewind; |
100 }; | 102 }; |
101 #endif // SkCodec_DEFINED | 103 #endif // SkCodec_DEFINED |
OLD | NEW |