Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "content/browser/renderer_host/surface_texture_transport_client_android .h" | 5 #include "content/browser/renderer_host/surface_texture_transport_client_android .h" |
| 6 | 6 |
| 7 #include <android/native_window_jni.h> | 7 #include <android/native_window_jni.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "cc/layers/video_layer.h" | 10 #include "cc/layers/video_layer.h" |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 | 41 |
| 42 scoped_refptr<gfx::SurfaceTextureBridge> surface_; | 42 scoped_refptr<gfx::SurfaceTextureBridge> surface_; |
| 43 ANativeWindow* window_; | 43 ANativeWindow* window_; |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 } // anonymous namespace | 46 } // anonymous namespace |
| 47 | 47 |
| 48 SurfaceTextureTransportClient::SurfaceTextureTransportClient() | 48 SurfaceTextureTransportClient::SurfaceTextureTransportClient() |
| 49 : window_(NULL), | 49 : window_(NULL), |
| 50 texture_id_(0), | 50 texture_id_(0), |
| 51 texture_mailbox_sync_point_(0), | |
| 51 surface_id_(0), | 52 surface_id_(0), |
| 52 weak_factory_(this) { | 53 weak_factory_(this) { |
| 53 } | 54 } |
| 54 | 55 |
| 55 SurfaceTextureTransportClient::~SurfaceTextureTransportClient() { | 56 SurfaceTextureTransportClient::~SurfaceTextureTransportClient() { |
| 56 } | 57 } |
| 57 | 58 |
| 58 scoped_refptr<cc::Layer> SurfaceTextureTransportClient::Initialize() { | 59 scoped_refptr<cc::Layer> SurfaceTextureTransportClient::Initialize() { |
| 59 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 60 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 60 // Use a SurfaceTexture to stream frames to the UI thread. | 61 // Use a SurfaceTexture to stream frames to the UI thread. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 scoped_refptr<media::VideoFrame> SurfaceTextureTransportClient:: | 98 scoped_refptr<media::VideoFrame> SurfaceTextureTransportClient:: |
| 98 GetCurrentFrame() { | 99 GetCurrentFrame() { |
| 99 if (!texture_id_) { | 100 if (!texture_id_) { |
| 100 WebKit::WebGraphicsContext3D* context = | 101 WebKit::WebGraphicsContext3D* context = |
| 101 ImageTransportFactoryAndroid::GetInstance()->GetContext3D(); | 102 ImageTransportFactoryAndroid::GetInstance()->GetContext3D(); |
| 102 context->makeContextCurrent(); | 103 context->makeContextCurrent(); |
| 103 texture_id_ = context->createTexture(); | 104 texture_id_ = context->createTexture(); |
| 104 context->bindTexture(GL_TEXTURE_EXTERNAL_OES, texture_id_); | 105 context->bindTexture(GL_TEXTURE_EXTERNAL_OES, texture_id_); |
| 105 context->flush(); | 106 context->flush(); |
| 106 surface_texture_->AttachToGLContext(); | 107 surface_texture_->AttachToGLContext(); |
| 108 | |
| 109 context->genMailboxCHROMIUM(texture_mailbox_.name); | |
| 110 context->bindTexture(kGLTextureExternalOES, texture_id_); | |
|
piman
2013/06/14 21:47:29
nit: you just bound above.
danakj
2013/06/14 21:54:39
Done.
| |
| 111 context->produceTextureCHROMIUM(kGLTextureExternalOES, | |
| 112 texture_mailbox_.name); | |
| 113 texture_mailbox_sync_point_ = context->insertSyncPoint(); | |
| 107 } | 114 } |
| 108 if (!video_frame_.get()) { | 115 if (!video_frame_.get()) { |
| 109 const gfx::Size size = video_layer_->bounds(); | 116 const gfx::Size size = video_layer_->bounds(); |
| 110 video_frame_ = media::VideoFrame::WrapNativeTexture( | 117 video_frame_ = media::VideoFrame::WrapNativeTexture( |
| 111 texture_id_, kGLTextureExternalOES, | 118 texture_mailbox_, |
| 119 texture_mailbox_sync_point_, | |
| 120 kGLTextureExternalOES, | |
| 112 size, | 121 size, |
| 113 gfx::Rect(gfx::Point(), size), | 122 gfx::Rect(gfx::Point(), size), |
| 114 size, | 123 size, |
| 115 base::TimeDelta(), | 124 base::TimeDelta(), |
| 116 media::VideoFrame::ReadPixelsCB(), | 125 media::VideoFrame::ReadPixelsCB(), |
| 126 media::VideoFrame::TextureNoLongerNeededCallback(), | |
| 117 base::Closure()); | 127 base::Closure()); |
| 118 } | 128 } |
| 119 surface_texture_->UpdateTexImage(); | 129 surface_texture_->UpdateTexImage(); |
| 120 | 130 |
| 121 return video_frame_; | 131 return video_frame_; |
| 122 } | 132 } |
| 123 | 133 |
| 124 void SurfaceTextureTransportClient::PutCurrentFrame( | 134 void SurfaceTextureTransportClient::PutCurrentFrame( |
| 125 const scoped_refptr<media::VideoFrame>& frame) { | 135 const scoped_refptr<media::VideoFrame>& frame) { |
| 126 } | 136 } |
| 127 | 137 |
| 128 void SurfaceTextureTransportClient::OnSurfaceTextureFrameAvailable() { | 138 void SurfaceTextureTransportClient::OnSurfaceTextureFrameAvailable() { |
| 129 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 139 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 130 video_layer_->SetNeedsDisplay(); | 140 video_layer_->SetNeedsDisplay(); |
| 131 } | 141 } |
| 132 | 142 |
| 133 } // namespace content | 143 } // namespace content |
| OLD | NEW |