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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 // Gets the levels. | 110 // Gets the levels. |
111 int levels() const { | 111 int levels() const { |
112 return levels_param_->value(); | 112 return levels_param_->value(); |
113 } | 113 } |
114 | 114 |
115 // Gets the format of the texture resource. | 115 // Gets the format of the texture resource. |
116 Format format() const { | 116 Format format() const { |
117 return format_; | 117 return format_; |
118 } | 118 } |
119 | 119 |
120 int update_count() { | |
121 return update_count_; | |
122 } | |
123 | |
124 int render_count() { | |
125 CheckLastTextureUpdateRendered(); | |
126 return render_count_; | |
127 } | |
128 | |
120 bool render_surfaces_enabled() const { | 129 bool render_surfaces_enabled() const { |
121 return render_surfaces_enabled_; | 130 return render_surfaces_enabled_; |
122 } | 131 } |
123 | 132 |
124 // Generates mips. | 133 // Generates mips. |
125 virtual void GenerateMips(int source_level, int num_levels) = 0; | 134 virtual void GenerateMips(int source_level, int num_levels) = 0; |
126 | 135 |
127 // Gets a RGBASwizzleIndices that contains a mapping from | 136 // Gets a RGBASwizzleIndices that contains a mapping from |
128 // RGBA to the internal format used by the graphics API. | 137 // RGBA to the internal format used by the graphics API. |
129 virtual const RGBASwizzleIndices& GetABGR32FSwizzleIndices() = 0; | 138 virtual const RGBASwizzleIndices& GetABGR32FSwizzleIndices() = 0; |
130 | 139 |
131 // Gets a weak pointer to us. | 140 // Gets a weak pointer to us. |
132 WeakPointerType GetWeakPointer() const { | 141 WeakPointerType GetWeakPointer() const { |
133 return weak_pointer_manager_.GetWeakPointer(); | 142 return weak_pointer_manager_.GetWeakPointer(); |
134 } | 143 } |
135 | 144 |
136 protected: | 145 protected: |
137 void set_levels(int levels) { | 146 void set_levels(int levels) { |
138 levels_param_->set_read_only_value(levels); | 147 levels_param_->set_read_only_value(levels); |
139 } | 148 } |
140 | 149 |
141 void set_format(Format format) { | 150 void set_format(Format format) { |
142 format_ = format; | 151 format_ = format; |
143 } | 152 } |
144 | 153 |
154 void TextureUpdated(); | |
155 | |
156 // The global renderer. | |
157 Renderer* renderer_; | |
158 | |
zhurunz
2010/12/04 01:29:49
static is better?
Tristan Schmelcher 2
2010/12/06 18:44:59
Static won't work. Technically it's not a global i
| |
145 private: | 159 private: |
160 void CheckLastTextureUpdateRendered(); | |
161 | |
146 // The number of mipmap levels contained in this texture. | 162 // The number of mipmap levels contained in this texture. |
147 ParamInteger::Ref levels_param_; | 163 ParamInteger::Ref levels_param_; |
148 | 164 |
149 // true if all the alpha values in this texture are 1.0. | 165 // true if all the alpha values in this texture are 1.0. |
150 bool alpha_is_one_; | 166 bool alpha_is_one_; |
151 | 167 |
152 // The data format of each pixel. | 168 // The data format of each pixel. |
153 Format format_; | 169 Format format_; |
154 | 170 |
155 // Manager for weak pointers to us. | 171 // Manager for weak pointers to us. |
156 WeakPointerType::WeakPointerManager weak_pointer_manager_; | 172 WeakPointerType::WeakPointerManager weak_pointer_manager_; |
157 | 173 |
158 bool render_surfaces_enabled_; | 174 bool render_surfaces_enabled_; |
159 | 175 |
176 // Counting of frames, to allow the page to determine the framerate of dynamic | |
177 // textures. | |
178 bool has_unrendered_update_; | |
179 int last_render_frame_count_; | |
180 int update_count_; | |
181 int render_count_; | |
182 | |
160 O3D_DECL_CLASS(Texture, ParamObject); | 183 O3D_DECL_CLASS(Texture, ParamObject); |
161 DISALLOW_COPY_AND_ASSIGN(Texture); | 184 DISALLOW_COPY_AND_ASSIGN(Texture); |
162 }; | 185 }; |
163 | 186 |
164 class ParamTexture : public TypedRefParam<Texture> { | 187 class ParamTexture : public TypedRefParam<Texture> { |
165 public: | 188 public: |
166 typedef SmartPointer<ParamTexture> Ref; | 189 typedef SmartPointer<ParamTexture> Ref; |
167 | 190 |
168 ParamTexture(ServiceLocator* service_locator, bool dynamic, bool read_only) | 191 ParamTexture(ServiceLocator* service_locator, bool dynamic, bool read_only) |
169 : TypedRefParam<Texture>(service_locator, dynamic, read_only) {} | 192 : TypedRefParam<Texture>(service_locator, dynamic, read_only) {} |
170 | 193 |
171 private: | 194 private: |
172 friend class IClassManager; | 195 friend class IClassManager; |
173 static ObjectBase::Ref Create(ServiceLocator* service_locator); | 196 static ObjectBase::Ref Create(ServiceLocator* service_locator); |
174 | 197 |
175 O3D_DECL_CLASS(ParamTexture, RefParamBase); | 198 O3D_DECL_CLASS(ParamTexture, RefParamBase); |
176 DISALLOW_COPY_AND_ASSIGN(ParamTexture); | 199 DISALLOW_COPY_AND_ASSIGN(ParamTexture); |
177 }; | 200 }; |
178 | 201 |
179 } // namespace o3d | 202 } // namespace o3d |
180 | 203 |
181 #endif // O3D_CORE_CROSS_TEXTURE_BASE_H_ | 204 #endif // O3D_CORE_CROSS_TEXTURE_BASE_H_ |
OLD | NEW |