| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 unsigned height, | 74 unsigned height, |
| 75 const void* src_data, | 75 const void* src_data, |
| 76 int src_pitch); | 76 int src_pitch); |
| 77 | 77 |
| 78 // Returns the implementation-specific texture handle for this texture. | 78 // Returns the implementation-specific texture handle for this texture. |
| 79 virtual void* GetTextureHandle() const { | 79 virtual void* GetTextureHandle() const { |
| 80 return reinterpret_cast<void*>(resource_id_); | 80 return reinterpret_cast<void*>(resource_id_); |
| 81 } | 81 } |
| 82 | 82 |
| 83 // Gets the texture resource ID. | 83 // Gets the texture resource ID. |
| 84 command_buffer::ResourceID resource_id() const { return resource_id_; } | 84 command_buffer::ResourceId resource_id() const { return resource_id_; } |
| 85 | 85 |
| 86 // Gets a RGBASwizzleIndices that contains a mapping from | 86 // Gets a RGBASwizzleIndices that contains a mapping from |
| 87 // RGBA to the internal format used by the rendering API. | 87 // RGBA to the internal format used by the rendering API. |
| 88 virtual const RGBASwizzleIndices& GetABGR32FSwizzleIndices(); | 88 virtual const RGBASwizzleIndices& GetABGR32FSwizzleIndices(); |
| 89 | 89 |
| 90 protected: | 90 protected: |
| 91 // Overridden from Texture2D | 91 // Overridden from Texture2D |
| 92 virtual bool PlatformSpecificLock( | 92 virtual bool PlatformSpecificLock( |
| 93 int level, void** texture_data, int* pitch, AccessMode mode); | 93 int level, void** texture_data, int* pitch, AccessMode mode); |
| 94 | 94 |
| 95 // Overridden from Texture2D | 95 // Overridden from Texture2D |
| 96 virtual bool PlatformSpecificUnlock(int level); | 96 virtual bool PlatformSpecificUnlock(int level); |
| 97 | 97 |
| 98 // Overridden from Texture2D | 98 // Overridden from Texture2D |
| 99 virtual RenderSurface::Ref PlatformSpecificGetRenderSurface(int mip_level); | 99 virtual RenderSurface::Ref PlatformSpecificGetRenderSurface(int mip_level); |
| 100 | 100 |
| 101 private: | 101 private: |
| 102 // Initializes the Texture2DCB from a preexisting OpenCB texture handle | 102 // Initializes the Texture2DCB from a preexisting OpenCB texture handle |
| 103 // and raw Bitmap data. | 103 // and raw Bitmap data. |
| 104 // The texture takes ownership of the bitmap data. | 104 // The texture takes ownership of the bitmap data. |
| 105 Texture2DCB(ServiceLocator* service_locator, | 105 Texture2DCB(ServiceLocator* service_locator, |
| 106 command_buffer::ResourceID resource_id, | 106 command_buffer::ResourceId resource_id, |
| 107 Texture::Format format, | 107 Texture::Format format, |
| 108 int levels, | 108 int levels, |
| 109 int width, | 109 int width, |
| 110 int height, | 110 int height, |
| 111 bool enable_render_surfaces); | 111 bool enable_render_surfaces); |
| 112 | 112 |
| 113 // Returns true if the backing bitmap has the data for the level. | 113 // Returns true if the backing bitmap has the data for the level. |
| 114 bool HasLevel(unsigned int level) { | 114 bool HasLevel(unsigned int level) { |
| 115 DCHECK_LT(level, static_cast<unsigned int>(levels())); | 115 DCHECK_LT(level, static_cast<unsigned int>(levels())); |
| 116 return (has_levels_ & (1 << level)) != 0; | 116 return (has_levels_ & (1 << level)) != 0; |
| 117 } | 117 } |
| 118 | 118 |
| 119 RendererCB* renderer_; | 119 RendererCB* renderer_; |
| 120 command_buffer::ResourceID resource_id_; | 120 command_buffer::ResourceId resource_id_; |
| 121 | 121 |
| 122 // A bitmap used to back the NPOT textures on POT-only hardware, and to back | 122 // A bitmap used to back the NPOT textures on POT-only hardware, and to back |
| 123 // the pixel buffer for Lock(). | 123 // the pixel buffer for Lock(). |
| 124 Bitmap::Ref backing_bitmap_; | 124 Bitmap::Ref backing_bitmap_; |
| 125 | 125 |
| 126 // Bitfield that indicates mip levels that are currently stored in the | 126 // Bitfield that indicates mip levels that are currently stored in the |
| 127 // backing bitmap. | 127 // backing bitmap. |
| 128 unsigned int has_levels_; | 128 unsigned int has_levels_; |
| 129 | 129 |
| 130 // Bitfield that indicates which mip levels are currently locked. | 130 // Bitfield that indicates which mip levels are currently locked. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 155 unsigned height, | 155 unsigned height, |
| 156 const void* src_data, | 156 const void* src_data, |
| 157 int src_pitch); | 157 int src_pitch); |
| 158 | 158 |
| 159 // Returns the implementation-specific texture handle for this texture. | 159 // Returns the implementation-specific texture handle for this texture. |
| 160 virtual void* GetTextureHandle() const { | 160 virtual void* GetTextureHandle() const { |
| 161 return reinterpret_cast<void*>(resource_id_); | 161 return reinterpret_cast<void*>(resource_id_); |
| 162 } | 162 } |
| 163 | 163 |
| 164 // Gets the texture resource ID. | 164 // Gets the texture resource ID. |
| 165 command_buffer::ResourceID resource_id() const { return resource_id_; } | 165 command_buffer::ResourceId resource_id() const { return resource_id_; } |
| 166 | 166 |
| 167 // Gets a RGBASwizzleIndices that contains a mapping from | 167 // Gets a RGBASwizzleIndices that contains a mapping from |
| 168 // RGBA to the internal format used by the rendering API. | 168 // RGBA to the internal format used by the rendering API. |
| 169 virtual const RGBASwizzleIndices& GetABGR32FSwizzleIndices(); | 169 virtual const RGBASwizzleIndices& GetABGR32FSwizzleIndices(); |
| 170 | 170 |
| 171 protected: | 171 protected: |
| 172 // Overridden from TextureCUBE | 172 // Overridden from TextureCUBE |
| 173 virtual bool PlatformSpecificLock( | 173 virtual bool PlatformSpecificLock( |
| 174 CubeFace face, int level, void** texture_data, int* pitch, | 174 CubeFace face, int level, void** texture_data, int* pitch, |
| 175 AccessMode mode); | 175 AccessMode mode); |
| 176 | 176 |
| 177 // Overridden from TextureCUBE | 177 // Overridden from TextureCUBE |
| 178 virtual bool PlatformSpecificUnlock(CubeFace face, int level); | 178 virtual bool PlatformSpecificUnlock(CubeFace face, int level); |
| 179 | 179 |
| 180 // Overridden from TextureCUBE. | 180 // Overridden from TextureCUBE. |
| 181 virtual RenderSurface::Ref PlatformSpecificGetRenderSurface(CubeFace face, | 181 virtual RenderSurface::Ref PlatformSpecificGetRenderSurface(CubeFace face, |
| 182 int level); | 182 int level); |
| 183 private: | 183 private: |
| 184 // Creates a texture from a pre-existing texture resource. | 184 // Creates a texture from a pre-existing texture resource. |
| 185 TextureCUBECB(ServiceLocator* service_locator, | 185 TextureCUBECB(ServiceLocator* service_locator, |
| 186 command_buffer::ResourceID texture, | 186 command_buffer::ResourceId texture, |
| 187 Texture::Format format, | 187 Texture::Format format, |
| 188 int levels, | 188 int levels, |
| 189 int edge_length, | 189 int edge_length, |
| 190 bool enable_render_surfaces); | 190 bool enable_render_surfaces); |
| 191 | 191 |
| 192 | 192 |
| 193 // Returns true if the backing bitmap has the data for the level. | 193 // Returns true if the backing bitmap has the data for the level. |
| 194 bool HasLevel(CubeFace face, unsigned int level) { | 194 bool HasLevel(CubeFace face, unsigned int level) { |
| 195 DCHECK_LT(level, static_cast<unsigned int>(levels())); | 195 DCHECK_LT(level, static_cast<unsigned int>(levels())); |
| 196 return (has_levels_[face] & (1 << level)) != 0; | 196 return (has_levels_[face] & (1 << level)) != 0; |
| 197 } | 197 } |
| 198 | 198 |
| 199 RendererCB* renderer_; | 199 RendererCB* renderer_; |
| 200 command_buffer::ResourceID resource_id_; | 200 command_buffer::ResourceId resource_id_; |
| 201 | 201 |
| 202 // Bitmaps used to back the NPOT textures on POT-only hardware. | 202 // Bitmaps used to back the NPOT textures on POT-only hardware. |
| 203 Bitmap::Ref backing_bitmaps_[NUMBER_OF_FACES]; | 203 Bitmap::Ref backing_bitmaps_[NUMBER_OF_FACES]; |
| 204 | 204 |
| 205 // Bitfields that indicates mip levels that are currently stored in the | 205 // Bitfields that indicates mip levels that are currently stored in the |
| 206 // backing bitmap, one per face. | 206 // backing bitmap, one per face. |
| 207 unsigned int has_levels_[NUMBER_OF_FACES]; | 207 unsigned int has_levels_[NUMBER_OF_FACES]; |
| 208 | 208 |
| 209 // Bitfields that indicates which levels are currently locked, one per face. | 209 // Bitfields that indicates which levels are currently locked, one per face. |
| 210 unsigned int locked_levels_[NUMBER_OF_FACES]; | 210 unsigned int locked_levels_[NUMBER_OF_FACES]; |
| 211 }; | 211 }; |
| 212 | 212 |
| 213 } // namespace o3d | 213 } // namespace o3d |
| 214 | 214 |
| 215 #endif // O3D_CORE_CROSS_COMMAND_BUFFER_TEXTURE_CB_H_ | 215 #endif // O3D_CORE_CROSS_COMMAND_BUFFER_TEXTURE_CB_H_ |
| OLD | NEW |