Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ion::gfx::Image Class Reference

An Image represents 2D image data that can be used in a texture supplied to a shader. More...

#include "image.h"

Inheritance diagram for ion::gfx::Image:
Collaboration diagram for ion::gfx::Image:

Classes

struct  PixelFormat
 Struct representing the GL types for a particular Format (see above). More...
 

Public Types

enum  Format {
  kAlpha,
  kLuminance,
  kLuminanceAlpha,
  kRgb888,
  kRgba8888,
  kRgb565,
  kRgba4444,
  kRgba5551,
  kRgbaFloat,
  kR8,
  kRSigned8,
  kR8i,
  kR8ui,
  kR16fFloat,
  kR16fHalf,
  kR16i,
  kR16ui,
  kR32f,
  kR32i,
  kR32ui,
  kRg8,
  kRgSigned8,
  kRg8i,
  kRg8ui,
  kRg16fFloat,
  kRg16fHalf,
  kRg16i,
  kRg16ui,
  kRg32f,
  kRg32i,
  kRg32ui,
  kRgb8,
  kRgbSigned8,
  kRgb8i,
  kRgb8ui,
  kRgb16fFloat,
  kRgb16fHalf,
  kRgb16i,
  kRgb16ui,
  kRgb32f,
  kRgb32i,
  kRgb32ui,
  kRgba8,
  kRgbaSigned8,
  kRgba8i,
  kRgba8ui,
  kRgb10a2,
  kRgb10a2ui,
  kRgba16fFloat,
  kRgba16fHalf,
  kRgba16i,
  kRgba16ui,
  kRgba32f,
  kRgba32i,
  kRgba32ui,
  kRenderbufferDepth16,
  kRenderbufferDepth24,
  kRenderbufferDepth32f,
  kRenderbufferDepth24Stencil8,
  kRenderbufferDepth32fStencil8,
  kTextureDepth16Int,
  kTextureDepth16Short,
  kStencil8,
  kDxt1,
  kDxt1Rgba,
  kDxt5,
  kEtc1,
  kPvrtc1Rgb2,
  kPvrtc1Rgb4,
  kPvrtc1Rgba2,
  kPvrtc1Rgba4,
  kSrgb8,
  kSrgba8,
  kRgb11f_11f_10f_Rev,
  kRgb11f_11f_10f_RevFloat,
  kRgb11f_11f_10f_RevHalf,
  kRgb565Byte,
  kRgb565Short,
  kRgb5a1Byte,
  kRgb5a1Short,
  kRgb5a1Int,
  kRgb9e5Float,
  kRgb9e5Half,
  kRgb9e5RevInt,
  kRgba4Byte,
  kRgba4Short,
  kEglImage,
  kInvalid
}
 Supported image formats. More...
 
enum  Type {
  kArray,
  kDense,
  kEgl,
  kExternalEgl
}
 The kind of Image, either array or dense, or an EGL type. More...
 
enum  Dimensions {
  k2d,
  k3d
}
 The number of dimensions in the image. 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::DataContainerPtrGetData () 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 PixelFormatGetPixelFormat (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< NotifierNotifierPtr
 
typedef AllocVector< NotifierPtrNotifierPtrVector
 

Protected Member Functions

 ~Image () override
 The destructor is protected because all base::Referent classes must have protected or private destructors. More...
 
const NotifierPtrVectorGetReceivers () const
 Returns the set of Notifiers that will be notified. More...
 
void Notify () const
 Notifies all contained Notifiers by calling their OnNotify(). More...
 

Detailed Description

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.

Definition at line 35 of file image.h.

Member Typedef Documentation

Definition at line 49 of file notifier.h.

typedef AllocVector<NotifierPtr> ion::base::Notifier::NotifierPtrVector
protectedinherited

Definition at line 50 of file notifier.h.

Member Enumeration Documentation

The number of dimensions in the image.

Note that an Nd array texture has N

  • 1 dimensions.
Enumerator
k2d 
k3d 

Definition at line 186 of file image.h.

Supported image formats.

Enumerator
kAlpha 

"Unsized" formats.

kLuminance 
kLuminanceAlpha 
kRgb888 
kRgba8888 
kRgb565 
kRgba4444 
kRgba5551 
kRgbaFloat 
kR8 

compatibility, where both format and internal_format are GL_RGBA).

