OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/renderer/pepper/video_decoder_shim.h" | 5 #include "content/renderer/pepper/video_decoder_shim.h" |
6 | 6 |
7 #include <GLES2/gl2.h> | 7 #include <GLES2/gl2.h> |
8 #include <GLES2/gl2ext.h> | 8 #include <GLES2/gl2ext.h> |
9 #include <GLES2/gl2extchromium.h> | 9 #include <GLES2/gl2extchromium.h> |
10 | 10 |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 const linked_ptr<PendingFrame>& frame = pending_frames_.front(); | 516 const linked_ptr<PendingFrame>& frame = pending_frames_.front(); |
517 | 517 |
518 TextureIdSet::iterator it = available_textures_.begin(); | 518 TextureIdSet::iterator it = available_textures_.begin(); |
519 uint32_t texture_id = *it; | 519 uint32_t texture_id = *it; |
520 available_textures_.erase(it); | 520 available_textures_.erase(it); |
521 | 521 |
522 uint32_t local_texture_id = texture_id_map_[texture_id]; | 522 uint32_t local_texture_id = texture_id_map_[texture_id]; |
523 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); | 523 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); |
524 gles2->ActiveTexture(GL_TEXTURE0); | 524 gles2->ActiveTexture(GL_TEXTURE0); |
525 gles2->BindTexture(GL_TEXTURE_2D, local_texture_id); | 525 gles2->BindTexture(GL_TEXTURE_2D, local_texture_id); |
| 526 #if !defined(OS_ANDROID) |
| 527 // BGRA is the native texture format, except on Android, where textures |
| 528 // would be uploaded as GL_RGBA. |
526 gles2->TexImage2D(GL_TEXTURE_2D, | 529 gles2->TexImage2D(GL_TEXTURE_2D, |
527 0, | 530 0, |
528 GL_RGBA, | 531 GL_BGRA_EXT, |
529 texture_size_.width(), | 532 texture_size_.width(), |
530 texture_size_.height(), | 533 texture_size_.height(), |
531 0, | 534 0, |
532 GL_RGBA, | 535 GL_BGRA_EXT, |
533 GL_UNSIGNED_BYTE, | 536 GL_UNSIGNED_BYTE, |
534 &frame->argb_pixels.front()); | 537 &frame->argb_pixels.front()); |
| 538 #else |
| 539 #error Not implemented. |
| 540 #endif |
535 | 541 |
536 host_->PictureReady(media::Picture(texture_id, frame->decode_id, | 542 host_->PictureReady(media::Picture(texture_id, frame->decode_id, |
537 frame->visible_rect, false)); | 543 frame->visible_rect, false)); |
538 pending_frames_.pop(); | 544 pending_frames_.pop(); |
539 } | 545 } |
540 | 546 |
541 FlushCommandBuffer(); | 547 FlushCommandBuffer(); |
542 | 548 |
543 if (pending_frames_.empty()) { | 549 if (pending_frames_.empty()) { |
544 // If frames aren't backing up, notify the host of any completed decodes so | 550 // If frames aren't backing up, notify the host of any completed decodes so |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 void VideoDecoderShim::DeleteTexture(uint32_t texture_id) { | 593 void VideoDecoderShim::DeleteTexture(uint32_t texture_id) { |
588 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); | 594 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); |
589 gles2->DeleteTextures(1, &texture_id); | 595 gles2->DeleteTextures(1, &texture_id); |
590 } | 596 } |
591 | 597 |
592 void VideoDecoderShim::FlushCommandBuffer() { | 598 void VideoDecoderShim::FlushCommandBuffer() { |
593 context_provider_->ContextGL()->Flush(); | 599 context_provider_->ContextGL()->Flush(); |
594 } | 600 } |
595 | 601 |
596 } // namespace content | 602 } // namespace content |
OLD | NEW |