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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 gfx::Vector2d()); | 308 gfx::Vector2d()); |
309 | 309 |
310 RecycleResourceData recycle_data = { | 310 RecycleResourceData recycle_data = { |
311 plane_resources[i].resource_id, | 311 plane_resources[i].resource_id, |
312 plane_resources[i].resource_size, | 312 plane_resources[i].resource_size, |
313 plane_resources[i].resource_format, | 313 plane_resources[i].resource_format, |
314 plane_resources[i].mailbox | 314 plane_resources[i].mailbox |
315 }; | 315 }; |
316 | 316 |
317 external_resources.mailboxes.push_back( | 317 external_resources.mailboxes.push_back( |
318 TextureMailbox(plane_resources[i].mailbox)); | 318 TextureMailbox(plane_resources[i].mailbox, GL_TEXTURE_2D, 0)); |
319 external_resources.release_callbacks.push_back( | 319 external_resources.release_callbacks.push_back( |
320 base::Bind(&RecycleResource, AsWeakPtr(), recycle_data)); | 320 base::Bind(&RecycleResource, AsWeakPtr(), recycle_data)); |
321 } | 321 } |
322 | 322 |
323 external_resources.type = VideoFrameExternalResources::YUV_RESOURCE; | 323 external_resources.type = VideoFrameExternalResources::YUV_RESOURCE; |
324 return external_resources; | 324 return external_resources; |
325 } | 325 } |
326 | 326 |
327 static void ReturnTexture(const scoped_refptr<media::VideoFrame>& frame, | 327 static void ReturnTexture(const scoped_refptr<media::VideoFrame>& frame, |
328 unsigned sync_point, | 328 uint32 sync_point, |
329 bool lost_resource) { | 329 bool lost_resource) { |
330 frame->texture_mailbox()->Resync(sync_point); | 330 frame->mailbox_holder()->set_sync_point(sync_point); |
331 } | 331 } |
332 | 332 |
333 VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes( | 333 VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes( |
334 const scoped_refptr<media::VideoFrame>& video_frame) { | 334 const scoped_refptr<media::VideoFrame>& video_frame) { |
335 media::VideoFrame::Format frame_format = video_frame->format(); | 335 media::VideoFrame::Format frame_format = video_frame->format(); |
336 | 336 |
337 DCHECK_EQ(frame_format, media::VideoFrame::NATIVE_TEXTURE); | 337 DCHECK_EQ(frame_format, media::VideoFrame::NATIVE_TEXTURE); |
338 if (frame_format != media::VideoFrame::NATIVE_TEXTURE) | 338 if (frame_format != media::VideoFrame::NATIVE_TEXTURE) |
339 return VideoFrameExternalResources(); | 339 return VideoFrameExternalResources(); |
340 | 340 |
341 if (!context_provider_) | 341 if (!context_provider_) |
342 return VideoFrameExternalResources(); | 342 return VideoFrameExternalResources(); |
343 | 343 |
| 344 gpu::MailboxHolder* mailbox_holder = video_frame->mailbox_holder(); |
344 VideoFrameExternalResources external_resources; | 345 VideoFrameExternalResources external_resources; |
345 switch (video_frame->texture_target()) { | 346 switch (mailbox_holder->target()) { |
346 case GL_TEXTURE_2D: | 347 case GL_TEXTURE_2D: |
347 external_resources.type = VideoFrameExternalResources::RGB_RESOURCE; | 348 external_resources.type = VideoFrameExternalResources::RGB_RESOURCE; |
348 break; | 349 break; |
349 case GL_TEXTURE_EXTERNAL_OES: | 350 case GL_TEXTURE_EXTERNAL_OES: |
350 external_resources.type = | 351 external_resources.type = |
351 VideoFrameExternalResources::STREAM_TEXTURE_RESOURCE; | 352 VideoFrameExternalResources::STREAM_TEXTURE_RESOURCE; |
352 break; | 353 break; |
353 case GL_TEXTURE_RECTANGLE_ARB: | 354 case GL_TEXTURE_RECTANGLE_ARB: |
354 external_resources.type = VideoFrameExternalResources::IO_SURFACE; | 355 external_resources.type = VideoFrameExternalResources::IO_SURFACE; |
355 break; | 356 break; |
356 default: | 357 default: |
357 NOTREACHED(); | 358 NOTREACHED(); |
358 return VideoFrameExternalResources(); | 359 return VideoFrameExternalResources(); |
359 } | 360 } |
360 | 361 |
361 media::VideoFrame::MailboxHolder* mailbox_holder = | |
362 video_frame->texture_mailbox(); | |
363 | |
364 external_resources.mailboxes.push_back( | 362 external_resources.mailboxes.push_back( |
365 TextureMailbox(mailbox_holder->mailbox(), | 363 TextureMailbox(mailbox_holder->mailbox(), |
366 video_frame->texture_target(), | 364 mailbox_holder->target(), |
367 mailbox_holder->sync_point())); | 365 mailbox_holder->sync_point())); |
368 external_resources.release_callbacks.push_back( | 366 external_resources.release_callbacks.push_back( |
369 base::Bind(&ReturnTexture, video_frame)); | 367 base::Bind(&ReturnTexture, video_frame)); |
370 return external_resources; | 368 return external_resources; |
371 } | 369 } |
372 | 370 |
373 // static | 371 // static |
374 void VideoResourceUpdater::RecycleResource( | 372 void VideoResourceUpdater::RecycleResource( |
375 base::WeakPtr<VideoResourceUpdater> updater, | 373 base::WeakPtr<VideoResourceUpdater> updater, |
376 RecycleResourceData data, | 374 RecycleResourceData data, |
377 unsigned sync_point, | 375 uint32 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->Context3d(), |
387 context_provider->Context3d()->waitSyncPoint(sync_point)); | 385 context_provider->Context3d()->waitSyncPoint(sync_point)); |
(...skipping 13 matching lines...) Expand all Loading... |
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 |