Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(439)

Side by Side Diff: media/blink/skcanvas_video_renderer.cc

Issue 972833004: Revert of gpu: introduce glCopySubTextureCHROMIUM (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/blink/skcanvas_video_renderer.h ('k') | media/blink/webmediaplayer_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "media/blink/skcanvas_video_renderer.h" 5 #include "media/blink/skcanvas_video_renderer.h"
6 6
7 #include "gpu/GLES2/gl2extchromium.h" 7 #include "gpu/GLES2/gl2extchromium.h"
8 #include "gpu/command_buffer/client/gles2_interface.h" 8 #include "gpu/command_buffer/client/gles2_interface.h"
9 #include "gpu/command_buffer/common/mailbox_holder.h" 9 #include "gpu/command_buffer/common/mailbox_holder.h"
10 #include "media/base/video_frame.h" 10 #include "media/base/video_frame.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 return false; 137 return false;
138 } 138 }
139 } 139 }
140 140
141 unsigned texture_id = 141 unsigned texture_id =
142 static_cast<unsigned>((bitmap->getTexture())->getTextureHandle()); 142 static_cast<unsigned>((bitmap->getTexture())->getTextureHandle());
143 // If CopyVideoFrameTextureToGLTexture() changes the state of the 143 // If CopyVideoFrameTextureToGLTexture() changes the state of the
144 // |texture_id|, it's needed to invalidate the state cached in skia, 144 // |texture_id|, it's needed to invalidate the state cached in skia,
145 // but currently the state isn't changed. 145 // but currently the state isn't changed.
146 SkCanvasVideoRenderer::CopyVideoFrameTextureToGLTexture( 146 SkCanvasVideoRenderer::CopyVideoFrameTextureToGLTexture(
147 context_3d.gl, video_frame, texture_id, GL_RGBA, GL_UNSIGNED_BYTE, true, 147 context_3d.gl, video_frame, texture_id, 0, GL_RGBA, GL_UNSIGNED_BYTE,
148 false); 148 true, false);
149 bitmap->notifyPixelsChanged(); 149 bitmap->notifyPixelsChanged();
150 return true; 150 return true;
151 } 151 }
152 152
153 class SyncPointClientImpl : public VideoFrame::SyncPointClient { 153 class SyncPointClientImpl : public VideoFrame::SyncPointClient {
154 public: 154 public:
155 explicit SyncPointClientImpl(gpu::gles2::GLES2Interface* gl) : gl_(gl) {} 155 explicit SyncPointClientImpl(gpu::gles2::GLES2Interface* gl) : gl_(gl) {}
156 ~SyncPointClientImpl() override {} 156 ~SyncPointClientImpl() override {}
157 uint32 InsertSyncPoint() override { return gl_->InsertSyncPointCHROMIUM(); } 157 uint32 InsertSyncPoint() override { return gl_->InsertSyncPointCHROMIUM(); }
158 void WaitSyncPoint(uint32 sync_point) override { 158 void WaitSyncPoint(uint32 sync_point) override {
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 case VideoFrame::NV12: 595 case VideoFrame::NV12:
596 NOTREACHED(); 596 NOTREACHED();
597 } 597 }
598 } 598 }
599 599
600 // static 600 // static
601 void SkCanvasVideoRenderer::CopyVideoFrameTextureToGLTexture( 601 void SkCanvasVideoRenderer::CopyVideoFrameTextureToGLTexture(
602 gpu::gles2::GLES2Interface* gl, 602 gpu::gles2::GLES2Interface* gl,
603 VideoFrame* video_frame, 603 VideoFrame* video_frame,
604 unsigned int texture, 604 unsigned int texture,
605 unsigned int level,
605 unsigned int internal_format, 606 unsigned int internal_format,
606 unsigned int type, 607 unsigned int type,
607 bool premultiply_alpha, 608 bool premultiply_alpha,
608 bool flip_y) { 609 bool flip_y) {
609 DCHECK(video_frame && video_frame->format() == VideoFrame::NATIVE_TEXTURE); 610 DCHECK(video_frame && video_frame->format() == VideoFrame::NATIVE_TEXTURE);
610 const gpu::MailboxHolder* mailbox_holder = video_frame->mailbox_holder(); 611 const gpu::MailboxHolder* mailbox_holder = video_frame->mailbox_holder();
611 DCHECK(mailbox_holder->texture_target == GL_TEXTURE_2D || 612 DCHECK(mailbox_holder->texture_target == GL_TEXTURE_2D ||
612 mailbox_holder->texture_target == GL_TEXTURE_RECTANGLE_ARB || 613 mailbox_holder->texture_target == GL_TEXTURE_RECTANGLE_ARB ||
613 mailbox_holder->texture_target == GL_TEXTURE_EXTERNAL_OES); 614 mailbox_holder->texture_target == GL_TEXTURE_EXTERNAL_OES);
614 615
615 gl->WaitSyncPointCHROMIUM(mailbox_holder->sync_point); 616 gl->WaitSyncPointCHROMIUM(mailbox_holder->sync_point);
616 uint32 source_texture = gl->CreateAndConsumeTextureCHROMIUM( 617 uint32 source_texture = gl->CreateAndConsumeTextureCHROMIUM(
617 mailbox_holder->texture_target, mailbox_holder->mailbox.name); 618 mailbox_holder->texture_target, mailbox_holder->mailbox.name);
618 619
619 // The video is stored in a unmultiplied format, so premultiply 620 // The video is stored in a unmultiplied format, so premultiply
620 // if necessary. 621 // if necessary.
621 gl->PixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, premultiply_alpha); 622 gl->PixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, premultiply_alpha);
622 // Application itself needs to take care of setting the right |flip_y| 623 // Application itself needs to take care of setting the right |flip_y|
623 // value down to get the expected result. 624 // value down to get the expected result.
624 // "flip_y == true" means to reverse the video orientation while 625 // "flip_y == true" means to reverse the video orientation while
625 // "flip_y == false" means to keep the intrinsic orientation. 626 // "flip_y == false" means to keep the intrinsic orientation.
626 gl->PixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, flip_y); 627 gl->PixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, flip_y);
627 gl->CopyTextureCHROMIUM(GL_TEXTURE_2D, source_texture, texture, 628 gl->CopyTextureCHROMIUM(GL_TEXTURE_2D, source_texture, texture, level,
628 internal_format, type); 629 internal_format, type);
629 gl->PixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, false); 630 gl->PixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, false);
630 gl->PixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, false); 631 gl->PixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, false);
631 632
632 gl->DeleteTextures(1, &source_texture); 633 gl->DeleteTextures(1, &source_texture);
633 gl->Flush(); 634 gl->Flush();
634 635
635 SyncPointClientImpl client(gl); 636 SyncPointClientImpl client(gl);
636 video_frame->UpdateReleaseSyncPoint(&client); 637 video_frame->UpdateReleaseSyncPoint(&client);
637 } 638 }
638 639
639 void SkCanvasVideoRenderer::ResetLastFrame() { 640 void SkCanvasVideoRenderer::ResetLastFrame() {
640 last_frame_.reset(); 641 last_frame_.reset();
641 last_frame_timestamp_ = media::kNoTimestamp(); 642 last_frame_timestamp_ = media::kNoTimestamp();
642 } 643 }
643 644
644 void SkCanvasVideoRenderer::ResetAcceleratedLastFrame() { 645 void SkCanvasVideoRenderer::ResetAcceleratedLastFrame() {
645 accelerated_last_frame_.reset(); 646 accelerated_last_frame_.reset();
646 accelerated_generator_ = nullptr; 647 accelerated_generator_ = nullptr;
647 accelerated_last_frame_timestamp_ = media::kNoTimestamp(); 648 accelerated_last_frame_timestamp_ = media::kNoTimestamp();
648 } 649 }
649 650
650 } // namespace media 651 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/skcanvas_video_renderer.h ('k') | media/blink/webmediaplayer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698