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

Unified Diff: media/blink/webmediaplayer_impl.cc

Issue 818853004: Revert of media: Optimize HW Video to 2D Canvas copy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/blink/webmediaplayer_impl.h ('k') | media/blink/webmediaplayer_params.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/blink/webmediaplayer_impl.cc
diff --git a/media/blink/webmediaplayer_impl.cc b/media/blink/webmediaplayer_impl.cc
index 778373b6544951b6bd7f448a52476d1f197f36fa..9f0c53db268226243b0244ab537c6ec8d81fe47f 100644
--- a/media/blink/webmediaplayer_impl.cc
+++ b/media/blink/webmediaplayer_impl.cc
@@ -22,7 +22,8 @@
#include "base/synchronization/waitable_event.h"
#include "cc/blink/web_layer_impl.h"
#include "cc/layers/video_layer.h"
-#include "gpu/blink/webgraphicscontext3d_impl.h"
+#include "gpu/GLES2/gl2extchromium.h"
+#include "gpu/command_buffer/common/mailbox_holder.h"
#include "media/audio/null_audio_sink.h"
#include "media/base/bind_to_current_loop.h"
#include "media/base/cdm_context.h"
@@ -38,6 +39,7 @@
#include "media/blink/webcontentdecryptionmodule_impl.h"
#include "media/blink/webinbandtexttrack_impl.h"
#include "media/blink/webmediaplayer_delegate.h"
+#include "media/blink/webmediaplayer_params.h"
#include "media/blink/webmediaplayer_util.h"
#include "media/blink/webmediasource_impl.h"
#include "media/filters/chunk_demuxer.h"
@@ -78,6 +80,23 @@
// the norms, we think 1/16x to 16x is a safe and useful range for now.
const double kMinRate = 0.0625;
const double kMaxRate = 16.0;
+
+class SyncPointClientImpl : public media::VideoFrame::SyncPointClient {
+ public:
+ explicit SyncPointClientImpl(
+ blink::WebGraphicsContext3D* web_graphics_context)
+ : web_graphics_context_(web_graphics_context) {}
+ ~SyncPointClientImpl() override {}
+ uint32 InsertSyncPoint() override {
+ return web_graphics_context_->insertSyncPoint();
+ }
+ void WaitSyncPoint(uint32 sync_point) override {
+ web_graphics_context_->waitSyncPoint(sync_point);
+ }
+
+ private:
+ blink::WebGraphicsContext3D* web_graphics_context_;
+};
} // namespace
@@ -134,7 +153,6 @@
client_(client),
delegate_(delegate),
defer_load_cb_(params.defer_load_cb()),
- context_3d_cb_(params.context_3d_cb()),
supports_save_(true),
chunk_demuxer_(NULL),
compositor_task_runner_(params.compositor_task_runner()),
@@ -522,18 +540,13 @@
GetCurrentFrameFromCompositor();
gfx::Rect gfx_rect(rect);
- Context3D context_3d;
- if (video_frame.get() &&
- video_frame->format() == VideoFrame::NATIVE_TEXTURE) {
- if (!context_3d_cb_.is_null()) {
- context_3d = context_3d_cb_.Run();
- }
- // GPU Process crashed.
- if (!context_3d.gl)
- return;
- }
- skcanvas_video_renderer_.Paint(video_frame, canvas, gfx_rect, alpha, mode,
- pipeline_metadata_.video_rotation, context_3d);
+
+ skcanvas_video_renderer_.Paint(video_frame,
+ canvas,
+ gfx_rect,
+ alpha,
+ mode,
+ pipeline_metadata_.video_rotation);
}
bool WebMediaPlayerImpl::hasSingleSecurityOrigin() const {
@@ -593,19 +606,43 @@
scoped_refptr<VideoFrame> video_frame =
GetCurrentFrameFromCompositor();
- if (!video_frame.get() ||
- video_frame->format() != VideoFrame::NATIVE_TEXTURE) {
+ if (!video_frame.get())
return false;
- }
-
- // TODO(dshwang): need more elegant way to convert WebGraphicsContext3D to
- // GLES2Interface.
- gpu::gles2::GLES2Interface* gl =
- static_cast<gpu_blink::WebGraphicsContext3DImpl*>(web_graphics_context)
- ->GetGLInterface();
- SkCanvasVideoRenderer::CopyVideoFrameTextureToGLTexture(
- gl, video_frame.get(), texture, level, internal_format, type,
- premultiply_alpha, flip_y);
+ if (video_frame->format() != VideoFrame::NATIVE_TEXTURE)
+ return false;
+
+ const gpu::MailboxHolder* mailbox_holder = video_frame->mailbox_holder();
+ if (mailbox_holder->texture_target != GL_TEXTURE_2D)
+ return false;
+
+ web_graphics_context->waitSyncPoint(mailbox_holder->sync_point);
+ uint32 source_texture = web_graphics_context->createAndConsumeTextureCHROMIUM(
+ GL_TEXTURE_2D, mailbox_holder->mailbox.name);
+
+ // The video is stored in a unmultiplied format, so premultiply
+ // if necessary.
+ web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM,
+ premultiply_alpha);
+ // Application itself needs to take care of setting the right flip_y
+ // value down to get the expected result.
+ // flip_y==true means to reverse the video orientation while
+ // flip_y==false means to keep the intrinsic orientation.
+ web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, flip_y);
+ web_graphics_context->copyTextureCHROMIUM(GL_TEXTURE_2D,
+ source_texture,
+ texture,
+ level,
+ internal_format,
+ type);
+ web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, false);
+ web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM,
+ false);
+
+ web_graphics_context->deleteTexture(source_texture);
+ web_graphics_context->flush();
+
+ SyncPointClientImpl client(web_graphics_context);
+ video_frame->UpdateReleaseSyncPoint(&client);
return true;
}
« no previous file with comments | « media/blink/webmediaplayer_impl.h ('k') | media/blink/webmediaplayer_params.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698