Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(424)

Side by Side Diff: include/codec/SkCodec.h

Issue 1018953003: Add SkEncodedFormat, used by SkCodec. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Use a common enum for SkImageEncoder and SkImageDecoder and SkCodec Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "SkEncodedFormat.h"
11 #include "SkImageGenerator.h" 12 #include "SkImageGenerator.h"
12 #include "SkImageInfo.h" 13 #include "SkImageInfo.h"
13 #include "SkSize.h" 14 #include "SkSize.h"
14 #include "SkStream.h" 15 #include "SkStream.h"
15 #include "SkTemplates.h" 16 #include "SkTemplates.h"
16 #include "SkTypes.h" 17 #include "SkTypes.h"
17 18
18 class SkData; 19 class SkData;
19 20
20 /** 21 /**
(...skipping 22 matching lines...) Expand all
43 * Return a size that approximately supports the desired scale factor. 44 * Return a size that approximately supports the desired scale factor.
44 * The codec may not be able to scale efficiently to the exact scale 45 * The codec may not be able to scale efficiently to the exact scale
45 * factor requested, so return a size that approximates that scale. 46 * factor requested, so return a size that approximates that scale.
46 * 47 *
47 * FIXME: Move to SkImageGenerator? 48 * FIXME: Move to SkImageGenerator?
48 */ 49 */
49 SkISize getScaledDimensions(float desiredScale) const { 50 SkISize getScaledDimensions(float desiredScale) const {
50 return this->onGetScaledDimensions(desiredScale); 51 return this->onGetScaledDimensions(desiredScale);
51 } 52 }
52 53
54 /**
55 * Format of the encoded data.
56 */
57 SkEncodedFormat getEncodedFormat() const { return this->onGetEncodedFormat() ; }
58
53 protected: 59 protected:
54 SkCodec(const SkImageInfo&, SkStream*); 60 SkCodec(const SkImageInfo&, SkStream*);
55 61
56 /** 62 /**
57 * The SkAlphaType is a conservative answer. i.e. it is possible that it 63 * The SkAlphaType is a conservative answer. i.e. it is possible that it
58 * initially returns a non-opaque answer, but completing the decode 64 * initially returns a non-opaque answer, but completing the decode
59 * reveals that the image is actually opaque. 65 * reveals that the image is actually opaque.
60 */ 66 */
61 bool onGetInfo(SkImageInfo* info) SK_OVERRIDE { 67 bool onGetInfo(SkImageInfo* info) SK_OVERRIDE {
62 *info = fInfo; 68 *info = fInfo;
63 return true; 69 return true;
64 } 70 }
65 71
66 // Helper for subclasses. 72 // Helper for subclasses.
67 const SkImageInfo& getOriginalInfo() { return fInfo; } 73 const SkImageInfo& getOriginalInfo() { return fInfo; }
68 74
69 virtual SkISize onGetScaledDimensions(float /* desiredScale */) const { 75 virtual SkISize onGetScaledDimensions(float /* desiredScale */) const {
70 // By default, scaling is not supported. 76 // By default, scaling is not supported.
71 return fInfo.dimensions(); 77 return fInfo.dimensions();
72 } 78 }
73 79
80 virtual SkEncodedFormat onGetEncodedFormat() const = 0;
81
74 /** 82 /**
75 * If the stream was previously read, attempt to rewind. 83 * If the stream was previously read, attempt to rewind.
76 * @returns: 84 * @returns:
77 * true 85 * true
78 * - if the stream needed to be rewound, and the rewind 86 * - if the stream needed to be rewound, and the rewind
79 * succeeded. 87 * succeeded.
80 * - if the stream did not need to be rewound. 88 * - if the stream did not need to be rewound.
81 * false 89 * false
82 * - if the stream needed to be rewound, and rewind failed. 90 * - if the stream needed to be rewound, and rewind failed.
83 * Subclasses MUST call this function before reading the stream (e.g. in 91 * Subclasses MUST call this function before reading the stream (e.g. in
(...skipping 10 matching lines...) Expand all
94 SkStream* stream() { 102 SkStream* stream() {
95 return fStream.get(); 103 return fStream.get();
96 } 104 }
97 105
98 private: 106 private:
99 const SkImageInfo fInfo; 107 const SkImageInfo fInfo;
100 SkAutoTDelete<SkStream> fStream; 108 SkAutoTDelete<SkStream> fStream;
101 bool fNeedsRewind; 109 bool fNeedsRewind;
102 }; 110 };
103 #endif // SkCodec_DEFINED 111 #endif // SkCodec_DEFINED
OLDNEW
« no previous file with comments | « gyp/images.gyp ('k') | include/core/SkEncodedFormat.h » ('j') | include/core/SkEncodedFormat.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698