Ion
|
An Image represents 2D image data that can be used in a texture supplied to a shader. More...
#include "image.h"
Classes | |
struct | PixelFormat |
Struct representing the GL types for a particular Format (see above). More... | |
Public Member Functions | |
Image () | |
The default constructor creates an empty (0x0) dense 2D image with format kRgb888. More... | |
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. More... | |
void | Set (Format format, uint32 width, uint32 height, uint32 depth, const base::DataContainerPtr &data) |
Overload that creates a 3D texture. More... | |
void | SetArray (Format format, uint32 width, uint32 num_planes, const base::DataContainerPtr &data) |
Similar to Set(), but creates an array of 1D textures. More... | |
void | SetArray (Format format, uint32 width, uint32 height, uint32 num_planes, const base::DataContainerPtr &data) |
Similar to Set(), but creates an array of 2D textures. More... | |
void | SetEglImage (const base::DataContainerPtr &image) |
Sets the image to be of EGLImage type. More... | |
void | SetExternalEglImage (const base::DataContainerPtr &external_image) |
Sets the image to be of external EGLImage type. More... | |
Format | GetFormat () const |
Type | GetType () const |
Dimensions | GetDimensions () const |
uint32 | GetWidth () const |
uint32 | GetHeight () const |
uint32 | GetDepth () const |
size_t | GetDataSize () const |
const base::DataContainerPtr & | GetData () const |
bool | IsCompressed () const |
Returns true if the image format is one of the compressed types. More... | |
void | AddReceiver (Notifier *receiver) |
Adds a Notifier to be notified. More... | |
void | RemoveReceiver (Notifier *receiver) |
Removes a Notifier to be notified. More... | |
size_t | GetReceiverCount () const |
Returns the number of Notifiers that will be notified. More... | |
const AllocatorPtr & | GetAllocator () const |
Returns the Allocator that was used for the instance. More... | |
const AllocatorPtr & | GetNonNullAllocator () const |
Return our allocator, or the default allocator if the instance was declared on the stack. More... | |
const AllocatorPtr & | GetAllocatorForLifetime (AllocationLifetime lifetime) const |
Convenience function that returns the Allocator to use to allocate an object with a specific lifetime. More... | |
void * | operator new (size_t size) |
The standard no-parameter new operator uses the default Allocator. More... | |
void * | operator new (size_t size, AllocationLifetime lifetime) |
This overloaded version of the new operator uses the AllocationManager's default Allocator for the specified lifetime. More... | |
void * | operator new (size_t size, const AllocatorPtr &allocator) |
This overloaded version of the new operator takes the Allocator to use directly as a parameter. More... | |
void * | operator new (size_t size, const AllocatorPtr &allocator, void *ptr) |
Special operator new for using placement new with Allocatables. More... | |
void * | operator new (size_t size, void *ptr) |
The placement new operator is defined conventionally. More... | |
void | operator delete (void *ptr) |
Define the delete operator to use specialized functions dealing with an Allocator. More... | |
void | operator delete (void *ptr, AllocationLifetime lifetime) |
Windows requires these (or it issues C4291 warnings). More... | |
void | operator delete (void *ptr, const AllocatorPtr &allocator) |
void | operator delete (void *ptr, void *ptr2) |
The placement delete operator does nothing, as usual. More... | |
int | GetRefCount () const |
GetRefCount() is part of the interface necessary for SharedPtr. More... | |
Static Public Member Functions | |
static const char * | GetFormatString (Format format) |
Convenience function that returns a string representing the name of a given Format. More... | |
static const PixelFormat & | GetPixelFormat (Format format) |
Convenience function that returns a PixelFormat given a Format. More... | |
static int | GetNumComponentsForFormat (Format format) |
Convenience function that returns the number of components for a given format. More... | |
static bool | IsCompressedFormat (Format format) |
Convenience function that returns true if the given format represents compressed image data. More... | |
static bool | Is8BitPerChannelFormat (Format format) |
Returns whether the specified format has 8 bits per channel. More... | |
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 and dimensions. More... | |
static size_t | ComputeDataSize (Format format, uint32 width, uint32 height, uint32 depth) |
Static Public Attributes | |
static const uint32 | kNumFormats = kEglImage + 1 |
Protected Types | |
typedef WeakReferentPtr< Notifier > | NotifierPtr |
typedef AllocVector< NotifierPtr > | NotifierPtrVector |
Protected Member Functions | |
~Image () override | |
The destructor is protected because all base::Referent classes must have protected or private destructors. More... | |
const NotifierPtrVector & | GetReceivers () const |
Returns the set of Notifiers that will be notified. More... | |
void | Notify () const |
Notifies all contained Notifiers by calling their OnNotify(). More... | |
An Image represents 2D image data that can be used in a texture supplied to a shader.
The image data is stored in a DataContainer to provide flexibility regarding storage lifetime.
|
protectedinherited |
Definition at line 49 of file notifier.h.
|
protectedinherited |
Definition at line 50 of file notifier.h.
Supported image formats.
The kind of Image, either array or dense, or an EGL type.
An array image is a series of planes that are not interpolated, while a dense image uses filtering across the last dimension. An EGL image is one supplied by the EGL library via the OES_EGL_image extension, while an external EGL image is one created via the OES_EGL_image_external extension.
Enumerator | |
---|---|
kArray | |
kDense | |
kEgl | |
kExternalEgl |
ion::gfx::Image::Image | ( | ) |
|
overrideprotected |
The destructor is protected because all base::Referent classes must have protected or private destructors.
Definition at line 40 of file image.cc.
References ion::base::SharedPtr< T >::Get().
|
inherited |
Adds a Notifier to be notified.
Does nothing if the receiver is NULL or is already in the receiver vector.
Definition at line 25 of file notifier.cc.
Convenience functions that return the correct data size in bytes of an image having the given format and dimensions.
Definition at line 421 of file image.cc.
References DCHECK, kAlpha, kDxt1, kDxt1Rgba, kDxt5, kEglImage, kEtc1, kInvalid, kLuminance, kLuminanceAlpha, kPvrtc1Rgb2, kPvrtc1Rgb4, kPvrtc1Rgba2, kPvrtc1Rgba4, kR16fFloat, kR16fHalf, kR16i, kR16ui, kR32f, kR32i, kR32ui, kR8, kR8i, kR8ui, kRenderbufferDepth16, kRenderbufferDepth24, kRenderbufferDepth24Stencil8, kRenderbufferDepth32f, kRenderbufferDepth32fStencil8, kRg16fFloat, kRg16fHalf, kRg16i, kRg16ui, kRg32f, kRg32i, kRg32ui, kRg8, kRg8i, kRg8ui, kRgb10a2, kRgb10a2ui, kRgb11f_11f_10f_Rev, kRgb11f_11f_10f_RevFloat, kRgb11f_11f_10f_RevHalf, kRgb16fFloat, kRgb16fHalf, kRgb16i, kRgb16ui, kRgb32f, kRgb32i, kRgb32ui, kRgb565, kRgb565Byte, kRgb565Short, kRgb5a1Byte, kRgb5a1Int, kRgb5a1Short, kRgb8, kRgb888, kRgb8i, kRgb8ui, kRgb9e5Float, kRgb9e5Half, kRgb9e5RevInt, kRgba16fFloat, kRgba16fHalf, kRgba16i, kRgba16ui, kRgba32f, kRgba32i, kRgba32ui, kRgba4444, kRgba4Byte, kRgba4Short, kRgba5551, kRgba8, kRgba8888, kRgba8i, kRgba8ui, kRgbaFloat, kRgbaSigned8, kRgbSigned8, kRgSigned8, kRSigned8, kSrgb8, kSrgba8, kStencil8, kTextureDepth16Int, and kTextureDepth16Short.
Referenced by ComputeDataSize(), and Is8BitPerChannelFormat().
|
static |
Definition at line 545 of file image.cc.
References ComputeDataSize().
|
inlineinherited |
Returns the Allocator that was used for the instance.
This will be NULL if the instance was declared on the stack or created with normal placement new.
Definition at line 68 of file allocatable.h.
References allocator_.
Referenced by ion::base::DataContainer::CreateAndCopy(), ion::text::DynamicFontImage::FindContainingImageDataIndex(), and ion::text::DynamicFontImage::FindImageDataIndex().
|
inlineinherited |
Convenience function that returns the Allocator to use to allocate an object with a specific lifetime.
Definition at line 78 of file allocatable.h.
References ion::base::Allocator::GetAllocatorForLifetime().
Referenced by ion::text::BasicBuilder::BuildVertexData(), ion::text::OutlineBuilder::BuildVertexData(), ion::gfxutils::ShaderManager::CreateShaderProgram(), ion::text::DynamicFontImage::FindContainingImageDataIndex(), ion::text::DynamicFontImage::FindImageDataIndex(), ion::gfx::Renderer::Renderer(), and ion::gfx::UpdateStateTable().
|
inline |
|
inline |
|
static |
Convenience function that returns a string representing the name of a given Format.
Definition at line 221 of file image.cc.
References kNumFormats.
|
inlineinherited |
Return our allocator, or the default allocator if the instance was declared on the stack.
Definition at line 72 of file allocatable.h.
References allocator_, and ion::base::AllocationManager::GetNonNullAllocator().
|
static |
Convenience function that returns the number of components for a given format.
Definition at line 315 of file image.cc.
References DCHECK, kAlpha, kDxt1, kDxt1Rgba, kDxt5, kEglImage, kEtc1, kInvalid, kLuminance, kLuminanceAlpha, kPvrtc1Rgb2, kPvrtc1Rgb4, kPvrtc1Rgba2, kPvrtc1Rgba4, kR16fFloat, kR16fHalf, kR16i, kR16ui, kR32f, kR32i, kR32ui, kR8, kR8i, kR8ui, kRenderbufferDepth16, kRenderbufferDepth24, kRenderbufferDepth24Stencil8, kRenderbufferDepth32f, kRenderbufferDepth32fStencil8, kRg16fFloat, kRg16fHalf, kRg16i, kRg16ui, kRg32f, kRg32i, kRg32ui, kRg8, kRg8i, kRg8ui, kRgb10a2, kRgb10a2ui, kRgb11f_11f_10f_Rev, kRgb11f_11f_10f_RevFloat, kRgb11f_11f_10f_RevHalf, kRgb16fFloat, kRgb16fHalf, kRgb16i, kRgb16ui, kRgb32f, kRgb32i, kRgb32ui, kRgb565, kRgb565Byte, kRgb565Short, kRgb5a1Byte, kRgb5a1Int, kRgb5a1Short, kRgb8, kRgb888, kRgb8i, kRgb8ui, kRgb9e5Float, kRgb9e5Half, kRgb9e5RevInt, kRgba16fFloat, kRgba16fHalf, kRgba16i, kRgba16ui, kRgba32f, kRgba32i, kRgba32ui, kRgba4444, kRgba4Byte, kRgba4Short, kRgba5551, kRgba8, kRgba8888, kRgba8i, kRgba8ui, kRgbaFloat, kRgbaSigned8, kRgbSigned8, kRgSigned8, kRSigned8, kSrgb8, kSrgba8, kStencil8, kTextureDepth16Int, and kTextureDepth16Short.
Referenced by Is8BitPerChannelFormat().
|
static |
Convenience function that returns a PixelFormat given a Format.
Definition at line 76 of file image.cc.
References GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG, GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG, GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, GL_ETC1_RGB8_OES, GL_LUMINANCE, GL_LUMINANCE_ALPHA, kEglImage, and kInvalid.
|
inherited |
Returns the number of Notifiers that will be notified.
Definition at line 71 of file notifier.cc.
|
protectedinherited |
Returns the set of Notifiers that will be notified.
Definition at line 77 of file notifier.cc.
|
inlineinherited |
GetRefCount() is part of the interface necessary for SharedPtr.
Definition at line 34 of file shareable.h.
Referenced by ion::base::Notifier::RemoveReceiver().
|
inlinestatic |
Returns whether the specified format has 8 bits per channel.
E.g. kRgba8888, kLuminanceAlpha, kRgb8ui, etc. It does not include compressed formats even if they decompress to something that is 8 bits per channel.
Definition at line 303 of file image.h.
References ComputeDataSize(), GetNumComponentsForFormat(), kEglImage, kInvalid, kRgb10a2, kRgb10a2ui, and kRgb5a1Int.
|
inline |
|
inlinestatic |
Convenience function that returns true if the given format represents compressed image data.
Definition at line 297 of file image.h.
References kDxt1, kDxt1Rgba, kDxt5, kEtc1, kPvrtc1Rgb2, kPvrtc1Rgb4, kPvrtc1Rgba2, and kPvrtc1Rgba4.
|
protectedinherited |
Notifies all contained Notifiers by calling their OnNotify().
Any receivers that have been destroyed will be removed from the vector of receivers.
Definition at line 81 of file notifier.cc.
References ion::base::SharedPtr< T >::Get().
|
inlineinherited |
Define the delete operator to use specialized functions dealing with an Allocator.
Definition at line 109 of file allocatable.h.
|
inlineinherited |
Windows requires these (or it issues C4291 warnings).
Definition at line 112 of file allocatable.h.
|
inlineinherited |
Definition at line 113 of file allocatable.h.
|
inlineinherited |
The placement delete operator does nothing, as usual.
Definition at line 118 of file allocatable.h.
|
inlineinherited |
The standard no-parameter new operator uses the default Allocator.
Definition at line 84 of file allocatable.h.
|
inlineinherited |
This overloaded version of the new operator uses the AllocationManager's default Allocator for the specified lifetime.
Definition at line 88 of file allocatable.h.
|
inlineinherited |
This overloaded version of the new operator takes the Allocator to use directly as a parameter.
If the Allocator pointer is NULL, this uses the default Allocator.
Definition at line 95 of file allocatable.h.
|
inlineinherited |
Special operator new for using placement new with Allocatables.
Definition at line 100 of file allocatable.h.
|
inlineinherited |
The placement new operator is defined conventionally.
Definition at line 105 of file allocatable.h.
|
inherited |
Removes a Notifier to be notified.
Does nothing if the receiver is NULL or not in the set of receivers.
Definition at line 38 of file notifier.cc.
References ion::base::Shareable::GetRefCount().
Referenced by ion::gfx::AttributeArray::~AttributeArray().
void ion::gfx::Image::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.
Definition at line 44 of file image.cc.
Referenced by SetArray().
void ion::gfx::Image::Set | ( | Format | format, |
uint32 | width, | ||
uint32 | height, | ||
uint32 | depth, | ||
const base::DataContainerPtr & | data | ||
) |
void ion::gfx::Image::SetArray | ( | Format | format, |
uint32 | width, | ||
uint32 | num_planes, | ||
const base::DataContainerPtr & | data | ||
) |
void ion::gfx::Image::SetArray | ( | Format | format, |
uint32 | width, | ||
uint32 | height, | ||
uint32 | num_planes, | ||
const base::DataContainerPtr & | data | ||
) |
void ion::gfx::Image::SetEglImage | ( | const base::DataContainerPtr & | image | ) |
Sets the image to be of EGLImage type.
The width, height, format, and image data are all determined opaquely based on the passed image. The passed data container may just wrap a void pointer. If the passed data is NULL, then it must be supplied via EGL outside of Ion after retrieving the texture ID from a Renderer.
void ion::gfx::Image::SetExternalEglImage | ( | const base::DataContainerPtr & | external_image | ) |
Sets the image to be of external EGLImage type.
The width, height, format, and image data are all determined opaquely based on the passed external image. The passed data container may just wrap a void pointer. If the passed data is NULL, then it must be supplied outside of Ion after retrieving the texture ID from a Renderer.
Definition at line 70 of file image.cc.
References k2d, kEglImage, and kExternalEgl.
|
static |
Definition at line 198 of file image.h.
Referenced by GetFormatString().