| 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" |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 gfx::Vector2d()); | 306 gfx::Vector2d()); |
| 307 | 307 |
| 308 RecycleResourceData recycle_data = { | 308 RecycleResourceData recycle_data = { |
| 309 plane_resources[i].resource_id, | 309 plane_resources[i].resource_id, |
| 310 plane_resources[i].resource_size, | 310 plane_resources[i].resource_size, |
| 311 plane_resources[i].resource_format, | 311 plane_resources[i].resource_format, |
| 312 plane_resources[i].mailbox | 312 plane_resources[i].mailbox |
| 313 }; | 313 }; |
| 314 | 314 |
| 315 external_resources.mailboxes.push_back( | 315 external_resources.mailboxes.push_back( |
| 316 TextureMailbox(plane_resources[i].mailbox)); | 316 TextureMailbox(plane_resources[i].mailbox, GL_TEXTURE_2D, 0)); |
| 317 external_resources.release_callbacks.push_back( | 317 external_resources.release_callbacks.push_back( |
| 318 base::Bind(&RecycleResource, AsWeakPtr(), recycle_data)); | 318 base::Bind(&RecycleResource, AsWeakPtr(), recycle_data)); |
| 319 } | 319 } |
| 320 | 320 |
| 321 external_resources.type = VideoFrameExternalResources::YUV_RESOURCE; | 321 external_resources.type = VideoFrameExternalResources::YUV_RESOURCE; |
| 322 return external_resources; | 322 return external_resources; |
| 323 } | 323 } |
| 324 | 324 |
| 325 static void ReturnTexture(const scoped_refptr<media::VideoFrame>& frame, | 325 static void ReturnTexture(const scoped_refptr<media::VideoFrame>& frame, |
| 326 unsigned sync_point, | 326 uint32 sync_point, |
| 327 bool lost_resource) { | 327 bool lost_resource) { |
| 328 frame->texture_mailbox()->Resync(sync_point); | 328 frame->mailbox_holder()->sync_point = sync_point; |
| 329 } | 329 } |
| 330 | 330 |
| 331 VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes( | 331 VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes( |
| 332 const scoped_refptr<media::VideoFrame>& video_frame) { | 332 const scoped_refptr<media::VideoFrame>& video_frame) { |
| 333 media::VideoFrame::Format frame_format = video_frame->format(); | 333 media::VideoFrame::Format frame_format = video_frame->format(); |
| 334 | 334 |
| 335 DCHECK_EQ(frame_format, media::VideoFrame::NATIVE_TEXTURE); | 335 DCHECK_EQ(frame_format, media::VideoFrame::NATIVE_TEXTURE); |
| 336 if (frame_format != media::VideoFrame::NATIVE_TEXTURE) | 336 if (frame_format != media::VideoFrame::NATIVE_TEXTURE) |
| 337 return VideoFrameExternalResources(); | 337 return VideoFrameExternalResources(); |
| 338 | 338 |
| 339 if (!context_provider_) | 339 if (!context_provider_) |
| 340 return VideoFrameExternalResources(); | 340 return VideoFrameExternalResources(); |
| 341 | 341 |
| 342 gpu::MailboxHolder* mailbox_holder = video_frame->mailbox_holder(); |
| 342 VideoFrameExternalResources external_resources; | 343 VideoFrameExternalResources external_resources; |
| 343 switch (video_frame->texture_target()) { | 344 switch (mailbox_holder->texture_target) { |
| 344 case GL_TEXTURE_2D: | 345 case GL_TEXTURE_2D: |
| 345 external_resources.type = VideoFrameExternalResources::RGB_RESOURCE; | 346 external_resources.type = VideoFrameExternalResources::RGB_RESOURCE; |
| 346 break; | 347 break; |
| 347 case GL_TEXTURE_EXTERNAL_OES: | 348 case GL_TEXTURE_EXTERNAL_OES: |
| 348 external_resources.type = | 349 external_resources.type = |
| 349 VideoFrameExternalResources::STREAM_TEXTURE_RESOURCE; | 350 VideoFrameExternalResources::STREAM_TEXTURE_RESOURCE; |
| 350 break; | 351 break; |
| 351 case GL_TEXTURE_RECTANGLE_ARB: | 352 case GL_TEXTURE_RECTANGLE_ARB: |
| 352 external_resources.type = VideoFrameExternalResources::IO_SURFACE; | 353 external_resources.type = VideoFrameExternalResources::IO_SURFACE; |
| 353 break; | 354 break; |
| 354 default: | 355 default: |
| 355 NOTREACHED(); | 356 NOTREACHED(); |
| 356 return VideoFrameExternalResources(); | 357 return VideoFrameExternalResources(); |
| 357 } | 358 } |
| 358 | 359 |
| 359 media::VideoFrame::MailboxHolder* mailbox_holder = | |
| 360 video_frame->texture_mailbox(); | |
| 361 | |
| 362 external_resources.mailboxes.push_back( | 360 external_resources.mailboxes.push_back( |
| 363 TextureMailbox(mailbox_holder->mailbox(), | 361 TextureMailbox(mailbox_holder->mailbox, |
| 364 video_frame->texture_target(), | 362 mailbox_holder->texture_target, |
| 365 mailbox_holder->sync_point())); | 363 mailbox_holder->sync_point)); |
| 366 external_resources.release_callbacks.push_back( | 364 external_resources.release_callbacks.push_back( |
| 367 base::Bind(&ReturnTexture, video_frame)); | 365 base::Bind(&ReturnTexture, video_frame)); |
| 368 return external_resources; | 366 return external_resources; |
| 369 } | 367 } |
| 370 | 368 |
| 371 // static | 369 // static |
| 372 void VideoResourceUpdater::RecycleResource( | 370 void VideoResourceUpdater::RecycleResource( |
| 373 base::WeakPtr<VideoResourceUpdater> updater, | 371 base::WeakPtr<VideoResourceUpdater> updater, |
| 374 RecycleResourceData data, | 372 RecycleResourceData data, |
| 375 unsigned sync_point, | 373 uint32 sync_point, |
| 376 bool lost_resource) { | 374 bool lost_resource) { |
| 377 if (!updater.get()) { | 375 if (!updater.get()) { |
| 378 // Resource was already deleted. | 376 // Resource was already deleted. |
| 379 return; | 377 return; |
| 380 } | 378 } |
| 381 | 379 |
| 382 ContextProvider* context_provider = updater->context_provider_; | 380 ContextProvider* context_provider = updater->context_provider_; |
| 383 if (context_provider && sync_point) { | 381 if (context_provider && sync_point) { |
| 384 GLC(context_provider->ContextGL(), | 382 GLC(context_provider->ContextGL(), |
| 385 context_provider->ContextGL()->WaitSyncPointCHROMIUM(sync_point)); | 383 context_provider->ContextGL()->WaitSyncPointCHROMIUM(sync_point)); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 399 } | 397 } |
| 400 | 398 |
| 401 PlaneResource recycled_resource(data.resource_id, | 399 PlaneResource recycled_resource(data.resource_id, |
| 402 data.resource_size, | 400 data.resource_size, |
| 403 data.resource_format, | 401 data.resource_format, |
| 404 data.mailbox); | 402 data.mailbox); |
| 405 updater->recycled_resources_.push_back(recycled_resource); | 403 updater->recycled_resources_.push_back(recycled_resource); |
| 406 } | 404 } |
| 407 | 405 |
| 408 } // namespace cc | 406 } // namespace cc |
| OLD | NEW |