Single-component red channel images.

kRSigned8 
kR8i 
kR8ui 
kR16fFloat 
kR16fHalf 
kR16i 
kR16ui 
kR32f 
kR32i 
kR32ui 
kRg8 

Two-component red-green images.

kRgSigned8 
kRg8i 
kRg8ui 
kRg16fFloat 
kRg16fHalf 
kRg16i 
kRg16ui 
kRg32f 
kRg32i 
kRg32ui 
kRgb8 

Three channel RGB images.

kRgbSigned8 
kRgb8i 
kRgb8ui 
kRgb16fFloat 
kRgb16fHalf 
kRgb16i 
kRgb16ui 
kRgb32f 
kRgb32i 
kRgb32ui 
kRgba8 

Four channel RGBA images.

kRgbaSigned8 
kRgba8i 
kRgba8ui 
kRgb10a2 
kRgb10a2ui 
kRgba16fFloat 
kRgba16fHalf 
kRgba16i 
kRgba16ui 
kRgba32f 
kRgba32i 
kRgba32ui 
kRenderbufferDepth16 

Depth and depth/stencil renderbuffers.

kRenderbufferDepth24 
kRenderbufferDepth32f 
kRenderbufferDepth24Stencil8 
kRenderbufferDepth32fStencil8 

stencil.

kTextureDepth16Int 

Depth textures.

kTextureDepth16Short 
kStencil8 

Stencil images.

kDxt1 

Compressed images.

kDxt1Rgba 
kDxt5 
kEtc1 
kPvrtc1Rgb2 
kPvrtc1Rgb4 
kPvrtc1Rgba2 
kPvrtc1Rgba4 

alpha).

kSrgb8 

alpha).

SRGB(A) images.

kSrgba8 
kRgb11f_11f_10f_Rev 

Packed sized images.

kRgb11f_11f_10f_RevFloat 

bits blue, packed 10f,11f,11f uint32 data.

kRgb11f_11f_10f_RevHalf 

bits blue, packed float data.

kRgb565Byte 

bits blue, packed half float data.

kRgb565Short 

green, uint8 data.

kRgb5a1Byte 

green, packed 565 uint16 data.

kRgb5a1Short 

bit alpha, uint8 data.

kRgb5a1Int 

bit alpha, packed 5551 uint16 data.

kRgb9e5Float 

bit alpha, packed 2,10,10,10 uint32 data.

kRgb9e5Half 

bits exponent, float data.

kRgb9e5RevInt 

bits exponent, half float data.

kRgba4Byte 

bits exponent, packed 5999 uint32 data.

kRgba4Short 

data.

kEglImage 

4444 uint16 data.

kInvalid 

have arbitrary format.

Definition at line 38 of file image.h.

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 

Definition at line 177 of file image.h.

Constructor & Destructor Documentation

ion::gfx::Image::Image ( )

The default constructor creates an empty (0x0) dense 2D image with format kRgb888.

Definition at line 31 of file image.cc.

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().

Member Function Documentation

void ion::base::Notifier::AddReceiver ( Notifier receiver)
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.

size_t ion::gfx::Image::ComputeDataSize ( Format  format,
uint32  width,
uint32  height,
uint32  depth 
)
static

Definition at line 545 of file image.cc.

References ComputeDataSize().

const AllocatorPtr& ion::base::Allocatable::GetAllocator ( ) const
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().

const AllocatorPtr& ion::base::Allocatable::GetAllocatorForLifetime ( AllocationLifetime  lifetime) const
inlineinherited
const base::DataContainerPtr& ion::gfx::Image::GetData ( ) const
inline

Definition at line 240 of file image.h.

size_t ion::gfx::Image::GetDataSize ( ) const
inline

Definition at line 239 of file image.h.

uint32 ion::gfx::Image::GetDepth ( ) const
inline

Definition at line 238 of file image.h.

Dimensions ion::gfx::Image::GetDimensions ( ) const
inline

Definition at line 235 of file image.h.

Format ion::gfx::Image::GetFormat ( ) const
inline

Definition at line 233 of file image.h.

const char * ion::gfx::Image::GetFormatString ( Format  format)
static

Convenience function that returns a string representing the name of a given Format.

Definition at line 221 of file image.cc.

References kNumFormats.

uint32 ion::gfx::Image::GetHeight ( ) const
inline

