OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/renderer/media/android/stream_texture_factory_android_synchron ous_impl.h" | 5 #include "content/renderer/media/android/stream_texture_factory_android_synchron ous_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 } // namespace | 117 } // namespace |
118 | 118 |
119 StreamTextureFactorySynchronousImpl::StreamTextureFactorySynchronousImpl( | 119 StreamTextureFactorySynchronousImpl::StreamTextureFactorySynchronousImpl( |
120 ContextProvider* context_provider, | 120 ContextProvider* context_provider, |
121 int view_id) | 121 int view_id) |
122 : context_provider_(context_provider), view_id_(view_id) {} | 122 : context_provider_(context_provider), view_id_(view_id) {} |
123 | 123 |
124 StreamTextureFactorySynchronousImpl::~StreamTextureFactorySynchronousImpl() {} | 124 StreamTextureFactorySynchronousImpl::~StreamTextureFactorySynchronousImpl() {} |
125 | 125 |
126 StreamTextureProxy* StreamTextureFactorySynchronousImpl::CreateProxy() { | 126 StreamTextureProxy* StreamTextureFactorySynchronousImpl::CreateProxy() { |
127 if (!context_provider_) | |
128 return NULL; | |
127 return new StreamTextureProxyImpl(context_provider_); | 129 return new StreamTextureProxyImpl(context_provider_); |
128 } | 130 } |
129 | 131 |
130 void StreamTextureFactorySynchronousImpl::EstablishPeer(int32 stream_id, | 132 void StreamTextureFactorySynchronousImpl::EstablishPeer(int32 stream_id, |
131 int player_id) { | 133 int player_id) { |
134 DCHECK(context_provider_); | |
132 scoped_refptr<gfx::SurfaceTexture> surface_texture = | 135 scoped_refptr<gfx::SurfaceTexture> surface_texture = |
133 context_provider_->GetSurfaceTexture(stream_id); | 136 context_provider_->GetSurfaceTexture(stream_id); |
134 if (surface_texture) { | 137 if (surface_texture) { |
135 SurfaceTexturePeer::GetInstance()->EstablishSurfaceTexturePeer( | 138 SurfaceTexturePeer::GetInstance()->EstablishSurfaceTexturePeer( |
136 base::Process::Current().handle(), | 139 base::Process::Current().handle(), |
137 surface_texture, | 140 surface_texture, |
138 view_id_, | 141 view_id_, |
139 player_id); | 142 player_id); |
140 } | 143 } |
141 } | 144 } |
142 | 145 |
143 unsigned StreamTextureFactorySynchronousImpl::CreateStreamTexture( | 146 unsigned StreamTextureFactorySynchronousImpl::CreateStreamTexture( |
144 unsigned texture_target, | 147 unsigned texture_target, |
145 unsigned* texture_id, | 148 unsigned* texture_id, |
146 gpu::Mailbox* texture_mailbox, | 149 gpu::Mailbox* texture_mailbox, |
147 unsigned* texture_mailbox_sync_point) { | 150 unsigned* texture_mailbox_sync_point) { |
148 WebKit::WebGraphicsContext3D* context = context_provider_->Context3d(); | 151 WebKit::WebGraphicsContext3D* context = NULL; |
149 unsigned stream_id = 0; | 152 unsigned stream_id = 0; |
150 if (context->makeContextCurrent()) { | 153 if (context_provider_ && |
no sievers
2013/09/06 01:50:34
Can we avoid allowing context_provider_ == NULL in
boliu
2013/09/06 02:59:26
Done.
| |
154 (context = context_provider_->Context3d()) && | |
155 context->makeContextCurrent()) { | |
151 *texture_id = context->createTexture(); | 156 *texture_id = context->createTexture(); |
152 stream_id = context->createStreamTextureCHROMIUM(*texture_id); | 157 stream_id = context->createStreamTextureCHROMIUM(*texture_id); |
153 | 158 |
154 context->genMailboxCHROMIUM(texture_mailbox->name); | 159 context->genMailboxCHROMIUM(texture_mailbox->name); |
155 context->bindTexture(texture_target, *texture_id); | 160 context->bindTexture(texture_target, *texture_id); |
156 context->produceTextureCHROMIUM(texture_target, texture_mailbox->name); | 161 context->produceTextureCHROMIUM(texture_target, texture_mailbox->name); |
157 | 162 |
158 context->flush(); | 163 context->flush(); |
159 *texture_mailbox_sync_point = context->insertSyncPoint(); | 164 *texture_mailbox_sync_point = context->insertSyncPoint(); |
160 } | 165 } |
161 return stream_id; | 166 return stream_id; |
162 } | 167 } |
163 | 168 |
164 void StreamTextureFactorySynchronousImpl::DestroyStreamTexture( | 169 void StreamTextureFactorySynchronousImpl::DestroyStreamTexture( |
165 unsigned texture_id) { | 170 unsigned texture_id) { |
171 DCHECK(context_provider_); | |
166 WebKit::WebGraphicsContext3D* context = context_provider_->Context3d(); | 172 WebKit::WebGraphicsContext3D* context = context_provider_->Context3d(); |
167 if (context->makeContextCurrent()) { | 173 if (context->makeContextCurrent()) { |
168 context->destroyStreamTextureCHROMIUM(texture_id); | 174 context->destroyStreamTextureCHROMIUM(texture_id); |
169 context->deleteTexture(texture_id); | 175 context->deleteTexture(texture_id); |
170 context->flush(); | 176 context->flush(); |
171 } | 177 } |
172 } | 178 } |
173 | 179 |
174 void StreamTextureFactorySynchronousImpl::SetStreamTextureSize( | 180 void StreamTextureFactorySynchronousImpl::SetStreamTextureSize( |
175 int32 stream_id, | 181 int32 stream_id, |
176 const gfx::Size& size) {} | 182 const gfx::Size& size) {} |
177 | 183 |
178 } // namespace content | 184 } // namespace content |
OLD | NEW |