Chromium Code Reviews| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 | 78 |
| 79 // Callbacks passed into pp:VideoDecoder_Dev functions. | 79 // Callbacks passed into pp:VideoDecoder_Dev functions. |
| 80 void DecoderInitDone(int32_t result); | 80 void DecoderInitDone(int32_t result); |
| 81 void DecoderBitstreamDone(int32_t result, int bitstream_buffer_id); | 81 void DecoderBitstreamDone(int32_t result, int bitstream_buffer_id); |
| 82 void DecoderFlushDone(int32_t result); | 82 void DecoderFlushDone(int32_t result); |
| 83 | 83 |
| 84 // Decode helpers. | 84 // Decode helpers. |
| 85 void DecodeNextNALUs(); | 85 void DecodeNextNALUs(); |
| 86 void DecodeNextNALU(); | 86 void DecodeNextNALU(); |
| 87 void GetNextNALUBoundary(size_t start_pos, size_t* end_pos); | 87 void GetNextNALUBoundary(size_t start_pos, size_t* end_pos); |
| 88 void PaintPicture(const PP_Picture_Dev& picture); | |
| 88 void Render(const PP_PictureBuffer_Dev& buffer); | 89 void Render(const PP_PictureBuffer_Dev& buffer); |
| 89 void DeleteOutstandingBitstreamBuffers(); | 90 void DeleteOutstandingBitstreamBuffers(); |
| 90 | 91 |
| 91 // GL-related functions. | 92 // GL-related functions. |
| 92 void InitGL(); | 93 void InitGL(); |
| 93 GLuint CreateTexture(int32_t width, int32_t height); | 94 GLuint CreateTexture(int32_t width, int32_t height); |
| 94 void CreateGLObjects(); | 95 void CreateGLObjects(); |
| 95 void CreateShader(GLuint program, GLenum type, const char* source, int size); | 96 void CreateShader(GLuint program, GLenum type, const char* source, int size); |
| 96 void DeleteTexture(GLuint id); | 97 void DeleteTexture(GLuint id); |
| 97 void DeleteOutstandingTextures(); | 98 void DeleteOutstandingTextures(); |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 317 assert(decoder == video_decoder_->pp_resource()); | 318 assert(decoder == video_decoder_->pp_resource()); |
| 318 PictureBufferMap::iterator it = buffers_by_id_.find(picture_buffer_id); | 319 PictureBufferMap::iterator it = buffers_by_id_.find(picture_buffer_id); |
| 319 assert(it != buffers_by_id_.end()); | 320 assert(it != buffers_by_id_.end()); |
| 320 DeleteTexture(it->second.texture_id); | 321 DeleteTexture(it->second.texture_id); |
| 321 buffers_by_id_.erase(it); | 322 buffers_by_id_.erase(it); |
| 322 } | 323 } |
| 323 | 324 |
| 324 void GLES2DemoInstance::PictureReady(PP_Resource decoder, | 325 void GLES2DemoInstance::PictureReady(PP_Resource decoder, |
| 325 const PP_Picture_Dev& picture) { | 326 const PP_Picture_Dev& picture) { |
| 326 assert(decoder == video_decoder_->pp_resource()); | 327 assert(decoder == video_decoder_->pp_resource()); |
| 328 PaintPicture(picture); | |
| 329 } | |
| 330 | |
| 331 void GLES2DemoInstance::PaintPicture(const PP_Picture_Dev& picture) { | |
| 327 if (first_frame_delivered_ticks_ == -1) | 332 if (first_frame_delivered_ticks_ == -1) |
| 328 assert((first_frame_delivered_ticks_ = core_if_->GetTimeTicks()) != -1); | 333 assert((first_frame_delivered_ticks_ = core_if_->GetTimeTicks()) != -1); |
| 329 if (is_painting_) { | 334 if (is_painting_) { |
| 330 pictures_pending_paint_.push_back(picture); | 335 pictures_pending_paint_.push_back(picture); |
| 331 return; | 336 return; |
| 332 } | 337 } |
| 333 PictureBufferMap::iterator it = | 338 PictureBufferMap::iterator it = |
| 334 buffers_by_id_.find(picture.picture_buffer_id); | 339 buffers_by_id_.find(picture.picture_buffer_id); |
| 335 assert(it != buffers_by_id_.end()); | 340 assert(it != buffers_by_id_.end()); |
| 336 Render(it->second); | 341 Render(it->second); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 381 gles2_if_->Clear(context_->pp_resource(), GL_COLOR_BUFFER_BIT); | 386 gles2_if_->Clear(context_->pp_resource(), GL_COLOR_BUFFER_BIT); |
| 382 gles2_if_->Viewport(context_->pp_resource(), 0, 0, | 387 gles2_if_->Viewport(context_->pp_resource(), 0, 0, |
| 383 position_size_.width(), position_size_.height()); | 388 position_size_.width(), position_size_.height()); |
| 384 | 389 |
| 385 assert(BindGraphics(*surface_)); | 390 assert(BindGraphics(*surface_)); |
| 386 assertNoGLError(); | 391 assertNoGLError(); |
| 387 | 392 |
| 388 CreateGLObjects(); | 393 CreateGLObjects(); |
| 389 } | 394 } |
| 390 | 395 |
| 391 void GLES2DemoInstance::Render(const PP_PictureBuffer_Dev& buffer) { | 396 void GLES2DemoInstance::Render(const PP_PictureBuffer_Dev& buffer) { |
|
Ami GONE FROM CHROMIUM
2011/08/09 22:25:16
From offline convo:
- inline Render into PaintPict
vrk (LEFT CHROMIUM)
2011/08/09 22:44:39
Done.
| |
| 392 assert(!is_painting_); | 397 assert(!is_painting_); |
| 393 is_painting_ = true; | 398 is_painting_ = true; |
| 394 gles2_if_->ActiveTexture(context_->pp_resource(), GL_TEXTURE0); | 399 gles2_if_->ActiveTexture(context_->pp_resource(), GL_TEXTURE0); |
| 395 gles2_if_->BindTexture( | 400 gles2_if_->BindTexture( |
| 396 context_->pp_resource(), GL_TEXTURE_2D, buffer.texture_id); | 401 context_->pp_resource(), GL_TEXTURE_2D, buffer.texture_id); |
| 397 gles2_if_->DrawArrays(context_->pp_resource(), GL_TRIANGLE_STRIP, 0, 4); | 402 gles2_if_->DrawArrays(context_->pp_resource(), GL_TRIANGLE_STRIP, 0, 4); |
| 398 pp::CompletionCallback cb = | 403 pp::CompletionCallback cb = |
| 399 callback_factory_.NewCallback( | 404 callback_factory_.NewCallback( |
| 400 &GLES2DemoInstance::PaintFinished, buffer.id); | 405 &GLES2DemoInstance::PaintFinished, buffer.id); |
| 401 last_swap_request_ticks_ = core_if_->GetTimeTicks(); | 406 last_swap_request_ticks_ = core_if_->GetTimeTicks(); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 412 double ms_per_swap = (swap_ticks_ * 1e3) / num_frames_rendered_; | 417 double ms_per_swap = (swap_ticks_ * 1e3) / num_frames_rendered_; |
| 413 LogError(this).s() << "Rendered frames: " << num_frames_rendered_ | 418 LogError(this).s() << "Rendered frames: " << num_frames_rendered_ |
| 414 << ", fps: " << fps << ", with average ms/swap of: " | 419 << ", fps: " << fps << ", with average ms/swap of: " |
| 415 << ms_per_swap; | 420 << ms_per_swap; |
| 416 } | 421 } |
| 417 if (video_decoder_) | 422 if (video_decoder_) |
| 418 video_decoder_->ReusePictureBuffer(picture_buffer_id); | 423 video_decoder_->ReusePictureBuffer(picture_buffer_id); |
| 419 while (!pictures_pending_paint_.empty() && !is_painting_) { | 424 while (!pictures_pending_paint_.empty() && !is_painting_) { |
| 420 PP_Picture_Dev picture = pictures_pending_paint_.front(); | 425 PP_Picture_Dev picture = pictures_pending_paint_.front(); |
| 421 pictures_pending_paint_.pop_front(); | 426 pictures_pending_paint_.pop_front(); |
| 422 PictureReady(video_decoder_->pp_resource(), picture); | 427 PaintPicture(picture); |
| 423 } | 428 } |
| 424 } | 429 } |
| 425 | 430 |
| 426 GLuint GLES2DemoInstance::CreateTexture(int32_t width, int32_t height) { | 431 GLuint GLES2DemoInstance::CreateTexture(int32_t width, int32_t height) { |
| 427 GLuint texture_id; | 432 GLuint texture_id; |
| 428 gles2_if_->GenTextures(context_->pp_resource(), 1, &texture_id); | 433 gles2_if_->GenTextures(context_->pp_resource(), 1, &texture_id); |
| 429 assertNoGLError(); | 434 assertNoGLError(); |
| 430 // Assign parameters. | 435 // Assign parameters. |
| 431 gles2_if_->ActiveTexture(context_->pp_resource(), GL_TEXTURE0); | 436 gles2_if_->ActiveTexture(context_->pp_resource(), GL_TEXTURE0); |
| 432 gles2_if_->BindTexture( | 437 gles2_if_->BindTexture( |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 528 gles2_if_->DeleteShader(context_->pp_resource(), shader); | 533 gles2_if_->DeleteShader(context_->pp_resource(), shader); |
| 529 } | 534 } |
| 530 } // anonymous namespace | 535 } // anonymous namespace |
| 531 | 536 |
| 532 namespace pp { | 537 namespace pp { |
| 533 // Factory function for your specialization of the Module object. | 538 // Factory function for your specialization of the Module object. |
| 534 Module* CreateModule() { | 539 Module* CreateModule() { |
| 535 return new GLES2DemoModule(); | 540 return new GLES2DemoModule(); |
| 536 } | 541 } |
| 537 } // namespace pp | 542 } // namespace pp |
| OLD | NEW |