| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010, Google Inc. | 2 * Copyright 2010, 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 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 #ifndef O3D_CORE_CROSS_CAIRO_TEXTURE_CAIRO_H_ | 36 #ifndef O3D_CORE_CROSS_CAIRO_TEXTURE_CAIRO_H_ |
| 37 #define O3D_CORE_CROSS_CAIRO_TEXTURE_CAIRO_H_ | 37 #define O3D_CORE_CROSS_CAIRO_TEXTURE_CAIRO_H_ |
| 38 | 38 |
| 39 #include "core/cross/texture.h" | 39 #include "core/cross/texture.h" |
| 40 | 40 |
| 41 namespace o3d { | 41 namespace o3d { |
| 42 | 42 |
| 43 class RendererCairo; | 43 class RendererCairo; |
| 44 | 44 |
| 45 struct TextureResource { |
| 46 // Current Frame Data Source |
| 47 const void* data; |
| 48 // X coordinate |
| 49 unsigned left; |
| 50 // Y coordinate |
| 51 unsigned top; |
| 52 // Current Frame Source Width |
| 53 unsigned width; |
| 54 // Current Frame Source Height |
| 55 unsigned height; |
| 56 // Current Frame Source Pitch |
| 57 int pitch; |
| 58 }; |
| 59 |
| 45 // Texture2DCairo implements the Texture2D interface. | 60 // Texture2DCairo implements the Texture2D interface. |
| 46 class TextureCairo : public Texture2D { | 61 class TextureCairo : public Texture2D { |
| 47 public: | 62 public: |
| 48 typedef SmartPointer<TextureCairo> Ref; | 63 typedef SmartPointer<TextureCairo> Ref; |
| 49 | 64 |
| 50 // Creates a new Texture2DCairo with the given specs. If the texture | 65 // Creates a new Texture2DCairo with the given specs. If the texture |
| 51 // creation fails then it returns NULL otherwise it returns a pointer to the | 66 // creation fails then it returns NULL otherwise it returns a pointer to the |
| 52 // newly created Texture object. | 67 // newly created Texture object. |
| 53 static TextureCairo* Create(ServiceLocator* service_locator, | 68 static TextureCairo* Create(ServiceLocator* service_locator, |
| 54 Texture::Format format, | 69 Texture::Format format, |
| 55 int levels, | 70 int levels, |
| 56 int width, | 71 int width, |
| 57 int height, | 72 int height, |
| 58 bool enable_render_surfaces); | 73 bool enable_render_surfaces); |
| 59 | 74 |
| 60 virtual ~TextureCairo(); | 75 virtual ~TextureCairo(); |
| 61 | 76 |
| 62 // Overridden from Texture2D | 77 // Overridden from Texture2D |
| 63 virtual void SetRect(int level, | 78 virtual void SetRect(int level, |
| 64 unsigned left, | 79 unsigned left, |
| 65 unsigned top, | 80 unsigned top, |
| 66 unsigned width, | 81 unsigned width, |
| 67 unsigned height, | 82 unsigned height, |
| 68 const void* src_data, | 83 const void* src_data, |
| 69 int src_pitch); | 84 int src_pitch); |
| 70 | 85 |
| 86 virtual TextureResource* GetResource(); |
| 87 |
| 71 // Gets a RGBASwizzleIndices that contains a mapping from | 88 // Gets a RGBASwizzleIndices that contains a mapping from |
| 72 // RGBA to the internal format used by the rendering API. | 89 // RGBA to the internal format used by the rendering API. |
| 73 virtual const RGBASwizzleIndices& GetABGR32FSwizzleIndices(); | 90 virtual const RGBASwizzleIndices& GetABGR32FSwizzleIndices(); |
| 74 | 91 |
| 75 protected: | 92 protected: |
| 76 // Overridden from Texture2D | 93 // Overridden from Texture2D |
| 77 virtual bool PlatformSpecificLock(int level, void** texture_data, int* pitch, | 94 virtual bool PlatformSpecificLock(int level, void** texture_data, int* pitch, |
| 78 AccessMode mode); | 95 AccessMode mode); |
| 79 | 96 |
| 80 // Overridden from Texture2D | 97 // Overridden from Texture2D |
| 81 virtual bool PlatformSpecificUnlock(int level); | 98 virtual bool PlatformSpecificUnlock(int level); |
| 82 | 99 |
| 83 // Overridden from Texture2D | 100 // Overridden from Texture2D |
| 84 virtual RenderSurface::Ref PlatformSpecificGetRenderSurface(int mip_level); | 101 virtual RenderSurface::Ref PlatformSpecificGetRenderSurface(int mip_level); |
| 85 | 102 |
| 86 // Returns the implementation-specific texture handle for this texture. | 103 // Returns the implementation-specific texture handle for this texture. |
| 87 virtual void* GetTextureHandle() const; | 104 virtual void* GetTextureHandle() const; |
| 88 | 105 |
| 89 // The 2d renderer object to be used by client | 106 // The 2d renderer object to be used by client. |
| 90 RendererCairo* renderer_; | 107 RendererCairo* renderer_; |
| 91 | 108 |
| 109 // Texture Resource for this particular instance. |
| 110 TextureResource resource_; |
| 111 |
| 92 private: | 112 private: |
| 93 // Initializes the Texture2D. | 113 // Initializes the Texture2D. |
| 94 TextureCairo(ServiceLocator* service_locator, | 114 TextureCairo(ServiceLocator* service_locator, |
| 95 Texture::Format format, | 115 Texture::Format format, |
| 96 int levels, | 116 int levels, |
| 97 int width, | 117 int width, |
| 98 int height, | 118 int height, |
| 99 bool enable_render_surfaces); | 119 bool enable_render_surfaces); |
| 100 }; | 120 }; |
| 101 | 121 |
| 102 } // namespace o3d | 122 } // namespace o3d |
| 103 | 123 |
| 104 #endif // O3D_CORE_CROSS_CAIRO_TEXTURE_CAIRO_H_ | 124 #endif // O3D_CORE_CROSS_CAIRO_TEXTURE_CAIRO_H_ |
| 105 | 125 |
| OLD | NEW |