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

Side by Side Diff: include/core/SkImage.h

Issue 54363008: move SkImage::ColorType into SkColorType (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « gm/srcmode.cpp ('k') | include/core/SkImageDecoder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 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 SkImage_DEFINED 8 #ifndef SkImage_DEFINED
9 #define SkImage_DEFINED 9 #define SkImage_DEFINED
10 10
11 #include "SkAlpha.h" 11 #include "SkAlpha.h"
12 #include "SkImageEncoder.h" 12 #include "SkImageEncoder.h"
13 #include "SkRefCnt.h" 13 #include "SkRefCnt.h"
14 #include "SkScalar.h" 14 #include "SkScalar.h"
15 15
16 class SkData; 16 class SkData;
17 class SkCanvas; 17 class SkCanvas;
18 class SkPaint; 18 class SkPaint;
19 class SkShader; 19 class SkShader;
20 class GrContext; 20 class GrContext;
21 class GrTexture; 21 class GrTexture;
22 22
23 // need for TileMode 23 // need for TileMode
24 #include "SkShader.h" 24 #include "SkShader.h"
25 25
26 enum SkColorType {
27 kAlpha_8_SkColorType,
28 kRGB_565_SkColorType,
29 kRGBA_8888_SkColorType,
30 kBGRA_8888_SkColorType,
31
32 #if SK_PMCOLOR_BYTE_ORDER(B,G,R,A)
33 kPMColor_SkColorType = kBGRA_8888_SkColorType,
34 #elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A)
35 kPMColor_SkColorType = kRGBA_8888_SkColorType,
36 #else
37 #error "SK_*32_SHFIT values must correspond to BGRA or RGBA byte order"
38 #endif
39
40 kLastEnum_SkColorType = kBGRA_8888_SkColorType
41 };
42
43 struct SkImageInfo {
44 int fWidth;
45 int fHeight;
46 SkColorType fColorType;
47 SkAlphaType fAlphaType;
48 };
49
26 /** 50 /**
27 * SkImage is an abstraction for drawing a rectagle of pixels, though the 51 * SkImage is an abstraction for drawing a rectagle of pixels, though the
28 * particular type of image could be actually storing its data on the GPU, or 52 * particular type of image could be actually storing its data on the GPU, or
29 * as drawing commands (picture or PDF or otherwise), ready to be played back 53 * as drawing commands (picture or PDF or otherwise), ready to be played back
30 * into another canvas. 54 * into another canvas.
31 * 55 *
32 * The content of SkImage is always immutable, though the actual storage may 56 * The content of SkImage is always immutable, though the actual storage may
33 * change, if for example that image can be re-created via encoded data or 57 * change, if for example that image can be re-created via encoded data or
34 * other means. 58 * other means.
35 */ 59 */
36 class SK_API SkImage : public SkRefCnt { 60 class SK_API SkImage : public SkRefCnt {
37 public: 61 public:
38 SK_DECLARE_INST_COUNT(SkImage) 62 SK_DECLARE_INST_COUNT(SkImage)
39 63
40 enum ColorType { 64 #ifdef SK_SUPPORT_LEGACY_COLORTYPE
41 kAlpha_8_ColorType, 65 typedef SkColorType ColorType;
42 kRGB_565_ColorType,
43 kRGBA_8888_ColorType,
44 kBGRA_8888_ColorType,
45 66
46 #if SK_PMCOLOR_BYTE_ORDER(B,G,R,A) 67 static const SkColorType kAlpha_8_ColorType = kAlpha_8_SkColorType;
47 kPMColor_ColorType = kBGRA_8888_ColorType, 68 static const SkColorType kRGB_565_ColorType = kRGB_565_SkColorType;
48 #elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A) 69 static const SkColorType kRGBA_8888_ColorType = kRGBA_8888_SkColorType;
49 kPMColor_ColorType = kRGBA_8888_ColorType, 70 static const SkColorType kBGRA_8888_ColorType = kBGRA_8888_SkColorType;
50 #else 71 static const SkColorType kPMColor_ColorType = kPMColor_SkColorType;
51 #error "SK_*32_SHFIT values must correspond to BGRA or RGBA byte order" 72 static const SkColorType kLastEnum_ColorType = kLastEnum_SkColorType;
52 #endif 73 #endif
53 74
54 kLastEnum_ColorType = kBGRA_8888_ColorType 75 #ifdef SK_SUPPORT_LEGACY_ALPHATYPE
55 };
56
57 typedef SkAlphaType AlphaType; 76 typedef SkAlphaType AlphaType;
58 77
59 static const SkAlphaType kIgnore_AlphaType = kIgnore_SkAlphaType; 78 static const SkAlphaType kIgnore_AlphaType = kIgnore_SkAlphaType;
60 static const SkAlphaType kOpaque_AlphaType = kOpaque_SkAlphaType; 79 static const SkAlphaType kOpaque_AlphaType = kOpaque_SkAlphaType;
61 static const SkAlphaType kPremul_AlphaType = kPremul_SkAlphaType; 80 static const SkAlphaType kPremul_AlphaType = kPremul_SkAlphaType;
62 static const SkAlphaType kUnpremul_AlphaType = kUnpremul_SkAlphaType; 81 static const SkAlphaType kUnpremul_AlphaType = kUnpremul_SkAlphaType;
82 #endif
63 83
64 struct Info { 84 typedef SkImageInfo Info;
65 int fWidth;
66 int fHeight;
67 ColorType fColorType;
68 SkAlphaType fAlphaType;
69 };
70 85
71 static SkImage* NewRasterCopy(const Info&, const void* pixels, size_t rowByt es); 86 static SkImage* NewRasterCopy(const Info&, const void* pixels, size_t rowByt es);
72 static SkImage* NewRasterData(const Info&, SkData* pixels, size_t rowBytes); 87 static SkImage* NewRasterData(const Info&, SkData* pixels, size_t rowBytes);
73 static SkImage* NewEncodedData(SkData*); 88 static SkImage* NewEncodedData(SkData*);
74 89
75 /** 90 /**
76 * GrTexture is a more logical parameter for this factory, but its 91 * GrTexture is a more logical parameter for this factory, but its
77 * interactions with scratch cache still has issues, so for now we take 92 * interactions with scratch cache still has issues, so for now we take
78 * SkBitmap instead. This will be changed in the future. skbug.com/1449 93 * SkBitmap instead. This will be changed in the future. skbug.com/1449
79 */ 94 */
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 const int fWidth; 143 const int fWidth;
129 const int fHeight; 144 const int fHeight;
130 const uint32_t fUniqueID; 145 const uint32_t fUniqueID;
131 146
132 static uint32_t NextUniqueID(); 147 static uint32_t NextUniqueID();
133 148
134 typedef SkRefCnt INHERITED; 149 typedef SkRefCnt INHERITED;
135 }; 150 };
136 151
137 #endif 152 #endif
OLDNEW
« no previous file with comments | « gm/srcmode.cpp ('k') | include/core/SkImageDecoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698