OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2010, Google Inc. |
| 3 * All rights reserved. |
| 4 * |
| 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are |
| 7 * met: |
| 8 * |
| 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. |
| 11 * * Redistributions in binary form must reproduce the above |
| 12 * copyright notice, this list of conditions and the following disclaimer |
| 13 * in the documentation and/or other materials provided with the |
| 14 * distribution. |
| 15 * * Neither the name of Google Inc. nor the names of its |
| 16 * contributors may be used to endorse or promote products derived from |
| 17 * this software without specific prior written permission. |
| 18 * |
| 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 */ |
| 31 |
| 32 // An alternative class of Transform for 2d Image Rendering Mode. |
| 33 |
| 34 #ifndef O3D_CORE_CROSS_CAIRO_IMAGE_2D_H_ |
| 35 #define O3D_CORE_CROSS_CAIRO_IMAGE_2D_H_ |
| 36 |
| 37 #include <vector> |
| 38 #include "core/cross/param_object.h" |
| 39 #include "core/cross/param.h" |
| 40 #include "core/cross/types.h" |
| 41 #include "core/cross/param_cache.h" |
| 42 #include "core/cross/bounding_box.h" |
| 43 #include "core/cross/cairo/texture_cairo.h" |
| 44 |
| 45 namespace o3d { |
| 46 |
| 47 class Image2D : public ParamObject { |
| 48 friend class Client; |
| 49 public: |
| 50 typedef WeakPointer<Image2D> WeakPointerType; |
| 51 |
| 52 const void* src_data_; |
| 53 |
| 54 int src_pitch_; |
| 55 |
| 56 int src_width_; |
| 57 |
| 58 int src_height_; |
| 59 |
| 60 int dest_x_; |
| 61 |
| 62 int dest_y_; |
| 63 |
| 64 float alpha_; |
| 65 |
| 66 float scale_x_; |
| 67 |
| 68 float scale_y_; |
| 69 |
| 70 float translate_x_; |
| 71 |
| 72 float translate_y_; |
| 73 |
| 74 // Set the corresponding texture for this Image2D instance. |
| 75 void SetTexture(Texture* texture) { |
| 76 texture_ = down_cast<TextureCairo*>(texture); |
| 77 } |
| 78 |
| 79 // Set the transparency of the Image2D. |
| 80 void SetAlpha(float alpha) { alpha_ = alpha; } |
| 81 |
| 82 // Set the origin x,y of this Image2D. |
| 83 void SetDest(float x, float y) { |
| 84 dest_x_ = x; |
| 85 dest_y_ = y; |
| 86 } |
| 87 |
| 88 // Translate the given x,y from its origin. |
| 89 void Translate(float x, float y) { |
| 90 translate_x_ = x; |
| 91 translate_y_ = y; |
| 92 } |
| 93 |
| 94 |
| 95 // Scale the image to the given x,y. |
| 96 void Scale(float x, float y) { |
| 97 scale_x_ = x; |
| 98 scale_y_ = y; |
| 99 } |
| 100 |
| 101 // Update TextureResource to have the latest data. |
| 102 void updateTextureResource(); |
| 103 |
| 104 // Gets a weak pointer to us. |
| 105 WeakPointerType GetWeakPointer() const { |
| 106 return weak_pointer_manager_.GetWeakPointer(); |
| 107 } |
| 108 |
| 109 private: |
| 110 explicit Image2D(ServiceLocator* service_locator); |
| 111 |
| 112 friend class IClassManager; |
| 113 static ObjectBase::Ref Create(ServiceLocator* service_locator); |
| 114 |
| 115 // Texture Container. |
| 116 TextureCairo* texture_; |
| 117 |
| 118 // Caches of Params for rendering. |
| 119 ParamCacheManager param_cache_manager_; |
| 120 |
| 121 // Manager for weak pointers to us. |
| 122 WeakPointerType::WeakPointerManager weak_pointer_manager_; |
| 123 |
| 124 O3D_DECL_CLASS(Image2D, ParamObject) |
| 125 }; // Image2D |
| 126 |
| 127 } // namespace o3d |
| 128 |
| 129 #endif /* O3D_CORE_CROSS_CAIRO_IMAGE_2D_H_ */ |
| 130 |
OLD | NEW |