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

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

Issue 108723003: Revert "Revert "PixelRef now returns (nearly) everything that is currently in SkBitmap. The goal is… (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: fix warnings, update SkImageRef_ashmem Created 7 years 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 | « include/core/SkBitmapDevice.h ('k') | include/core/SkMallocPixelRef.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 2013 Google Inc. 2 * Copyright 2013 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 SkImageInfo_DEFINED 8 #ifndef SkImageInfo_DEFINED
9 #define SkImageInfo_DEFINED 9 #define SkImageInfo_DEFINED
10 10
11 #include "SkTypes.h" 11 #include "SkTypes.h"
12 12
13 class SkFlattenableWriteBuffer;
14 class SkFlattenableReadBuffer;
15
13 /** 16 /**
14 * Describes how to interpret the alpha compoent of a pixel. 17 * Describes how to interpret the alpha compoent of a pixel.
15 */ 18 */
16 enum SkAlphaType { 19 enum SkAlphaType {
17 /** 20 /**
18 * All pixels should be treated as opaque, regardless of the value stored 21 * All pixels should be treated as opaque, regardless of the value stored
19 * in their alpha field. Used for legacy images that wrote 0 or garbarge 22 * in their alpha field. Used for legacy images that wrote 0 or garbarge
20 * in their alpha field, but intended the RGB to be treated as opaque. 23 * in their alpha field, but intended the RGB to be treated as opaque.
21 */ 24 */
22 kIgnore_SkAlphaType, 25 kIgnore_SkAlphaType,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 } 59 }
57 60
58 /////////////////////////////////////////////////////////////////////////////// 61 ///////////////////////////////////////////////////////////////////////////////
59 62
60 /** 63 /**
61 * Describes how to interpret the components of a pixel. 64 * Describes how to interpret the components of a pixel.
62 */ 65 */
63 enum SkColorType { 66 enum SkColorType {
64 kAlpha_8_SkColorType, 67 kAlpha_8_SkColorType,
65 kRGB_565_SkColorType, 68 kRGB_565_SkColorType,
69 kARGB_4444_SkColorType,
66 kRGBA_8888_SkColorType, 70 kRGBA_8888_SkColorType,
67 kBGRA_8888_SkColorType, 71 kBGRA_8888_SkColorType,
68 kIndex8_SkColorType, 72 kIndex8_SkColorType,
69 73
70 kLastEnum_SkColorType = kIndex8_SkColorType, 74 kLastEnum_SkColorType = kIndex8_SkColorType,
71 75
72 #if SK_PMCOLOR_BYTE_ORDER(B,G,R,A) 76 #if SK_PMCOLOR_BYTE_ORDER(B,G,R,A)
73 kPMColor_SkColorType = kBGRA_8888_SkColorType 77 kPMColor_SkColorType = kBGRA_8888_SkColorType
74 #elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A) 78 #elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A)
75 kPMColor_SkColorType = kRGBA_8888_SkColorType 79 kPMColor_SkColorType = kRGBA_8888_SkColorType
76 #else 80 #else
77 #error "SK_*32_SHFIT values must correspond to BGRA or RGBA byte order" 81 #error "SK_*32_SHFIT values must correspond to BGRA or RGBA byte order"
78 #endif 82 #endif
79 }; 83 };
80 84
81 static int SkColorTypeBytesPerPixel(SkColorType ct) { 85 static int SkColorTypeBytesPerPixel(SkColorType ct) {
82 static const uint8_t gSize[] = { 86 static const uint8_t gSize[] = {
83 1, // Alpha_8 87 1, // Alpha_8
84 2, // RGB_565 88 2, // RGB_565
89 2, // ARGB_4444
85 4, // RGBA_8888 90 4, // RGBA_8888
86 4, // BGRA_8888 91 4, // BGRA_8888
87 1, // kIndex_8 92 1, // kIndex_8
88 }; 93 };
89 SK_COMPILE_ASSERT(SK_ARRAY_COUNT(gSize) == (size_t)(kLastEnum_SkColorType + 1), 94 SK_COMPILE_ASSERT(SK_ARRAY_COUNT(gSize) == (size_t)(kLastEnum_SkColorType + 1),
90 size_mismatch_with_SkColorType_enum); 95 size_mismatch_with_SkColorType_enum);
91 96
92 SkASSERT((size_t)ct < SK_ARRAY_COUNT(gSize)); 97 SkASSERT((size_t)ct < SK_ARRAY_COUNT(gSize));
93 return gSize[ct]; 98 return gSize[ct];
94 } 99 }
(...skipping 10 matching lines...) Expand all
105 SkAlphaType fAlphaType; 110 SkAlphaType fAlphaType;
106 111
107 bool isOpaque() const { 112 bool isOpaque() const {
108 return SkAlphaTypeIsOpaque(fAlphaType); 113 return SkAlphaTypeIsOpaque(fAlphaType);
109 } 114 }
110 115
111 int bytesPerPixel() const { 116 int bytesPerPixel() const {
112 return SkColorTypeBytesPerPixel(fColorType); 117 return SkColorTypeBytesPerPixel(fColorType);
113 } 118 }
114 119
120 size_t minRowBytes() const {
121 return fWidth * this->bytesPerPixel();
122 }
123
115 bool operator==(const SkImageInfo& other) const { 124 bool operator==(const SkImageInfo& other) const {
116 return 0 == memcmp(this, &other, sizeof(other)); 125 return 0 == memcmp(this, &other, sizeof(other));
117 } 126 }
118 bool operator!=(const SkImageInfo& other) const { 127 bool operator!=(const SkImageInfo& other) const {
119 return 0 != memcmp(this, &other, sizeof(other)); 128 return 0 != memcmp(this, &other, sizeof(other));
120 } 129 }
130
131 void unflatten(SkFlattenableReadBuffer&);
132 void flatten(SkFlattenableWriteBuffer&) const;
133
134 size_t getSafeSize(size_t rowBytes) const {
135 if (0 == fHeight) {
136 return 0;
137 }
138 return (fHeight - 1) * rowBytes + fWidth * this->bytesPerPixel();
139 }
121 }; 140 };
122 141
123 #endif 142 #endif
OLDNEW
« no previous file with comments | « include/core/SkBitmapDevice.h ('k') | include/core/SkMallocPixelRef.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698