Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Side by Side Diff: cc/resources/video_resource_updater.cc

Issue 132233041: Add gpu::MailboxHolder to hold state for a gpu::Mailbox (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ff7262fa Rebase. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/resources/video_resource_updater.h ('k') | cc/test/fake_delegated_renderer_layer_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 gfx::Vector2d()); 299 gfx::Vector2d());
300 300
301 RecycleResourceData recycle_data = { 301 RecycleResourceData recycle_data = {
302 plane_resources[i].resource_id, 302 plane_resources[i].resource_id,
303 plane_resources[i].resource_size, 303 plane_resources[i].resource_size,
304 plane_resources[i].resource_format, 304 plane_resources[i].resource_format,
305 plane_resources[i].mailbox 305 plane_resources[i].mailbox
306 }; 306 };
307 307
308 external_resources.mailboxes.push_back( 308 external_resources.mailboxes.push_back(
309 TextureMailbox(plane_resources[i].mailbox)); 309 TextureMailbox(plane_resources[i].mailbox, GL_TEXTURE_2D, 0));
310 external_resources.release_callbacks.push_back( 310 external_resources.release_callbacks.push_back(
311 base::Bind(&RecycleResource, AsWeakPtr(), recycle_data)); 311 base::Bind(&RecycleResource, AsWeakPtr(), recycle_data));
312 } 312 }
313 313
314 external_resources.type = VideoFrameExternalResources::YUV_RESOURCE; 314 external_resources.type = VideoFrameExternalResources::YUV_RESOURCE;
315 return external_resources; 315 return external_resources;
316 } 316 }
317 317
318 static void ReturnTexture(const scoped_refptr<media::VideoFrame>& frame, 318 static void ReturnTexture(const scoped_refptr<media::VideoFrame>& frame,
319 unsigned sync_point, 319 uint32 sync_point,
320 bool lost_resource) { 320 bool lost_resource) {
321 frame->texture_mailbox()->Resync(sync_point); 321 frame->mailbox_holder()->sync_point = sync_point;
322 } 322 }
323 323
324 VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes( 324 VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes(
325 const scoped_refptr<media::VideoFrame>& video_frame) { 325 const scoped_refptr<media::VideoFrame>& video_frame) {
326 media::VideoFrame::Format frame_format = video_frame->format(); 326 media::VideoFrame::Format frame_format = video_frame->format();
327 327
328 DCHECK_EQ(frame_format, media::VideoFrame::NATIVE_TEXTURE); 328 DCHECK_EQ(frame_format, media::VideoFrame::NATIVE_TEXTURE);
329 if (frame_format != media::VideoFrame::NATIVE_TEXTURE) 329 if (frame_format != media::VideoFrame::NATIVE_TEXTURE)
330 return VideoFrameExternalResources(); 330 return VideoFrameExternalResources();
331 331
332 if (!context_provider_) 332 if (!context_provider_)
333 return VideoFrameExternalResources(); 333 return VideoFrameExternalResources();
334 334
335 gpu::MailboxHolder* mailbox_holder = video_frame->mailbox_holder();
335 VideoFrameExternalResources external_resources; 336 VideoFrameExternalResources external_resources;
336 switch (video_frame->texture_target()) { 337 switch (mailbox_holder->texture_target) {
337 case GL_TEXTURE_2D: 338 case GL_TEXTURE_2D:
338 external_resources.type = VideoFrameExternalResources::RGB_RESOURCE; 339 external_resources.type = VideoFrameExternalResources::RGB_RESOURCE;
339 break; 340 break;
340 case GL_TEXTURE_EXTERNAL_OES: 341 case GL_TEXTURE_EXTERNAL_OES:
341 external_resources.type = 342 external_resources.type =
342 VideoFrameExternalResources::STREAM_TEXTURE_RESOURCE; 343 VideoFrameExternalResources::STREAM_TEXTURE_RESOURCE;
343 break; 344 break;
344 case GL_TEXTURE_RECTANGLE_ARB: 345 case GL_TEXTURE_RECTANGLE_ARB:
345 external_resources.type = VideoFrameExternalResources::IO_SURFACE; 346 external_resources.type = VideoFrameExternalResources::IO_SURFACE;
346 break; 347 break;
347 default: 348 default:
348 NOTREACHED(); 349 NOTREACHED();
349 return VideoFrameExternalResources(); 350 return VideoFrameExternalResources();
350 } 351 }
351 352
352 media::VideoFrame::MailboxHolder* mailbox_holder =
353 video_frame->texture_mailbox();
354
355 external_resources.mailboxes.push_back( 353 external_resources.mailboxes.push_back(
356 TextureMailbox(mailbox_holder->mailbox(), 354 TextureMailbox(mailbox_holder->mailbox,
357 video_frame->texture_target(), 355 mailbox_holder->texture_target,
358 mailbox_holder->sync_point())); 356 mailbox_holder->sync_point));
359 external_resources.release_callbacks.push_back( 357 external_resources.release_callbacks.push_back(
360 base::Bind(&ReturnTexture, video_frame)); 358 base::Bind(&ReturnTexture, video_frame));
361 return external_resources; 359 return external_resources;
362 } 360 }
363 361
364 // static 362 // static
365 void VideoResourceUpdater::RecycleResource( 363 void VideoResourceUpdater::RecycleResource(
366 base::WeakPtr<VideoResourceUpdater> updater, 364 base::WeakPtr<VideoResourceUpdater> updater,
367 RecycleResourceData data, 365 RecycleResourceData data,
368 unsigned sync_point, 366 uint32 sync_point,
369 bool lost_resource) { 367 bool lost_resource) {
370 if (!updater.get()) { 368 if (!updater.get()) {
371 // Resource was already deleted. 369 // Resource was already deleted.
372 return; 370 return;
373 } 371 }
374 372
375 ContextProvider* context_provider = updater->context_provider_; 373 ContextProvider* context_provider = updater->context_provider_;
376 if (context_provider && sync_point) { 374 if (context_provider && sync_point) {
377 GLC(context_provider->ContextGL(), 375 GLC(context_provider->ContextGL(),
378 context_provider->ContextGL()->WaitSyncPointCHROMIUM(sync_point)); 376 context_provider->ContextGL()->WaitSyncPointCHROMIUM(sync_point));
(...skipping 13 matching lines...) Expand all
392 } 390 }
393 391
394 PlaneResource recycled_resource(data.resource_id, 392 PlaneResource recycled_resource(data.resource_id,
395 data.resource_size, 393 data.resource_size,
396 data.resource_format, 394 data.resource_format,
397 data.mailbox); 395 data.mailbox);
398 updater->recycled_resources_.push_back(recycled_resource); 396 updater->recycled_resources_.push_back(recycled_resource);
399 } 397 }
400 398
401 } // namespace cc 399 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/video_resource_updater.h ('k') | cc/test/fake_delegated_renderer_layer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698