| 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/video_layer.h" | 10 #include "cc/video_layer.h" |
| 11 #include "content/browser/gpu/gpu_surface_tracker.h" | 11 #include "content/browser/gpu/gpu_surface_tracker.h" |
| 12 #include "content/browser/renderer_host/compositor_impl_android.h" | 12 #include "content/browser/renderer_host/compositor_impl_android.h" |
| 13 #include "content/browser/renderer_host/image_transport_factory_android.h" | 13 #include "content/browser/renderer_host/image_transport_factory_android.h" |
| 14 #include "content/common/android/surface_texture_bridge.h" | 14 #include "content/common/android/surface_texture_bridge.h" |
| 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" | 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" |
| 16 #include "third_party/WebKit/Source/Platform/chromium/public/WebVideoLayer.h" | 16 #include "third_party/WebKit/Source/Platform/chromium/public/WebVideoLayer.h" |
| 17 #include "webkit/compositor_bindings/web_compositor_support_impl.h" | 17 #include "webkit/compositor_bindings/web_compositor_support_impl.h" |
| 18 #include "webkit/media/webvideoframe_impl.h" | 18 #include "webkit/media/webvideoframe_impl.h" |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 static const uint32 kGLTextureExternalOES = 0x8D65; | 22 static const uint32 kGLTextureExternalOES = 0x8D65; |
| 23 | 23 |
| 24 } // anonymous namespace | 24 } // anonymous namespace |
| 25 | 25 |
| 26 namespace content { | 26 namespace content { |
| 27 | 27 |
| 28 SurfaceTextureTransportClient::SurfaceTextureTransportClient() | 28 SurfaceTextureTransportClient::SurfaceTextureTransportClient() |
| 29 : window_(NULL), | 29 : window_(NULL), |
| 30 texture_id_(0) { | 30 texture_id_(0), |
| 31 surface_id_(0) { |
| 31 } | 32 } |
| 32 | 33 |
| 33 SurfaceTextureTransportClient::~SurfaceTextureTransportClient() { | 34 SurfaceTextureTransportClient::~SurfaceTextureTransportClient() { |
| 35 if (surface_id_) { |
| 36 GpuSurfaceTracker::Get()->SetNativeWidget( |
| 37 surface_id_, gfx::kNullAcceleratedWidget); |
| 38 } |
| 34 if (window_) | 39 if (window_) |
| 35 ANativeWindow_release(window_); | 40 ANativeWindow_release(window_); |
| 36 } | 41 } |
| 37 | 42 |
| 38 scoped_refptr<cc::Layer> SurfaceTextureTransportClient::Initialize() { | 43 scoped_refptr<cc::Layer> SurfaceTextureTransportClient::Initialize() { |
| 39 // Use a SurfaceTexture to stream frames to the UI thread. | 44 // Use a SurfaceTexture to stream frames to the UI thread. |
| 40 video_layer_ = cc::VideoLayer::create(this); | 45 video_layer_ = cc::VideoLayer::create(this); |
| 41 | 46 |
| 42 surface_texture_ = new SurfaceTextureBridge(0); | 47 surface_texture_ = new SurfaceTextureBridge(0); |
| 43 surface_texture_->SetFrameAvailableCallback( | 48 surface_texture_->SetFrameAvailableCallback( |
| 44 base::Bind( | 49 base::Bind( |
| 45 &SurfaceTextureTransportClient::OnSurfaceTextureFrameAvailable, | 50 &SurfaceTextureTransportClient::OnSurfaceTextureFrameAvailable, |
| 46 base::Unretained(this))); | 51 base::Unretained(this))); |
| 47 surface_texture_->DetachFromGLContext(); | 52 surface_texture_->DetachFromGLContext(); |
| 48 return video_layer_.get(); | 53 return video_layer_.get(); |
| 49 } | 54 } |
| 50 | 55 |
| 51 gfx::GLSurfaceHandle | 56 gfx::GLSurfaceHandle |
| 52 SurfaceTextureTransportClient::GetCompositingSurface(int surface_id) { | 57 SurfaceTextureTransportClient::GetCompositingSurface(int surface_id) { |
| 53 DCHECK(surface_id); | 58 DCHECK(surface_id); |
| 59 surface_id_ = surface_id; |
| 60 |
| 54 if (!window_) | 61 if (!window_) |
| 55 window_ = surface_texture_->CreateSurface(); | 62 window_ = surface_texture_->CreateSurface(); |
| 56 | 63 |
| 57 GpuSurfaceTracker::Get()->SetNativeWidget(surface_id, window_); | 64 GpuSurfaceTracker::Get()->SetNativeWidget(surface_id, window_); |
| 58 return gfx::GLSurfaceHandle(gfx::kDummyPluginWindow, false); | 65 return gfx::GLSurfaceHandle(gfx::kDummyPluginWindow, false); |
| 59 } | 66 } |
| 60 | 67 |
| 61 void SurfaceTextureTransportClient::SetSize(const gfx::Size& size) { | 68 void SurfaceTextureTransportClient::SetSize(const gfx::Size& size) { |
| 62 surface_texture_->SetDefaultBufferSize(size.width(), size.height()); | 69 surface_texture_->SetDefaultBufferSize(size.width(), size.height()); |
| 63 video_layer_->setBounds(size); | 70 video_layer_->setBounds(size); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 91 | 98 |
| 92 void SurfaceTextureTransportClient::PutCurrentFrame( | 99 void SurfaceTextureTransportClient::PutCurrentFrame( |
| 93 const scoped_refptr<media::VideoFrame>& frame) { | 100 const scoped_refptr<media::VideoFrame>& frame) { |
| 94 } | 101 } |
| 95 | 102 |
| 96 void SurfaceTextureTransportClient::OnSurfaceTextureFrameAvailable() { | 103 void SurfaceTextureTransportClient::OnSurfaceTextureFrameAvailable() { |
| 97 video_layer_->setNeedsDisplay(); | 104 video_layer_->setNeedsDisplay(); |
| 98 } | 105 } |
| 99 | 106 |
| 100 } // namespace content | 107 } // namespace content |
| OLD | NEW |