46 SetData(
kDense,
k2d, format, width, height, 1, data);
51 SetData(
kDense,
k3d, format, width, height, depth, data);
56 SetData(
kArray,
k2d, format, width, num_planes, 1, data);
60 Set(format, width, height, num_planes, data);
61 SetData(
kArray,
k3d, format, width, height, num_planes, data);
80 {GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE},
85 {GL_RGB, GL_RGB, GL_UNSIGNED_BYTE},
86 {GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE},
87 {GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5},
89 GL_UNSIGNED_SHORT_4_4_4_4},
91 GL_UNSIGNED_SHORT_5_5_5_1},
92 {GL_RGBA, GL_RGBA, GL_FLOAT},
93 {GL_R8, GL_RED, GL_UNSIGNED_BYTE},
94 {GL_R8_SNORM, GL_RED, GL_BYTE},
95 {GL_R8I, GL_RED_INTEGER, GL_BYTE},
96 {GL_R8UI, GL_RED_INTEGER,
98 {GL_R16F, GL_RED, GL_FLOAT},
99 {GL_R16F, GL_RED, GL_HALF_FLOAT},
100 {GL_R16I, GL_RED_INTEGER, GL_SHORT},
101 {GL_R16UI, GL_RED_INTEGER,
103 {GL_R32F, GL_RED, GL_FLOAT},
104 {GL_R32I, GL_RED_INTEGER, GL_INT},
105 {GL_R32UI, GL_RED_INTEGER,
107 {GL_RG8, GL_RG, GL_UNSIGNED_BYTE},
108 {GL_RG8_SNORM, GL_RG, GL_BYTE},
109 {GL_RG8I, GL_RG_INTEGER, GL_BYTE},
110 {GL_RG8UI, GL_RG_INTEGER,
112 {GL_RG16F, GL_RG, GL_FLOAT},
113 {GL_RG16F, GL_RG, GL_HALF_FLOAT},
114 {GL_RG16I, GL_RG_INTEGER, GL_SHORT},
115 {GL_RG16UI, GL_RG_INTEGER,
117 {GL_RG32F, GL_RG, GL_FLOAT},
118 {GL_RG32I, GL_RG_INTEGER, GL_INT},
119 {GL_RG32UI, GL_RG_INTEGER,
121 {GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE},
122 {GL_RGB8_SNORM, GL_RGB, GL_BYTE},
123 {GL_RGB8I, GL_RGB_INTEGER, GL_BYTE},
124 {GL_RGB8UI, GL_RGB_INTEGER,
126 {GL_RGB16F, GL_RGB, GL_FLOAT},
127 {GL_RGB16F, GL_RGB, GL_HALF_FLOAT},
128 {GL_RGB16I, GL_RGB_INTEGER, GL_SHORT},
129 {GL_RGB16UI, GL_RGB_INTEGER,
131 {GL_RGB32F, GL_RGB, GL_FLOAT},
132 {GL_RGB32I, GL_RGB_INTEGER, GL_INT},
133 {GL_RGB32UI, GL_RGB_INTEGER,
135 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE},
136 {GL_RGBA8_SNORM, GL_RGBA, GL_BYTE},
137 {GL_RGBA8I, GL_RGBA_INTEGER, GL_BYTE},
138 {GL_RGBA8UI, GL_RGBA_INTEGER,
140 {GL_RGB10_A2, GL_RGBA,
141 GL_UNSIGNED_INT_2_10_10_10_REV},
142 {GL_RGB10_A2UI, GL_RGBA_INTEGER,
143 GL_UNSIGNED_INT_2_10_10_10_REV},
144 {GL_RGBA16F, GL_RGBA, GL_FLOAT},
145 {GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT},
146 {GL_RGBA16I, GL_RGBA_INTEGER, GL_SHORT},
147 {GL_RGBA16UI, GL_RGBA_INTEGER,
149 {GL_RGBA32F, GL_RGBA, GL_FLOAT},
150 {GL_RGBA32I, GL_RGBA_INTEGER, GL_INT},
151 {GL_RGBA32UI, GL_RGBA_INTEGER,
153 {GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT,
155 {GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT,
157 {GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT,
159 {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL,
160 GL_UNSIGNED_INT_24_8},
161 {GL_DEPTH32F_STENCIL8,
163 GL_FLOAT_32_UNSIGNED_INT_24_8_REV},
164 {GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT,
166 {GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT,
168 {GL_STENCIL_INDEX8, GL_STENCIL,
170 {GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
173 {GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
176 {GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
193 {GL_SRGB8, GL_RGB, GL_UNSIGNED_BYTE},
194 {GL_SRGB8_ALPHA8, GL_RGBA,
196 {GL_R11F_G11F_B10F, GL_RGB,
197 GL_UNSIGNED_INT_10F_11F_11F_REV},
198 {GL_R11F_G11F_B10F, GL_RGB, GL_FLOAT},
199 {GL_R11F_G11F_B10F, GL_RGB, GL_HALF_FLOAT},
200 {GL_RGB565, GL_RGB, GL_UNSIGNED_BYTE},
202 GL_UNSIGNED_SHORT_5_6_5},
203 {GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_BYTE},
204 {GL_RGB5_A1, GL_RGBA,
205 GL_UNSIGNED_SHORT_5_5_5_1},
206 {GL_RGB5_A1, GL_RGBA,
207 GL_UNSIGNED_INT_2_10_10_10_REV},
208 {GL_RGB9_E5, GL_RGB, GL_FLOAT},
209 {GL_RGB9_E5, GL_RGB, GL_HALF_FLOAT},
211 GL_UNSIGNED_INT_5_9_9_9_REV},
212 {GL_RGBA4, GL_RGBA, GL_UNSIGNED_BYTE},
214 GL_UNSIGNED_SHORT_4_4_4_4}};
215 static const PixelFormat kInvalidPixelFormat = {0, 0, 0};
218 : kPixelFormats[format];
222 static const char* kStrings[] = {
278 "RenderbufferDepth16",
279 "RenderbufferDepth24",
280 "RenderbufferDepth32f",
281 "RenderbufferDepth24Stencil8",
282 "RenderbufferDepth32fStencil8",
284 "TextureDepth16Short",
296 "Rgb11f_11f_10f_Rev",
297 "Rgb11f_11f_10f_RevFloat",
298 "Rgb11f_11f_10f_RevHalf",
311 return static_cast<uint32
>(format) >=
kNumFormats ?
"<UNKNOWN>"
416 DCHECK(
false) <<
"Unknown format";
430 return width * height;
436 return 8 * ((width + 3) / 4) * ((height + 3) / 4);
440 return 16 * ((width + 3) / 4) * ((height + 3) / 4);
464 return 2 * width * height;
468 return width * height / 4;
472 return width * height / 2;
480 return 3 * width * height;
506 return 4 * width * height;
512 return 6 * width * height;
522 return 8 * width * height;
527 return 12 * width * height;
533 return 16 * width * height;
540 DCHECK(
false) <<
"Unknown format";
550 void Image::SetData(Type
type, Dimensions dims, Format format, uint32
width,
551 uint32 height, uint32 depth,
560 old_data->RemoveReceiver(
this);
563 new_data->AddReceiver(
this);
564 if (data_.
Get() && data_->GetData())
579 const EnumHelper::EnumData<Image::Dimensions> EnumHelper::GetEnumData() {
580 static const GLenum kValues[] = {0, 0};
581 static const char* kStrings[] = {
"2",
"3"};
583 "EnumHelper size mismatch");
584 return EnumData<Image::Dimensions>(
591 const EnumHelper::EnumData<Image::Type> EnumHelper::GetEnumData() {
592 static const GLenum kValues[] = {0, 0, 0, 0};
593 static const char* kStrings[] = {
"Array",
"Dense",
"EGLImage",
594 "External EGLImage"};
596 "EnumHelper size mismatch");
597 return EnumData<Image::Type>(
~Image() override
The destructor is protected because all base::Referent classes must have protected or private destruc...
Format
Supported image formats.
Image()
The default constructor creates an empty (0x0) dense 2D image with format kRgb888.
bits exponent, half float data.
Depth and depth/stencil renderbuffers.
bit alpha, packed 5551 uint16 data.
bit alpha, packed 2,10,10,10 uint32 data.
Four channel RGBA images.
void SetArray(Format format, uint32 width, uint32 num_planes, const base::DataContainerPtr &data)
Similar to Set(), but creates an array of 1D textures.
void Notify() const
Notifies all contained Notifiers by calling their OnNotify().
Three channel RGB images.
static size_t ComputeDataSize(Format format, uint32 width, uint32 height)
Convenience functions that return the correct data size in bytes of an image having the given format ...
The DataContainer class encapsulates arbitrary user data passed to Ion.
T * Get() const
Returns a raw pointer to the instance, which may be NULL.
This template class can be used to map between two kinds of indices when the following assumptions ap...
Two-component red-green images.
bits exponent, packed 5999 uint32 data.
static const PixelFormat & GetPixelFormat(Format format)
Convenience function that returns a PixelFormat given a Format.
bits blue, packed 10f,11f,11f uint32 data.
bits exponent, float data.
const Grid & image
The original monochrome image data, as doubles (0 - 1).
void SetExternalEglImage(const base::DataContainerPtr &external_image)
Sets the image to be of external EGLImage type.
bits blue, packed float data.
Copyright 2016 Google Inc.
bits blue, packed half float data.
void Set(Format format, uint32 width, uint32 height, const base::DataContainerPtr &data)
Sets the image to the given size and format and using the data in the given DataContainer, which is assumed to be the correct size.
static int GetNumComponentsForFormat(Format format)
Convenience function that returns the number of components for a given format.
compatibility, where both format and internal_format are GL_RGBA).
#define ION_STATIC_ASSERT(expr, message)
Copyright 2016 Google Inc.
void SetEglImage(const base::DataContainerPtr &image)
Sets the image to be of EGLImage type.
A SharedPtr is a smart shared pointer to an instance of some class that implements reference counting...
static const uint32 kNumFormats
static const char * GetFormatString(Format format)
Convenience function that returns a string representing the name of a given Format.
green, packed 565 uint16 data.