| 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 15 matching lines...) Expand all Loading... |
| 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 */ | 30 */ |
| 31 | 31 |
| 32 | 32 |
| 33 // This file contains the definition of the Texture class. | 33 // This file contains the definition of the Texture class. |
| 34 | 34 |
| 35 #include "core/cross/texture_base.h" | 35 #include "core/cross/texture_base.h" |
| 36 |
| 37 #include "core/cross/bitmap.h" |
| 36 #include "core/cross/pack.h" | 38 #include "core/cross/pack.h" |
| 37 #include "core/cross/bitmap.h" | 39 #include "core/cross/renderer.h" |
| 38 | 40 |
| 39 namespace o3d { | 41 namespace o3d { |
| 40 | 42 |
| 41 O3D_DEFN_CLASS(Texture, ParamObject); | 43 O3D_DEFN_CLASS(Texture, ParamObject); |
| 42 O3D_DEFN_CLASS(ParamTexture, RefParamBase); | 44 O3D_DEFN_CLASS(ParamTexture, RefParamBase); |
| 43 | 45 |
| 44 const char* Texture::kLevelsParamName = | 46 const char* Texture::kLevelsParamName = |
| 45 O3D_STRING_CONSTANT("levels"); | 47 O3D_STRING_CONSTANT("levels"); |
| 46 | 48 |
| 47 Texture::Texture(ServiceLocator* service_locator, | 49 Texture::Texture(ServiceLocator* service_locator, |
| 48 Format format, | 50 Format format, |
| 49 int levels, | 51 int levels, |
| 50 bool enable_render_surfaces) | 52 bool enable_render_surfaces) |
| 51 : ParamObject(service_locator), | 53 : ParamObject(service_locator), |
| 54 renderer_(service_locator->GetService<Renderer>()), |
| 52 alpha_is_one_(false), | 55 alpha_is_one_(false), |
| 53 format_(format), | 56 format_(format), |
| 54 weak_pointer_manager_(this), | 57 weak_pointer_manager_(this), |
| 55 render_surfaces_enabled_(enable_render_surfaces) { | 58 render_surfaces_enabled_(enable_render_surfaces), |
| 59 has_unrendered_update_(false), |
| 60 last_render_frame_count_(0), |
| 61 update_count_(0), |
| 62 render_count_(0) { |
| 56 RegisterReadOnlyParamRef(kLevelsParamName, &levels_param_); | 63 RegisterReadOnlyParamRef(kLevelsParamName, &levels_param_); |
| 57 levels_param_->set_read_only_value(levels); | 64 levels_param_->set_read_only_value(levels); |
| 58 } | 65 } |
| 59 | 66 |
| 67 void Texture::TextureUpdated() { |
| 68 CheckLastTextureUpdateRendered(); |
| 69 last_render_frame_count_ = renderer_->render_frame_count(); |
| 70 update_count_++; |
| 71 has_unrendered_update_ = true; |
| 72 } |
| 73 |
| 74 void Texture::CheckLastTextureUpdateRendered() { |
| 75 if (has_unrendered_update_ && |
| 76 renderer_->render_frame_count() != last_render_frame_count_) { |
| 77 // Then a new frame has been rendered to the screen since we last |
| 78 // updated this texture, so that update has been rendered to the screen. |
| 79 render_count_++; |
| 80 has_unrendered_update_ = false; |
| 81 } |
| 82 } |
| 83 |
| 60 ObjectBase::Ref ParamTexture::Create(ServiceLocator* service_locator) { | 84 ObjectBase::Ref ParamTexture::Create(ServiceLocator* service_locator) { |
| 61 return ObjectBase::Ref(new ParamTexture(service_locator, false, false)); | 85 return ObjectBase::Ref(new ParamTexture(service_locator, false, false)); |
| 62 } | 86 } |
| 63 | 87 |
| 64 } // namespace o3d | 88 } // namespace o3d |
| OLD | NEW |