| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <string.h> | 5 #include <string.h> |
| 6 | 6 |
| 7 #include <iostream> | 7 #include <iostream> |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 #include <list> | 9 #include <list> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 // When decode outpaces render, we queue up decoded pictures for later | 148 // When decode outpaces render, we queue up decoded pictures for later |
| 149 // painting. Elements are <decoder,picture>. | 149 // painting. Elements are <decoder,picture>. |
| 150 std::list<std::pair<PP_Resource, PP_Picture_Dev> > pictures_pending_paint_; | 150 std::list<std::pair<PP_Resource, PP_Picture_Dev> > pictures_pending_paint_; |
| 151 int num_frames_rendered_; | 151 int num_frames_rendered_; |
| 152 PP_TimeTicks first_frame_delivered_ticks_; | 152 PP_TimeTicks first_frame_delivered_ticks_; |
| 153 PP_TimeTicks last_swap_request_ticks_; | 153 PP_TimeTicks last_swap_request_ticks_; |
| 154 PP_TimeTicks swap_ticks_; | 154 PP_TimeTicks swap_ticks_; |
| 155 pp::CompletionCallbackFactory<GLES2DemoInstance> callback_factory_; | 155 pp::CompletionCallbackFactory<GLES2DemoInstance> callback_factory_; |
| 156 | 156 |
| 157 // Unowned pointers. | 157 // Unowned pointers. |
| 158 const struct PPB_Console_Dev* console_if_; | 158 const PPB_Console_Dev* console_if_; |
| 159 const struct PPB_Core* core_if_; | 159 const PPB_Core* core_if_; |
| 160 const struct PPB_OpenGLES2* gles2_if_; | 160 const PPB_OpenGLES2* gles2_if_; |
| 161 | 161 |
| 162 // Owned data. | 162 // Owned data. |
| 163 pp::Graphics3D* context_; | 163 pp::Graphics3D* context_; |
| 164 typedef std::map<int, DecoderClient*> Decoders; | 164 typedef std::map<int, DecoderClient*> Decoders; |
| 165 Decoders video_decoders_; | 165 Decoders video_decoders_; |
| 166 }; | 166 }; |
| 167 | 167 |
| 168 GLES2DemoInstance::DecoderClient::DecoderClient(GLES2DemoInstance* gles2, | 168 GLES2DemoInstance::DecoderClient::DecoderClient(GLES2DemoInstance* gles2, |
| 169 pp::VideoDecoder_Dev* decoder) | 169 pp::VideoDecoder_Dev* decoder) |
| 170 : gles2_(gles2), decoder_(decoder), callback_factory_(this), | 170 : gles2_(gles2), decoder_(decoder), callback_factory_(this), |
| (...skipping 19 matching lines...) Expand all Loading... |
| 190 } | 190 } |
| 191 | 191 |
| 192 GLES2DemoInstance::GLES2DemoInstance(PP_Instance instance, pp::Module* module) | 192 GLES2DemoInstance::GLES2DemoInstance(PP_Instance instance, pp::Module* module) |
| 193 : pp::Instance(instance), pp::Graphics3DClient(this), | 193 : pp::Instance(instance), pp::Graphics3DClient(this), |
| 194 pp::VideoDecoderClient_Dev(this), | 194 pp::VideoDecoderClient_Dev(this), |
| 195 num_frames_rendered_(0), | 195 num_frames_rendered_(0), |
| 196 first_frame_delivered_ticks_(-1), | 196 first_frame_delivered_ticks_(-1), |
| 197 swap_ticks_(0), | 197 swap_ticks_(0), |
| 198 callback_factory_(this), | 198 callback_factory_(this), |
| 199 context_(NULL) { | 199 context_(NULL) { |
| 200 assert((console_if_ = static_cast<const struct PPB_Console_Dev*>( | 200 assert((console_if_ = static_cast<const PPB_Console_Dev*>( |
| 201 module->GetBrowserInterface(PPB_CONSOLE_DEV_INTERFACE)))); | 201 module->GetBrowserInterface(PPB_CONSOLE_DEV_INTERFACE)))); |
| 202 assert((core_if_ = static_cast<const struct PPB_Core*>( | 202 assert((core_if_ = static_cast<const PPB_Core*>( |
| 203 module->GetBrowserInterface(PPB_CORE_INTERFACE)))); | 203 module->GetBrowserInterface(PPB_CORE_INTERFACE)))); |
| 204 assert((gles2_if_ = static_cast<const struct PPB_OpenGLES2*>( | 204 assert((gles2_if_ = static_cast<const PPB_OpenGLES2*>( |
| 205 module->GetBrowserInterface(PPB_OPENGLES2_INTERFACE)))); | 205 module->GetBrowserInterface(PPB_OPENGLES2_INTERFACE)))); |
| 206 } | 206 } |
| 207 | 207 |
| 208 GLES2DemoInstance::~GLES2DemoInstance() { | 208 GLES2DemoInstance::~GLES2DemoInstance() { |
| 209 for (Decoders::iterator it = video_decoders_.begin(); | 209 for (Decoders::iterator it = video_decoders_.begin(); |
| 210 it != video_decoders_.end(); ++it) { | 210 it != video_decoders_.end(); ++it) { |
| 211 delete it->second; | 211 delete it->second; |
| 212 } | 212 } |
| 213 video_decoders_.clear(); | 213 video_decoders_.clear(); |
| 214 delete context_; | 214 delete context_; |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 gles2_if_->DeleteShader(context_->pp_resource(), shader); | 577 gles2_if_->DeleteShader(context_->pp_resource(), shader); |
| 578 } | 578 } |
| 579 } // anonymous namespace | 579 } // anonymous namespace |
| 580 | 580 |
| 581 namespace pp { | 581 namespace pp { |
| 582 // Factory function for your specialization of the Module object. | 582 // Factory function for your specialization of the Module object. |
| 583 Module* CreateModule() { | 583 Module* CreateModule() { |
| 584 return new GLES2DemoModule(); | 584 return new GLES2DemoModule(); |
| 585 } | 585 } |
| 586 } // namespace pp | 586 } // namespace pp |
| OLD | NEW |