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

Side by Side Diff: include/core/SkImageEncoder.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 2011 Google Inc. 2 * Copyright 2011 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 SkImageEncoder_DEFINED 8 #ifndef SkImageEncoder_DEFINED
9 #define SkImageEncoder_DEFINED 9 #define SkImageEncoder_DEFINED
10 10
11 #include "SkEncodedFormat.h"
11 #include "SkImageInfo.h" 12 #include "SkImageInfo.h"
12 #include "SkTRegistry.h" 13 #include "SkTRegistry.h"
13 14
14 class SkBitmap; 15 class SkBitmap;
15 class SkData; 16 class SkData;
16 class SkWStream; 17 class SkWStream;
17 18
18 class SkImageEncoder { 19 class SkImageEncoder {
19 public: 20 public:
20 enum Type { 21 static SkImageEncoder* Create(SkEncodedFormat);
scroggo 2015/03/19 20:00:21 Now that we've changed this (and SkImageDecoder),
21 kUnknown_Type,
22 kBMP_Type,
23 kGIF_Type,
24 kICO_Type,
25 kJPEG_Type,
26 kPNG_Type,
27 kWBMP_Type,
28 kWEBP_Type,
29 kKTX_Type,
scroggo 2015/03/19 20:00:21 There's a slight difference between this and the n
30 };
31 static SkImageEncoder* Create(Type);
32 22
33 virtual ~SkImageEncoder(); 23 virtual ~SkImageEncoder();
34 24
35 /* Quality ranges from 0..100 */ 25 /* Quality ranges from 0..100 */
36 enum { 26 enum {
37 kDefaultQuality = 80 27 kDefaultQuality = 80
38 }; 28 };
39 29
40 /** 30 /**
41 * Encode bitmap 'bm', returning the results in an SkData, at quality level 31 * Encode bitmap 'bm', returning the results in an SkData, at quality level
(...skipping 11 matching lines...) Expand all
53 bool encodeFile(const char file[], const SkBitmap& bm, int quality); 43 bool encodeFile(const char file[], const SkBitmap& bm, int quality);
54 44
55 /** 45 /**
56 * Encode bitmap 'bm' in the desired format, writing results to 46 * Encode bitmap 'bm' in the desired format, writing results to
57 * stream 'stream', at quality level 'quality' (which can be in 47 * stream 'stream', at quality level 'quality' (which can be in
58 * range 0-100). Returns false on failure. 48 * range 0-100). Returns false on failure.
59 */ 49 */
60 bool encodeStream(SkWStream* stream, const SkBitmap& bm, int quality); 50 bool encodeStream(SkWStream* stream, const SkBitmap& bm, int quality);
61 51
62 static SkData* EncodeData(const SkImageInfo&, const void* pixels, size_t row Bytes, 52 static SkData* EncodeData(const SkImageInfo&, const void* pixels, size_t row Bytes,
63 Type, int quality); 53 SkEncodedFormat, int quality);
64 static SkData* EncodeData(const SkBitmap&, Type, int quality); 54 static SkData* EncodeData(const SkBitmap&, SkEncodedFormat, int quality);
65 55
66 static bool EncodeFile(const char file[], const SkBitmap&, Type, 56 static bool EncodeFile(const char file[], const SkBitmap&, SkEncodedFormat,
67 int quality); 57 int quality);
68 static bool EncodeStream(SkWStream*, const SkBitmap&, Type, 58 static bool EncodeStream(SkWStream*, const SkBitmap&, SkEncodedFormat,
69 int quality); 59 int quality);
70 60
71 protected: 61 protected:
72 /** 62 /**
73 * Encode bitmap 'bm' in the desired format, writing results to 63 * Encode bitmap 'bm' in the desired format, writing results to
74 * stream 'stream', at quality level 'quality' (which can be in 64 * stream 'stream', at quality level 'quality' (which can be in
75 * range 0-100). 65 * range 0-100).
76 * 66 *
77 * This must be overridden by each SkImageEncoder implementation. 67 * This must be overridden by each SkImageEncoder implementation.
78 */ 68 */
(...skipping 23 matching lines...) Expand all
102 DECLARE_ENCODER_CREATOR(PNGImageEncoder); 92 DECLARE_ENCODER_CREATOR(PNGImageEncoder);
103 DECLARE_ENCODER_CREATOR(KTXImageEncoder); 93 DECLARE_ENCODER_CREATOR(KTXImageEncoder);
104 DECLARE_ENCODER_CREATOR(WEBPImageEncoder); 94 DECLARE_ENCODER_CREATOR(WEBPImageEncoder);
105 95
106 #ifdef SK_BUILD_FOR_IOS 96 #ifdef SK_BUILD_FOR_IOS
107 DECLARE_ENCODER_CREATOR(PNGImageEncoder_IOS); 97 DECLARE_ENCODER_CREATOR(PNGImageEncoder_IOS);
108 #endif 98 #endif
109 99
110 // Typedef to make registering encoder callback easier 100 // Typedef to make registering encoder callback easier
111 // This has to be defined outside SkImageEncoder. :( 101 // This has to be defined outside SkImageEncoder. :(
112 typedef SkTRegistry<SkImageEncoder*(*)(SkImageEncoder::Type)> SkImageEncoder_Enc odeReg; 102 typedef SkTRegistry<SkImageEncoder*(*)(SkEncodedFormat)> SkImageEncoder_EncodeRe g;
113 #endif 103 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698