OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/media/webmediaplayer_impl.h" | 5 #include "content/renderer/media/webmediaplayer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 // The cost of getIntegerv is sufficiently high, however, that we want to | 614 // The cost of getIntegerv is sufficiently high, however, that we want to |
615 // avoid it in user builds. As a result assume (below) that |texture| is | 615 // avoid it in user builds. As a result assume (below) that |texture| is |
616 // bound when this method is called, and only verify this fact when | 616 // bound when this method is called, and only verify this fact when |
617 // DCHECK_IS_ON. | 617 // DCHECK_IS_ON. |
618 #if DCHECK_IS_ON | 618 #if DCHECK_IS_ON |
619 GLint bound_texture = 0; | 619 GLint bound_texture = 0; |
620 web_graphics_context->getIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); | 620 web_graphics_context->getIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); |
621 DCHECK_EQ(static_cast<GLuint>(bound_texture), texture); | 621 DCHECK_EQ(static_cast<GLuint>(bound_texture), texture); |
622 #endif | 622 #endif |
623 | 623 |
624 uint32 source_texture = web_graphics_context->createTexture(); | |
625 | |
626 web_graphics_context->waitSyncPoint(mailbox_holder->sync_point); | 624 web_graphics_context->waitSyncPoint(mailbox_holder->sync_point); |
627 web_graphics_context->bindTexture(GL_TEXTURE_2D, source_texture); | 625 uint32 source_texture = web_graphics_context->createAndConsumeTextureCHROMIUM( |
628 web_graphics_context->consumeTextureCHROMIUM(GL_TEXTURE_2D, | 626 GL_TEXTURE_2D, mailbox_holder->mailbox.name); |
629 mailbox_holder->mailbox.name); | |
630 | 627 |
631 // The video is stored in a unmultiplied format, so premultiply | 628 // The video is stored in a unmultiplied format, so premultiply |
632 // if necessary. | 629 // if necessary. |
633 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, | 630 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, |
634 premultiply_alpha); | 631 premultiply_alpha); |
635 // Application itself needs to take care of setting the right flip_y | 632 // Application itself needs to take care of setting the right flip_y |
636 // value down to get the expected result. | 633 // value down to get the expected result. |
637 // flip_y==true means to reverse the video orientation while | 634 // flip_y==true means to reverse the video orientation while |
638 // flip_y==false means to keep the intrinsic orientation. | 635 // flip_y==false means to keep the intrinsic orientation. |
639 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, flip_y); | 636 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, flip_y); |
640 web_graphics_context->copyTextureCHROMIUM(GL_TEXTURE_2D, | 637 web_graphics_context->copyTextureCHROMIUM(GL_TEXTURE_2D, |
641 source_texture, | 638 source_texture, |
642 texture, | 639 texture, |
643 level, | 640 level, |
644 internal_format, | 641 internal_format, |
645 type); | 642 type); |
646 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, false); | 643 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, false); |
647 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, | 644 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, |
648 false); | 645 false); |
649 | 646 |
650 // Restore the state for TEXTURE_2D binding point as mentioned above. | |
651 web_graphics_context->bindTexture(GL_TEXTURE_2D, texture); | |
652 | |
653 web_graphics_context->deleteTexture(source_texture); | 647 web_graphics_context->deleteTexture(source_texture); |
654 web_graphics_context->flush(); | 648 web_graphics_context->flush(); |
655 video_frame->AppendReleaseSyncPoint(web_graphics_context->insertSyncPoint()); | 649 video_frame->AppendReleaseSyncPoint(web_graphics_context->insertSyncPoint()); |
656 return true; | 650 return true; |
657 } | 651 } |
658 | 652 |
659 // Helper functions to report media EME related stats to UMA. They follow the | 653 // Helper functions to report media EME related stats to UMA. They follow the |
660 // convention of more commonly used macros UMA_HISTOGRAM_ENUMERATION and | 654 // convention of more commonly used macros UMA_HISTOGRAM_ENUMERATION and |
661 // UMA_HISTOGRAM_COUNTS. The reason that we cannot use those macros directly is | 655 // UMA_HISTOGRAM_COUNTS. The reason that we cannot use those macros directly is |
662 // that UMA_* macros require the names to be constant throughout the process' | 656 // that UMA_* macros require the names to be constant throughout the process' |
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1358 compositor_task_runner_->PostTask(FROM_HERE, | 1352 compositor_task_runner_->PostTask(FROM_HERE, |
1359 base::Bind(&GetCurrentFrameAndSignal, | 1353 base::Bind(&GetCurrentFrameAndSignal, |
1360 base::Unretained(compositor_), | 1354 base::Unretained(compositor_), |
1361 &video_frame, | 1355 &video_frame, |
1362 &event)); | 1356 &event)); |
1363 event.Wait(); | 1357 event.Wait(); |
1364 return video_frame; | 1358 return video_frame; |
1365 } | 1359 } |
1366 | 1360 |
1367 } // namespace content | 1361 } // namespace content |
OLD | NEW |