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

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

Issue 1420843005: Revert of "webgl: optimize webgl.texSubImage2D(video) path." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
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/renderers/skcanvas_video_renderer.h" 5 #include "media/renderers/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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 gpu::gles2::GLES2Interface* gl = context_3d.gl; 155 gpu::gles2::GLES2Interface* gl = context_3d.gl;
156 unsigned source_texture = 0; 156 unsigned source_texture = 0;
157 if (mailbox_holder.texture_target != GL_TEXTURE_2D) { 157 if (mailbox_holder.texture_target != GL_TEXTURE_2D) {
158 // TODO(dcastagna): At the moment Skia doesn't support targets different 158 // TODO(dcastagna): At the moment Skia doesn't support targets different
159 // than GL_TEXTURE_2D. Avoid this copy once 159 // than GL_TEXTURE_2D. Avoid this copy once
160 // https://code.google.com/p/skia/issues/detail?id=3868 is addressed. 160 // https://code.google.com/p/skia/issues/detail?id=3868 is addressed.
161 gl->GenTextures(1, &source_texture); 161 gl->GenTextures(1, &source_texture);
162 DCHECK(source_texture); 162 DCHECK(source_texture);
163 gl->BindTexture(GL_TEXTURE_2D, source_texture); 163 gl->BindTexture(GL_TEXTURE_2D, source_texture);
164 SkCanvasVideoRenderer::CopyVideoFrameSingleTextureToGLTexture( 164 SkCanvasVideoRenderer::CopyVideoFrameSingleTextureToGLTexture(
165 gl, video_frame, 165 gl, video_frame, source_texture, GL_RGBA, GL_UNSIGNED_BYTE, true,
166 SkCanvasVideoRenderer::CopyFrameSingleTextureParams( 166 false);
167 SkCanvasVideoRenderer::CopyFrameSingleTextureParams::FullCopy,
168 GL_TEXTURE_2D, source_texture, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0, 0,
169 true, false));
170 } else { 167 } else {
171 gl->WaitSyncPointCHROMIUM(mailbox_holder.sync_point); 168 gl->WaitSyncPointCHROMIUM(mailbox_holder.sync_point);
172 source_texture = gl->CreateAndConsumeTextureCHROMIUM( 169 source_texture = gl->CreateAndConsumeTextureCHROMIUM(
173 mailbox_holder.texture_target, mailbox_holder.mailbox.name); 170 mailbox_holder.texture_target, mailbox_holder.mailbox.name);
174 } 171 }
175 GrBackendTextureDesc desc; 172 GrBackendTextureDesc desc;
176 desc.fFlags = kRenderTarget_GrBackendTextureFlag; 173 desc.fFlags = kRenderTarget_GrBackendTextureFlag;
177 desc.fOrigin = kTopLeft_GrSurfaceOrigin; 174 desc.fOrigin = kTopLeft_GrSurfaceOrigin;
178 desc.fWidth = video_frame->coded_size().width(); 175 desc.fWidth = video_frame->coded_size().width();
179 desc.fHeight = video_frame->coded_size().height(); 176 desc.fHeight = video_frame->coded_size().height();
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 case PIXEL_FORMAT_MT21: 532 case PIXEL_FORMAT_MT21:
536 case PIXEL_FORMAT_UNKNOWN: 533 case PIXEL_FORMAT_UNKNOWN:
537 NOTREACHED(); 534 NOTREACHED();
538 } 535 }
539 } 536 }
540 537
541 // static 538 // static
542 void SkCanvasVideoRenderer::CopyVideoFrameSingleTextureToGLTexture( 539 void SkCanvasVideoRenderer::CopyVideoFrameSingleTextureToGLTexture(
543 gpu::gles2::GLES2Interface* gl, 540 gpu::gles2::GLES2Interface* gl,
544 VideoFrame* video_frame, 541 VideoFrame* video_frame,
545 const CopyFrameSingleTextureParams& params) { 542 unsigned int texture,
543 unsigned int internal_format,
544 unsigned int type,
545 bool premultiply_alpha,
546 bool flip_y) {
546 DCHECK(video_frame); 547 DCHECK(video_frame);
547 DCHECK(video_frame->HasTextures()); 548 DCHECK(video_frame->HasTextures());
548 DCHECK_EQ(1u, VideoFrame::NumPlanes(video_frame->format())); 549 DCHECK_EQ(1u, VideoFrame::NumPlanes(video_frame->format()));
549 550
550 const gpu::MailboxHolder& mailbox_holder = video_frame->mailbox_holder(0); 551 const gpu::MailboxHolder& mailbox_holder = video_frame->mailbox_holder(0);
551 DCHECK(mailbox_holder.texture_target == GL_TEXTURE_2D || 552 DCHECK(mailbox_holder.texture_target == GL_TEXTURE_2D ||
552 mailbox_holder.texture_target == GL_TEXTURE_RECTANGLE_ARB || 553 mailbox_holder.texture_target == GL_TEXTURE_RECTANGLE_ARB ||
553 mailbox_holder.texture_target == GL_TEXTURE_EXTERNAL_OES) 554 mailbox_holder.texture_target == GL_TEXTURE_EXTERNAL_OES)
554 << mailbox_holder.texture_target; 555 << mailbox_holder.texture_target;
555 556
556 gl->WaitSyncPointCHROMIUM(mailbox_holder.sync_point); 557 gl->WaitSyncPointCHROMIUM(mailbox_holder.sync_point);
557 uint32 source_texture = gl->CreateAndConsumeTextureCHROMIUM( 558 uint32 source_texture = gl->CreateAndConsumeTextureCHROMIUM(
558 mailbox_holder.texture_target, mailbox_holder.mailbox.name); 559 mailbox_holder.texture_target, mailbox_holder.mailbox.name);
559 560
560 // The video is stored in a unmultiplied format, so premultiply 561 // The video is stored in a unmultiplied format, so premultiply
561 // if necessary. 562 // if necessary.
562 // Application itself needs to take care of setting the right |flip_y| 563 // Application itself needs to take care of setting the right |flip_y|
563 // value down to get the expected result. 564 // value down to get the expected result.
564 // "flip_y == true" means to reverse the video orientation while 565 // "flip_y == true" means to reverse the video orientation while
565 // "flip_y == false" means to keep the intrinsic orientation. 566 // "flip_y == false" means to keep the intrinsic orientation.
566 if (params.copy_type == CopyFrameSingleTextureParams::FullCopy) { 567 gl->CopyTextureCHROMIUM(GL_TEXTURE_2D, source_texture, texture,
567 DCHECK(!params.xoffset && !params.yoffset); 568 internal_format, type, flip_y, premultiply_alpha,
568 gl->CopyTextureCHROMIUM(params.target, source_texture, params.texture, 569 false);
569 params.internal_format, params.type, params.flip_y,
570 params.premultiply_alpha, false);
571 } else {
572 DCHECK_EQ(static_cast<unsigned int>(GL_FALSE), params.internal_format);
573 DCHECK_EQ(static_cast<unsigned int>(GL_FALSE), params.type);
574 gl->CopySubTextureCHROMIUM(params.target, source_texture, params.texture,
575 params.xoffset, params.yoffset, 0, 0,
576 video_frame->natural_size().width(),
577 video_frame->natural_size().height(),
578 params.flip_y, params.premultiply_alpha, false);
579 }
580 570
581 gl->DeleteTextures(1, &source_texture); 571 gl->DeleteTextures(1, &source_texture);
582 gl->Flush(); 572 gl->Flush();
583 573
584 SyncPointClientImpl client(gl); 574 SyncPointClientImpl client(gl);
585 video_frame->UpdateReleaseSyncPoint(&client); 575 video_frame->UpdateReleaseSyncPoint(&client);
586 } 576 }
587 577
588 void SkCanvasVideoRenderer::ResetCache() { 578 void SkCanvasVideoRenderer::ResetCache() {
589 // Clear cached values. 579 // Clear cached values.
590 last_image_ = nullptr; 580 last_image_ = nullptr;
591 last_timestamp_ = kNoTimestamp(); 581 last_timestamp_ = kNoTimestamp();
592 } 582 }
593 583
594 SkCanvasVideoRenderer::CopyFrameSingleTextureParams::
595 CopyFrameSingleTextureParams(CopyType copy_type,
596 unsigned target,
597 unsigned texture,
598 unsigned internal_format,
599 unsigned type,
600 int level,
601 int xoffset,
602 int yoffset,
603 bool premultiply_alpha,
604 bool flip_y)
605 : copy_type(copy_type),
606 target(target),
607 texture(texture),
608 internal_format(internal_format),
609 type(type),
610 level(level),
611 xoffset(xoffset),
612 yoffset(yoffset),
613 premultiply_alpha(premultiply_alpha),
614 flip_y(flip_y) {}
615
616 } // namespace media 584 } // namespace media
OLDNEW
« no previous file with comments | « media/renderers/skcanvas_video_renderer.h ('k') | third_party/WebKit/Source/core/html/HTMLVideoElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698