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 28 matching lines...) Expand all Loading... |
39 | 39 |
40 scoped_refptr<SurfaceTextureBridge> surface_; | 40 scoped_refptr<SurfaceTextureBridge> surface_; |
41 ANativeWindow* window_; | 41 ANativeWindow* window_; |
42 }; | 42 }; |
43 | 43 |
44 } // anonymous namespace | 44 } // anonymous namespace |
45 | 45 |
46 SurfaceTextureTransportClient::SurfaceTextureTransportClient() | 46 SurfaceTextureTransportClient::SurfaceTextureTransportClient() |
47 : window_(NULL), | 47 : window_(NULL), |
48 texture_id_(0), | 48 texture_id_(0), |
| 49 texture_mailbox_sync_point_(0), |
49 surface_id_(0) { | 50 surface_id_(0) { |
50 } | 51 } |
51 | 52 |
52 SurfaceTextureTransportClient::~SurfaceTextureTransportClient() { | 53 SurfaceTextureTransportClient::~SurfaceTextureTransportClient() { |
53 } | 54 } |
54 | 55 |
55 scoped_refptr<cc::Layer> SurfaceTextureTransportClient::Initialize() { | 56 scoped_refptr<cc::Layer> SurfaceTextureTransportClient::Initialize() { |
56 // Use a SurfaceTexture to stream frames to the UI thread. | 57 // Use a SurfaceTexture to stream frames to the UI thread. |
57 video_layer_ = cc::VideoLayer::Create(this); | 58 video_layer_ = cc::VideoLayer::Create(this); |
58 | 59 |
(...skipping 30 matching lines...) Expand all Loading... |
89 } | 90 } |
90 | 91 |
91 scoped_refptr<media::VideoFrame> SurfaceTextureTransportClient:: | 92 scoped_refptr<media::VideoFrame> SurfaceTextureTransportClient:: |
92 GetCurrentFrame() { | 93 GetCurrentFrame() { |
93 if (!texture_id_) { | 94 if (!texture_id_) { |
94 WebKit::WebGraphicsContext3D* context = | 95 WebKit::WebGraphicsContext3D* context = |
95 ImageTransportFactoryAndroid::GetInstance()->GetContext3D(); | 96 ImageTransportFactoryAndroid::GetInstance()->GetContext3D(); |
96 context->makeContextCurrent(); | 97 context->makeContextCurrent(); |
97 texture_id_ = context->createTexture(); | 98 texture_id_ = context->createTexture(); |
98 surface_texture_->AttachToGLContext(texture_id_); | 99 surface_texture_->AttachToGLContext(texture_id_); |
| 100 |
| 101 context->genMailboxCHROMIUM(texture_mailbox_.name); |
| 102 context->bindTexture(kGLTextureExternalOES, texture_id_); |
| 103 context->produceTextureCHROMIUM(kGLTextureExternalOES, |
| 104 texture_mailbox_.name); |
| 105 texture_mailbox_sync_point_ = context->insertSyncPoint(); |
99 } | 106 } |
100 if (!video_frame_) { | 107 if (!video_frame_) { |
101 const gfx::Size size = video_layer_->bounds(); | 108 const gfx::Size size = video_layer_->bounds(); |
102 video_frame_ = media::VideoFrame::WrapNativeTexture( | 109 video_frame_ = media::VideoFrame::WrapNativeTexture( |
103 texture_id_, kGLTextureExternalOES, | 110 texture_mailbox_, |
| 111 texture_mailbox_sync_point_, |
| 112 kGLTextureExternalOES, |
104 size, | 113 size, |
105 gfx::Rect(gfx::Point(), size), | 114 gfx::Rect(gfx::Point(), size), |
106 size, | 115 size, |
107 base::TimeDelta(), | 116 base::TimeDelta(), |
108 media::VideoFrame::ReadPixelsCB(), | 117 media::VideoFrame::ReadPixelsCB(), |
| 118 media::VideoFrame::TextureNoLongerNeededCallback(), |
109 base::Closure()); | 119 base::Closure()); |
110 } | 120 } |
111 surface_texture_->UpdateTexImage(); | 121 surface_texture_->UpdateTexImage(); |
112 | 122 |
113 return video_frame_; | 123 return video_frame_; |
114 } | 124 } |
115 | 125 |
116 void SurfaceTextureTransportClient::PutCurrentFrame( | 126 void SurfaceTextureTransportClient::PutCurrentFrame( |
117 const scoped_refptr<media::VideoFrame>& frame) { | 127 const scoped_refptr<media::VideoFrame>& frame) { |
118 } | 128 } |
119 | 129 |
120 void SurfaceTextureTransportClient::OnSurfaceTextureFrameAvailable() { | 130 void SurfaceTextureTransportClient::OnSurfaceTextureFrameAvailable() { |
121 video_layer_->SetNeedsDisplay(); | 131 video_layer_->SetNeedsDisplay(); |
122 } | 132 } |
123 | 133 |
124 } // namespace content | 134 } // namespace content |
OLD | NEW |