Definition at line 237 of file image.h.

const AllocatorPtr& ion::base::Allocatable::GetNonNullAllocator ( ) const
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().

const Image::PixelFormat & ion::gfx::Image::GetPixelFormat ( Format  format)
static
size_t ion::base::Notifier::GetReceiverCount ( ) const
inherited

Returns the number of Notifiers that will be notified.

Definition at line 71 of file notifier.cc.

const Notifier::NotifierPtrVector & ion::base::Notifier::GetReceivers ( ) const
protectedinherited

Returns the set of Notifiers that will be notified.

Definition at line 77 of file notifier.cc.

int ion::base::Shareable::GetRefCount ( ) const
inlineinherited

GetRefCount() is part of the interface necessary for SharedPtr.

Definition at line 34 of file shareable.h.

Referenced by ion::base::Notifier::RemoveReceiver().

Type ion::gfx::Image::GetType ( ) const
inline

Definition at line 234 of file image.h.

uint32 ion::gfx::Image::GetWidth ( ) const
inline

Definition at line 236 of file image.h.

bool ion::gfx::Image::Is8BitPerChannelFormat ( Image::Format  format)
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.

bool ion::gfx::Image::IsCompressed ( ) const
inline

Returns true if the image format is one of the compressed types.

Definition at line 243 of file image.h.

bool ion::gfx::Image::IsCompressedFormat ( Image::Format  format)
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.

void ion::base::Notifier::Notify ( ) const
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().

void ion::base::Allocatable::operator delete ( void *  ptr)
inlineinherited

Define the delete operator to use specialized functions dealing with an Allocator.

Definition at line 109 of file allocatable.h.

void ion::base::Allocatable::operator delete ( void *  ptr,
AllocationLifetime  lifetime 
)
inlineinherited

Windows requires these (or it issues C4291 warnings).

Definition at line 112 of file allocatable.h.

void ion::base::Allocatable::operator delete ( void *  ptr,
const AllocatorPtr allocator 
)
inlineinherited

Definition at line 113 of file allocatable.h.

void ion::base::Allocatable::operator delete ( void *  ptr,
void *  ptr2 
)
inlineinherited

The placement delete operator does nothing, as usual.

Definition at line 118 of file allocatable.h.

void* ion::base::Allocatable::operator new ( size_t  size)
inlineinherited

The standard no-parameter new operator uses the default Allocator.

Definition at line 84 of file allocatable.h.

void* ion::base::Allocatable::operator new ( size_t  size,
AllocationLifetime  lifetime 
)
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.

void* ion::base::Allocatable::operator new ( size_t  size,
const AllocatorPtr allocator 
)
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.

void* ion::base::Allocatable::operator new ( size_t  size,
const AllocatorPtr allocator,
void *  ptr 
)
inlineinherited

Special operator new for using placement new with Allocatables.

Definition at line 100 of file allocatable.h.

void* ion::base::Allocatable::operator new ( size_t  size,
void *  ptr 
)
inlineinherited

The placement new operator is defined conventionally.

Definition at line 105 of file allocatable.h.

void ion::base::Notifier::RemoveReceiver ( Notifier receiver)
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.

References k2d, and kDense.

Referenced by SetArray().

void ion::gfx::Image::Set ( Format  format,
uint32  width,
uint32  height,
uint32  depth,
const base::DataContainerPtr data 
)

Overload that creates a 3D texture.

Definition at line 49 of file image.cc.

References k3d, and kDense.

void ion::gfx::Image::SetArray ( Format  format,
uint32  width,
uint32  num_planes,
const base::DataContainerPtr data 
)

Similar to Set(), but creates an array of 1D textures.

Definition at line 54 of file image.cc.

References k2d, and kArray.

void ion::gfx::Image::SetArray ( Format  format,
uint32  width,
uint32  height,
uint32  num_planes,
const base::DataContainerPtr data 
)

Similar to Set(), but creates an array of 2D textures.

Definition at line 58 of file image.cc.

References k3d, kArray, and Set().

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.

Definition at line 64 of file image.cc.

References k2d, kEgl, and kEglImage.

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.

Member Data Documentation

const uint32 ion::gfx::Image::kNumFormats = kEglImage + 1
static

Definition at line 198 of file image.h.

Referenced by GetFormatString().


The documentation for this class was generated from the following files: