18 #ifndef ION_GFX_TEXTURE_H_
19 #define ION_GFX_TEXTURE_H_
23 #include "base/integral_types.h"
24 #include "base/macros.h"
38 static const size_t kMipmapSlotCount = 16;
49 SubImage(
size_t level_in,
const math::Point2ui& offset_in,
52 offset(offset_in[0], offset_in[1], 0U),
54 SubImage(
size_t level_in,
const math::Point3ui& offset_in,
65 kBaseLevelChanged = kNumBaseChanges,
106 void SetImmutableImage(
const ImagePtr&
image,
size_t levels);
136 swizzle_green_.Set(g);
137 swizzle_blue_.Set(b);
138 swizzle_alpha_.Set(a);
148 LOG(
WARNING) <<
"Ignoring bad number of samples: " << samples;
151 multisample_samples_.Set(samples);
152 multisample_fixed_sample_locations_.Set(fixed_sample_locations);
155 return multisample_samples_.Get();
158 return multisample_fixed_sample_locations_.Get();
167 int mipmaps_changed_start_bit);
172 void SetSubImage(
size_t level,
const math::Point2ui
offset,
177 void SetSubImage(
size_t level,
const math::Point3ui offset,
193 return level < mipmaps_set_.size() && mipmaps_set_.test(level);
200 return mipmaps_.
Get(level);
207 return mipmaps_set_.count();
228 std::bitset<kMipmapSlotCount> mipmaps_set_;
239 Field<SamplerPtr> sampler_;
240 Field<int> base_level_;
241 Field<int> max_level_;
242 RangedField<Swizzle> swizzle_red_;
243 RangedField<Swizzle> swizzle_green_;
244 RangedField<Swizzle> swizzle_blue_;
245 RangedField<Swizzle> swizzle_alpha_;
248 TextureType texture_type_;
251 Field<ImagePtr> immutable_image_;
253 size_t immutable_levels_;
256 Field<int> multisample_samples_;
257 Field<bool> multisample_fixed_sample_locations_;
271 kNumChanges = kMipmapChanged + kMipmapSlotCount
278 if (GetImmutableImage().Get())
279 LOG(
ERROR) <<
"ION: SetImage() called on immutable texture \""
281 <<
"\". Use SetSubImage() to update an immutable texture.";
283 face_.SetImage(level, image,
this);
286 return face_.HasImage(level);
289 return face_.GetImage(level);
292 return face_.GetImageCount();
296 SetSubImage(level, math::Point3ui(offset[0], offset[1], 0), image);
300 face_.SetSubImage(level, offset, image);
303 return face_.GetSubImages();
306 face_.ClearSubImages();
311 static bool ExpectedDimensionsForMipmap(
const uint32 mipmap_width,
312 const uint32 mipmap_height,
313 const uint32 mipmap_level,
314 const uint32 base_width,
315 const uint32 base_height,
316 uint32* expected_width,
317 uint32* expected_height);
338 #endif // ION_GFX_TEXTURE_H_
const ImagePtr GetImage(size_t level) const
Returns the image at the specified mipmap level, or NULL if this is not mipmapped.
bool IsMultisampleFixedSampleLocations() const
A Texture object represents the image data and mipmaps associated with a single texture.
base::ReferentPtr< Image >::Type ImagePtr
void SetSwizzleBlue(Swizzle b)
Changes
Changes that affect this resource. Some changes are forwarded from Sampler.
const SamplerPtr & GetSampler() const
void SetMultisampling(int samples, bool fixed_sample_locations)
Enables/disables and sets parameters for texture multisampling.
Wrapper around a sub-image, which is defined as an image, the xy offset of where it should be placed ...
SubImage(size_t level_in, const math::Point2ui &offset_in, const ImagePtr &image_in)
size_t GetImageCount() const
#define LOG(severity)
Logs the streamed message unconditionally with a severity of severity.
A Notifier both sends notifications to and receives notifications from other Notifiers.
A Field that holds a vector of up to some number of values.
Swizzle GetSwizzleGreen() const
void SetBaseLevel(int level)
Sets/returns the index of the lowest mipmap level to use when rendering.
void ClearSubImages() const
bool HasImage(size_t level) const
void ClearSubImages() const
Clears the vector of sub-images.
Internal class that wraps texture data: a single image or a stack of mipmaps, and any sub- or layered...
T * Get() const
Returns a raw pointer to the instance, which may be NULL.
void SetSwizzleRed(Swizzle r)
Sets/returns the color component to use when the color channels of a texture are used in a shader...
int GetMultisampleSamples() const
bool HasImage(size_t level) const
Returns true if there is a mipmap image at the specified level stored here.
Swizzle GetSwizzleAlpha() const
const Grid & image
The original monochrome image data, as doubles (0 - 1).
const base::AllocVector< SubImage > & GetSubImages() const
Returns the vector of sub-images; it may be empty.
void SetSwizzleAlpha(Swizzle a)
SubImage(size_t level_in, const math::Point3ui &offset_in, const ImagePtr &image_in)
TexturePtr texture
The Texture to add sub-image data to.
Swizzle GetSwizzleBlue() const
This is an internal base class for all texture types.
A generic field that represents some state in the resource.
void SetSwizzles(Swizzle r, Swizzle g, Swizzle b, Swizzle a)
Sets all swizzles at once.
size_t GetImageCount() const
Gets the number of mipmap images that have been set.
void SetMaxLevel(int level)
Sets/returns the index of the highest mipmap level to use when rendering.
void SetImage(size_t level, const ImagePtr &image)
See comments in TextureBase::Face.
const ImagePtr GetImage(size_t level) const
TextureType GetTextureType() const
Returns what type of texture that this is.
const base::AllocVector< SubImage > & GetSubImages() const
kMipmapChanged must be last since it is a range of slots.
void SetSwizzleGreen(Swizzle g)
A SharedPtr is a smart shared pointer to an instance of some class that implements reference counting...
Swizzle GetSwizzleRed() const
size_t GetImmutableLevels() const
Returns the number of immutable mipmap levels used by this texture.
const ImagePtr & GetImmutableImage() const
ResourceHolder is an internal base class for objects that hold resources managed by an outside entity...
base::ReferentPtr< Texture >::Type TexturePtr
Convenience typedef for shared pointer to a Texture.
void SetSubImage(size_t level, const math::Point3ui offset, const ImagePtr &image)
void SetSubImage(size_t level, const math::Point2ui offset, const ImagePtr &image)
This class can be used in place of std::vector to allow an Ion Allocator to be used for memory alloca...