| 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 "cc/resources/video_resource_updater.h" | 5 #include "cc/resources/video_resource_updater.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "cc/output/gl_renderer.h" | 8 #include "cc/output/gl_renderer.h" |
| 9 #include "cc/resources/resource_provider.h" | 9 #include "cc/resources/resource_provider.h" |
| 10 #include "gpu/GLES2/gl2extchromium.h" | 10 #include "gpu/GLES2/gl2extchromium.h" |
| 11 #include "gpu/command_buffer/client/gles2_interface.h" |
| 11 #include "media/base/video_frame.h" | 12 #include "media/base/video_frame.h" |
| 12 #include "media/filters/skcanvas_video_renderer.h" | 13 #include "media/filters/skcanvas_video_renderer.h" |
| 13 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | |
| 14 #include "third_party/khronos/GLES2/gl2.h" | 14 #include "third_party/khronos/GLES2/gl2.h" |
| 15 #include "third_party/khronos/GLES2/gl2ext.h" | 15 #include "third_party/khronos/GLES2/gl2ext.h" |
| 16 #include "ui/gfx/size_conversions.h" | 16 #include "ui/gfx/size_conversions.h" |
| 17 | 17 |
| 18 namespace cc { | 18 namespace cc { |
| 19 | 19 |
| 20 const ResourceFormat kYUVResourceFormat = LUMINANCE_8; | 20 const ResourceFormat kYUVResourceFormat = LUMINANCE_8; |
| 21 const ResourceFormat kRGBResourceFormat = RGBA_8888; | 21 const ResourceFormat kRGBResourceFormat = RGBA_8888; |
| 22 | 22 |
| 23 VideoFrameExternalResources::VideoFrameExternalResources() : type(NONE) {} | 23 VideoFrameExternalResources::VideoFrameExternalResources() : type(NONE) {} |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 resource_provider_->CreateResource(output_plane_resource_size, | 198 resource_provider_->CreateResource(output_plane_resource_size, |
| 199 GL_CLAMP_TO_EDGE, | 199 GL_CLAMP_TO_EDGE, |
| 200 ResourceProvider::TextureUsageAny, | 200 ResourceProvider::TextureUsageAny, |
| 201 output_resource_format); | 201 output_resource_format); |
| 202 | 202 |
| 203 DCHECK(mailbox.IsZero()); | 203 DCHECK(mailbox.IsZero()); |
| 204 | 204 |
| 205 if (!software_compositor) { | 205 if (!software_compositor) { |
| 206 DCHECK(context_provider_); | 206 DCHECK(context_provider_); |
| 207 | 207 |
| 208 blink::WebGraphicsContext3D* context = | 208 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); |
| 209 context_provider_->Context3d(); | |
| 210 | 209 |
| 211 GLC(context, context->genMailboxCHROMIUM(mailbox.name)); | 210 GLC(gl, gl->GenMailboxCHROMIUM(mailbox.name)); |
| 212 if (mailbox.IsZero()) { | 211 if (mailbox.IsZero()) { |
| 213 resource_provider_->DeleteResource(resource_id); | 212 resource_provider_->DeleteResource(resource_id); |
| 214 resource_id = 0; | 213 resource_id = 0; |
| 215 } else { | 214 } else { |
| 216 ResourceProvider::ScopedWriteLockGL lock( | 215 ResourceProvider::ScopedWriteLockGL lock( |
| 217 resource_provider_, resource_id); | 216 resource_provider_, resource_id); |
| 218 GLC(context, context->bindTexture(GL_TEXTURE_2D, lock.texture_id())); | 217 GLC(gl, gl->BindTexture(GL_TEXTURE_2D, lock.texture_id())); |
| 219 GLC(context, context->produceTextureCHROMIUM(GL_TEXTURE_2D, | 218 GLC(gl, gl->ProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name)); |
| 220 mailbox.name)); | 219 GLC(gl, gl->BindTexture(GL_TEXTURE_2D, 0)); |
| 221 GLC(context, context->bindTexture(GL_TEXTURE_2D, 0)); | |
| 222 } | 220 } |
| 223 } | 221 } |
| 224 | 222 |
| 225 if (resource_id) | 223 if (resource_id) |
| 226 all_resources_.push_back(resource_id); | 224 all_resources_.push_back(resource_id); |
| 227 } | 225 } |
| 228 | 226 |
| 229 if (resource_id == 0) { | 227 if (resource_id == 0) { |
| 230 allocation_success = false; | 228 allocation_success = false; |
| 231 break; | 229 break; |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 RecycleResourceData data, | 374 RecycleResourceData data, |
| 377 unsigned sync_point, | 375 unsigned sync_point, |
| 378 bool lost_resource) { | 376 bool lost_resource) { |
| 379 if (!updater.get()) { | 377 if (!updater.get()) { |
| 380 // Resource was already deleted. | 378 // Resource was already deleted. |
| 381 return; | 379 return; |
| 382 } | 380 } |
| 383 | 381 |
| 384 ContextProvider* context_provider = updater->context_provider_; | 382 ContextProvider* context_provider = updater->context_provider_; |
| 385 if (context_provider && sync_point) { | 383 if (context_provider && sync_point) { |
| 386 GLC(context_provider->Context3d(), | 384 GLC(context_provider->ContextGL(), |
| 387 context_provider->Context3d()->waitSyncPoint(sync_point)); | 385 context_provider->ContextGL()->WaitSyncPointCHROMIUM(sync_point)); |
| 388 } | 386 } |
| 389 | 387 |
| 390 if (lost_resource) { | 388 if (lost_resource) { |
| 391 updater->DeleteResource(data.resource_id); | 389 updater->DeleteResource(data.resource_id); |
| 392 return; | 390 return; |
| 393 } | 391 } |
| 394 | 392 |
| 395 // Drop recycled resources that are the wrong format. | 393 // Drop recycled resources that are the wrong format. |
| 396 while (!updater->recycled_resources_.empty() && | 394 while (!updater->recycled_resources_.empty() && |
| 397 updater->recycled_resources_.back().resource_format != | 395 updater->recycled_resources_.back().resource_format != |
| 398 data.resource_format) { | 396 data.resource_format) { |
| 399 updater->DeleteResource(updater->recycled_resources_.back().resource_id); | 397 updater->DeleteResource(updater->recycled_resources_.back().resource_id); |
| 400 updater->recycled_resources_.pop_back(); | 398 updater->recycled_resources_.pop_back(); |
| 401 } | 399 } |
| 402 | 400 |
| 403 PlaneResource recycled_resource(data.resource_id, | 401 PlaneResource recycled_resource(data.resource_id, |
| 404 data.resource_size, | 402 data.resource_size, |
| 405 data.resource_format, | 403 data.resource_format, |
| 406 data.mailbox); | 404 data.mailbox); |
| 407 updater->recycled_resources_.push_back(recycled_resource); | 405 updater->recycled_resources_.push_back(recycled_resource); |
| 408 } | 406 } |
| 409 | 407 |
| 410 } // namespace cc | 408 } // namespace cc |
| OLD | NEW |