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 23 matching lines...) Expand all Loading... |
34 #define O3D_CORE_CROSS_TEXTURE_H_ | 34 #define O3D_CORE_CROSS_TEXTURE_H_ |
35 | 35 |
36 #include <vector> | 36 #include <vector> |
37 | 37 |
38 #include "core/cross/render_surface.h" | 38 #include "core/cross/render_surface.h" |
39 #include "core/cross/texture_base.h" | 39 #include "core/cross/texture_base.h" |
40 | 40 |
41 namespace o3d { | 41 namespace o3d { |
42 | 42 |
43 class Pack; | 43 class Pack; |
| 44 class Bitmap; |
44 | 45 |
45 // An abstract class for 2D textures that defines the interface for getting | 46 // An abstract class for 2D textures that defines the interface for getting |
46 // the dimensions of the texture and number of mipmap levels. | 47 // the dimensions of the texture and number of mipmap levels. |
47 // Concrete implementations should implement the Lock and Unlock methods. | 48 // Concrete implementations should implement the Lock and Unlock methods. |
48 class Texture2D : public Texture { | 49 class Texture2D : public Texture { |
49 public: | 50 public: |
50 typedef SmartPointer<Texture2D> Ref; | 51 typedef SmartPointer<Texture2D> Ref; |
51 Texture2D(ServiceLocator* service_locator, | 52 Texture2D(ServiceLocator* service_locator, |
52 int width, | 53 int width, |
53 int height, | 54 int height, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 virtual bool Unlock(int level) = 0; | 90 virtual bool Unlock(int level) = 0; |
90 | 91 |
91 // Returns a RenderSurface object associated with a mip_level of a texture. | 92 // Returns a RenderSurface object associated with a mip_level of a texture. |
92 // Parameters: | 93 // Parameters: |
93 // mip_level: [in] The mip-level of the surface to be returned. | 94 // mip_level: [in] The mip-level of the surface to be returned. |
94 // pack: [in] The pack in which the surface will reside. | 95 // pack: [in] The pack in which the surface will reside. |
95 // Returns: | 96 // Returns: |
96 // Reference to the RenderSurface object. | 97 // Reference to the RenderSurface object. |
97 virtual RenderSurface::Ref GetRenderSurface(int mip_level, Pack* pack) = 0; | 98 virtual RenderSurface::Ref GetRenderSurface(int mip_level, Pack* pack) = 0; |
98 | 99 |
| 100 // Copy pixels from source bitmap to certain mip level. |
| 101 // Scales if the width and height of source and dest do not match. |
| 102 // Parameters: |
| 103 // source_img: source bitmap which would be drawn. |
| 104 // source_x: x-coordinate of the starting pixel in the source image. |
| 105 // source_y: y-coordinate of the starting pixel in the source image. |
| 106 // source_width: width of the source image to draw. |
| 107 // source_height: Height of the source image to draw. |
| 108 // dest_x: x-coordinate of the starting pixel in the dest image. |
| 109 // dest_y: y-coordinate of the starting pixel in the dest image. |
| 110 // dest_width: width of the dest image. |
| 111 // dest_height: height of the dest image. |
| 112 // dest_mip: on which mip level the sourceImg would be drawn. |
| 113 void DrawImage(Bitmap* source_img, int source_x, int source_y, |
| 114 int source_width, int source_height, |
| 115 int dest_x, int dest_y, |
| 116 int dest_width, int dest_height, int dest_mip); |
| 117 |
99 protected: | 118 protected: |
100 // Returns true if the mip-map level has been locked. | 119 // Returns true if the mip-map level has been locked. |
101 bool IsLocked(unsigned int level) { | 120 bool IsLocked(unsigned int level) { |
102 DCHECK_LT(static_cast<int>(level), levels()); | 121 DCHECK_LT(static_cast<int>(level), levels()); |
103 return (locked_levels_ & (1 << level)) != 0; | 122 return (locked_levels_ & (1 << level)) != 0; |
104 } | 123 } |
105 | 124 |
106 // Bitfield that indicates mip levels that are currently locked. | 125 // Bitfield that indicates mip levels that are currently locked. |
107 unsigned int locked_levels_; | 126 unsigned int locked_levels_; |
108 | 127 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 // Parameters: | 220 // Parameters: |
202 // face: [in] The cube face from which to extract the surface. | 221 // face: [in] The cube face from which to extract the surface. |
203 // mip_level: [in] The mip-level of the surface to be returned. | 222 // mip_level: [in] The mip-level of the surface to be returned. |
204 // pack: [in] The pack in which the surface will reside. | 223 // pack: [in] The pack in which the surface will reside. |
205 // Returns: | 224 // Returns: |
206 // Reference to the RenderSurface object. | 225 // Reference to the RenderSurface object. |
207 virtual RenderSurface::Ref GetRenderSurface(CubeFace face, | 226 virtual RenderSurface::Ref GetRenderSurface(CubeFace face, |
208 int level, | 227 int level, |
209 Pack* pack) = 0; | 228 Pack* pack) = 0; |
210 | 229 |
| 230 // Copy pixels from source bitmap to certain mip level. |
| 231 // Scales if the width and height of source and dest do not match. |
| 232 // Parameters: |
| 233 // source_img: source bitmap which would be drawn. |
| 234 // source_x: x-coordinate of the starting pixel in the source image. |
| 235 // source_y: y-coordinate of the starting pixel in the source image. |
| 236 // source_width: width of the source image to draw. |
| 237 // source_height: Height of the source image to draw. |
| 238 // dest_x: x-coordinate of the starting pixel in the dest image. |
| 239 // dest_y: y-coordinate of the starting pixel in the dest image. |
| 240 // dest_width: width of the dest image. |
| 241 // dest_height: height of the dest image. |
| 242 // face: on which face the sourceImg would be drawn. |
| 243 // dest_mip: on which mip level the sourceImg would be drawn. |
| 244 void DrawImage(Bitmap* source_img, int source_x, int source_y, |
| 245 int source_width, int source_height, |
| 246 int dest_x, int dest_y, int dest_width, |
| 247 int dest_height, CubeFace face, int dest_mip); |
| 248 |
211 protected: | 249 protected: |
212 // Returns true if the mip-map level has been locked. | 250 // Returns true if the mip-map level has been locked. |
213 bool IsLocked(unsigned int level, CubeFace face) { | 251 bool IsLocked(unsigned int level, CubeFace face) { |
214 DCHECK_LT(static_cast<int>(level), levels()); | 252 DCHECK_LT(static_cast<int>(level), levels()); |
215 return (locked_levels_[face] & (1 << level)) != 0; | 253 return (locked_levels_[face] & (1 << level)) != 0; |
216 } | 254 } |
217 | 255 |
218 // Bitfields that indicates mip levels that are currently locked, one per | 256 // Bitfields that indicates mip levels that are currently locked, one per |
219 // face. | 257 // face. |
220 unsigned int locked_levels_[NUMBER_OF_FACES]; | 258 unsigned int locked_levels_[NUMBER_OF_FACES]; |
221 | 259 |
222 private: | 260 private: |
223 friend class IClassManager; | 261 friend class IClassManager; |
224 static ObjectBase::Ref Create(ServiceLocator* service_locator); | 262 static ObjectBase::Ref Create(ServiceLocator* service_locator); |
225 | 263 |
226 // The length of each edge of the cube, in texels. | 264 // The length of each edge of the cube, in texels. |
227 ParamInteger::Ref edge_length_param_; | 265 ParamInteger::Ref edge_length_param_; |
228 | 266 |
229 O3D_DECL_CLASS(TextureCUBE, Texture); | 267 O3D_DECL_CLASS(TextureCUBE, Texture); |
230 DISALLOW_COPY_AND_ASSIGN(TextureCUBE); | 268 DISALLOW_COPY_AND_ASSIGN(TextureCUBE); |
231 }; | 269 }; |
232 | 270 |
233 } // namespace o3d | 271 } // namespace o3d |
234 | 272 |
235 #endif // O3D_CORE_CROSS_TEXTURE_H_ | 273 #endif // O3D_CORE_CROSS_TEXTURE_H_ |
OLD | NEW |