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

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

Issue 2242453002: Avoid planar YUV resources when one component EGL images are not supported (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add SyncToken comment Created 4 years, 3 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
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 : context_provider_(context_provider), 166 : context_provider_(context_provider),
167 resource_provider_(resource_provider) { 167 resource_provider_(resource_provider) {
168 } 168 }
169 169
170 VideoResourceUpdater::~VideoResourceUpdater() { 170 VideoResourceUpdater::~VideoResourceUpdater() {
171 for (const PlaneResource& plane_resource : all_resources_) 171 for (const PlaneResource& plane_resource : all_resources_)
172 resource_provider_->DeleteResource(plane_resource.resource_id()); 172 resource_provider_->DeleteResource(plane_resource.resource_id());
173 } 173 }
174 174
175 VideoResourceUpdater::ResourceList::iterator 175 VideoResourceUpdater::ResourceList::iterator
176 VideoResourceUpdater::RecycleOrAllocateResource(
177 const gfx::Size& resource_size,
178 ResourceFormat resource_format,
179 const gfx::ColorSpace& color_space,
180 bool software_resource,
181 bool immutable_hint,
182 int unique_id,
183 int plane_index) {
184 ResourceList::iterator recyclable_resource = all_resources_.end();
185 for (auto it = all_resources_.begin(); it != all_resources_.end(); ++it) {
186 // If the plane index is valid (positive, or 0, meaning all planes)
187 // then we are allowed to return a referenced resource that already
188 // contains the right frame data. It's safe to reuse it even if
189 // resource_provider_ holds some references to it, because those
190 // references are read-only.
191 if (plane_index != -1 && it->Matches(unique_id, plane_index)) {
192 DCHECK(it->resource_size() == resource_size);
193 DCHECK(it->resource_format() == resource_format);
194 DCHECK(it->mailbox().IsZero() == software_resource);
195 return it;
196 }
197
198 // Otherwise check whether this is an unreferenced resource of the
199 // right format that we can recycle. Remember it, but don't return
200 // immediately, because we still want to find any reusable
201 // resources.
202 if (!it->has_refs() && it->resource_size() == resource_size &&
203 it->resource_format() == resource_format &&
204 it->mailbox().IsZero() == software_resource) {
205 if (software_resource) {
206 // This extra check is needed because resources backed by SharedMemory
207 // are not ref-counted, unlike mailboxes. Full discussion in
208 // codereview.chromium.org/145273021.
209 if (!resource_provider_->InUseByConsumer(it->resource_id()))
210 recyclable_resource = it;
211 } else if (immutable_hint ==
212 (resource_provider_->GetTextureHint(it->resource_id()) ==
danakj 2016/09/12 22:06:53 There's nothing innately GPU-only about this is th
Tobias Sargeant 2016/09/12 22:29:45 What do you think of ResourceProvider::IsImmutable
danakj 2016/09/12 22:38:15 I think they already are, since Resource construct
213 ResourceProvider::TEXTURE_HINT_IMMUTABLE)) {
214 recyclable_resource = it;
215 }
216 }
217 }
218
219 if (recyclable_resource != all_resources_.end())
220 return recyclable_resource;
221
222 // There was nothing available to reuse or recycle. Allocate a new resource.
223 return AllocateResource(resource_size, resource_format, color_space,
224 !software_resource, immutable_hint);
225 }
226
227 VideoResourceUpdater::ResourceList::iterator
176 VideoResourceUpdater::AllocateResource(const gfx::Size& plane_size, 228 VideoResourceUpdater::AllocateResource(const gfx::Size& plane_size,
177 ResourceFormat format, 229 ResourceFormat format,
178 const gfx::ColorSpace& color_space, 230 const gfx::ColorSpace& color_space,
179 bool has_mailbox, 231 bool has_mailbox,
180 bool immutable_hint) { 232 bool immutable_hint) {
181 // TODO(danakj): Abstract out hw/sw resource create/delete from 233 // TODO(danakj): Abstract out hw/sw resource create/delete from
182 // ResourceProvider and stop using ResourceProvider in this class. 234 // ResourceProvider and stop using ResourceProvider in this class.
183 const ResourceId resource_id = resource_provider_->CreateResource( 235 const ResourceId resource_id = resource_provider_->CreateResource(
184 plane_size, immutable_hint ? ResourceProvider::TEXTURE_HINT_IMMUTABLE 236 plane_size, immutable_hint ? ResourceProvider::TEXTURE_HINT_IMMUTABLE
185 : ResourceProvider::TEXTURE_HINT_DEFAULT, 237 : ResourceProvider::TEXTURE_HINT_DEFAULT,
186 format, color_space); 238 format, color_space);
187 if (resource_id == 0) 239 DCHECK_NE(resource_id, 0u);
188 return all_resources_.end();
189 240
190 gpu::Mailbox mailbox; 241 gpu::Mailbox mailbox;
191 if (has_mailbox) { 242 if (has_mailbox) {
192 DCHECK(context_provider_); 243 DCHECK(context_provider_);
193 244
194 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); 245 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL();
195 246
196 gl->GenMailboxCHROMIUM(mailbox.name); 247 gl->GenMailboxCHROMIUM(mailbox.name);
197 ResourceProvider::ScopedWriteLockGL lock(resource_provider_, resource_id, 248 ResourceProvider::ScopedWriteLockGL lock(resource_provider_, resource_id,
198 false); 249 false);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 if (!media::IsYuvPlanar(input_frame_format)) { 342 if (!media::IsYuvPlanar(input_frame_format)) {
292 NOTREACHED() << media::VideoPixelFormatToString(input_frame_format); 343 NOTREACHED() << media::VideoPixelFormatToString(input_frame_format);
293 return VideoFrameExternalResources(); 344 return VideoFrameExternalResources();
294 } 345 }
295 346
296 const bool software_compositor = context_provider_ == NULL; 347 const bool software_compositor = context_provider_ == NULL;
297 348
298 ResourceFormat output_resource_format = 349 ResourceFormat output_resource_format =
299 resource_provider_->YuvResourceFormat(bits_per_channel); 350 resource_provider_->YuvResourceFormat(bits_per_channel);
300 351
352 // If GPU compositing is enabled, but the output resource format
353 // returned by the resource provider is RGBA_8888, then a GPU driver
354 // bug workaround requires that YUV frames must be converted to RGB
355 // before texture upload.
356 bool texture_needs_rgb_conversion =
357 !software_compositor &&
358 output_resource_format == ResourceFormat::RGBA_8888;
301 size_t output_plane_count = media::VideoFrame::NumPlanes(input_frame_format); 359 size_t output_plane_count = media::VideoFrame::NumPlanes(input_frame_format);
302 360
303 // TODO(skaslev): If we're in software compositing mode, we do the YUV -> RGB 361 // TODO(skaslev): If we're in software compositing mode, we do the YUV -> RGB
304 // conversion here. That involves an extra copy of each frame to a bitmap. 362 // conversion here. That involves an extra copy of each frame to a bitmap.
305 // Obviously, this is suboptimal and should be addressed once ubercompositor 363 // Obviously, this is suboptimal and should be addressed once ubercompositor
306 // starts shaping up. 364 // starts shaping up.
307 if (software_compositor) { 365 if (software_compositor || texture_needs_rgb_conversion) {
308 output_resource_format = kRGBResourceFormat; 366 output_resource_format = kRGBResourceFormat;
309 output_plane_count = 1; 367 output_plane_count = 1;
368 bits_per_channel = 8;
310 } 369 }
311 370
312 // Drop recycled resources that are the wrong format. 371 // Drop recycled resources that are the wrong format.
313 for (auto it = all_resources_.begin(); it != all_resources_.end();) { 372 for (auto it = all_resources_.begin(); it != all_resources_.end();) {
314 if (!it->has_refs() && it->resource_format() != output_resource_format) 373 if (!it->has_refs() && it->resource_format() != output_resource_format)
315 DeleteResource(it++); 374 DeleteResource(it++);
316 else 375 else
317 ++it; 376 ++it;
318 } 377 }
319 378
320 const int max_resource_size = resource_provider_->max_texture_size(); 379 const int max_resource_size = resource_provider_->max_texture_size();
321 std::vector<ResourceList::iterator> plane_resources; 380 std::vector<ResourceList::iterator> plane_resources;
322 for (size_t i = 0; i < output_plane_count; ++i) { 381 for (size_t i = 0; i < output_plane_count; ++i) {
323 gfx::Size output_plane_resource_size = 382 gfx::Size output_plane_resource_size =
324 SoftwarePlaneDimension(video_frame.get(), software_compositor, i); 383 SoftwarePlaneDimension(video_frame.get(), software_compositor, i);
325 if (output_plane_resource_size.IsEmpty() || 384 if (output_plane_resource_size.IsEmpty() ||
326 output_plane_resource_size.width() > max_resource_size || 385 output_plane_resource_size.width() > max_resource_size ||
327 output_plane_resource_size.height() > max_resource_size) { 386 output_plane_resource_size.height() > max_resource_size) {
328 break; 387 break;
329 } 388 }
330 389
331 // Try recycle a previously-allocated resource. 390 const bool is_immutable = true;
332 ResourceList::iterator resource_it = all_resources_.end(); 391 ResourceList::iterator resource_it = RecycleOrAllocateResource(
333 for (auto it = all_resources_.begin(); it != all_resources_.end(); ++it) { 392 output_plane_resource_size, output_resource_format,
334 if (it->resource_size() == output_plane_resource_size && 393 video_frame->ColorSpace(), software_compositor, is_immutable,
335 it->resource_format() == output_resource_format) { 394 video_frame->unique_id(), i);
336 if (it->Matches(video_frame->unique_id(), i)) {
337 // Bingo, we found a resource that already contains the data we are
338 // planning to put in it. It's safe to reuse it even if
339 // resource_provider_ holds some references to it, because those
340 // references are read-only.
341 resource_it = it;
342 break;
343 }
344
345 // This extra check is needed because resources backed by SharedMemory
346 // are not ref-counted, unlike mailboxes. Full discussion in
347 // codereview.chromium.org/145273021.
348 const bool in_use =
349 software_compositor &&
350 resource_provider_->InUseByConsumer(it->resource_id());
351 if (!it->has_refs() && !in_use) {
352 // We found a resource with the correct size that we can overwrite.
353 resource_it = it;
354 }
355 }
356 }
357
358 // Check if we need to allocate a new resource.
359 if (resource_it == all_resources_.end()) {
360 const bool is_immutable = true;
361 resource_it = AllocateResource(
362 output_plane_resource_size, output_resource_format,
363 video_frame->ColorSpace(), !software_compositor, is_immutable);
364 }
365 if (resource_it == all_resources_.end())
366 break;
367 395
368 resource_it->add_ref(); 396 resource_it->add_ref();
369 plane_resources.push_back(resource_it); 397 plane_resources.push_back(resource_it);
370 } 398 }
371 399
372 if (plane_resources.size() != output_plane_count) {
373 // Allocation failed, nothing will be returned so restore reference counts.
374 for (ResourceList::iterator resource_it : plane_resources)
375 resource_it->remove_ref();
376 return VideoFrameExternalResources();
377 }
378
379 VideoFrameExternalResources external_resources; 400 VideoFrameExternalResources external_resources;
380 401
381 external_resources.bits_per_channel = bits_per_channel; 402 external_resources.bits_per_channel = bits_per_channel;
382 403
383 if (software_compositor) { 404 if (software_compositor || texture_needs_rgb_conversion) {
384 DCHECK_EQ(plane_resources.size(), 1u); 405 DCHECK_EQ(plane_resources.size(), 1u);
385 PlaneResource& plane_resource = *plane_resources[0]; 406 PlaneResource& plane_resource = *plane_resources[0];
386 DCHECK_EQ(plane_resource.resource_format(), kRGBResourceFormat); 407 DCHECK_EQ(plane_resource.resource_format(), kRGBResourceFormat);
387 DCHECK(plane_resource.mailbox().IsZero()); 408 DCHECK_EQ(software_compositor, plane_resource.mailbox().IsZero());
388 409
389 if (!plane_resource.Matches(video_frame->unique_id(), 0)) { 410 if (!plane_resource.Matches(video_frame->unique_id(), 0)) {
390 // We need to transfer data from |video_frame| to the plane resource. 411 // We need to transfer data from |video_frame| to the plane resource.
391 if (!video_renderer_) 412 if (software_compositor) {
392 video_renderer_.reset(new media::SkCanvasVideoRenderer); 413 if (!video_renderer_)
414 video_renderer_.reset(new media::SkCanvasVideoRenderer);
393 415
394 ResourceProvider::ScopedWriteLockSoftware lock( 416 ResourceProvider::ScopedWriteLockSoftware lock(
395 resource_provider_, plane_resource.resource_id()); 417 resource_provider_, plane_resource.resource_id());
396 SkCanvas canvas(lock.sk_bitmap()); 418 SkCanvas canvas(lock.sk_bitmap());
397 // This is software path, so canvas and video_frame are always backed 419 // This is software path, so canvas and video_frame are always backed
398 // by software. 420 // by software.
399 video_renderer_->Copy(video_frame, &canvas, media::Context3D()); 421 video_renderer_->Copy(video_frame, &canvas, media::Context3D());
422 } else {
423 size_t bytes_per_row = ResourceUtil::CheckedWidthInBytes<size_t>(
424 video_frame->coded_size().width(), ResourceFormat::RGBA_8888);
425 size_t needed_size = bytes_per_row * video_frame->coded_size().height();
426 if (upload_pixels_.size() < needed_size)
427 upload_pixels_.resize(needed_size);
428
429 media::SkCanvasVideoRenderer::ConvertVideoFrameToRGBPixels(
430 video_frame.get(), &upload_pixels_[0], bytes_per_row);
431
432 resource_provider_->CopyToResource(plane_resource.resource_id(),
433 &upload_pixels_[0],
434 plane_resource.resource_size());
435 }
400 plane_resource.SetUniqueId(video_frame->unique_id(), 0); 436 plane_resource.SetUniqueId(video_frame->unique_id(), 0);
401 } 437 }
402 438
403 external_resources.software_resources.push_back( 439 if (software_compositor) {
404 plane_resource.resource_id()); 440 external_resources.software_resources.push_back(
405 external_resources.software_release_callback = 441 plane_resource.resource_id());
406 base::Bind(&RecycleResource, AsWeakPtr(), plane_resource.resource_id()); 442 external_resources.software_release_callback = base::Bind(
407 external_resources.type = VideoFrameExternalResources::SOFTWARE_RESOURCE; 443 &RecycleResource, AsWeakPtr(), plane_resource.resource_id());
444 external_resources.type = VideoFrameExternalResources::SOFTWARE_RESOURCE;
445 } else {
446 // VideoResourceUpdater shares a context with the compositor so
447 // a sync token is not required.
448 TextureMailbox mailbox(plane_resource.mailbox(), gpu::SyncToken(),
449 resource_provider_->GetResourceTextureTarget(
450 plane_resource.resource_id()));
451 mailbox.set_color_space(video_frame->ColorSpace());
452 external_resources.mailboxes.push_back(mailbox);
453 external_resources.release_callbacks.push_back(base::Bind(
454 &RecycleResource, AsWeakPtr(), plane_resource.resource_id()));
455 external_resources.type = VideoFrameExternalResources::RGBA_RESOURCE;
456 }
408 return external_resources; 457 return external_resources;
409 } 458 }
410 459
411 for (size_t i = 0; i < plane_resources.size(); ++i) { 460 for (size_t i = 0; i < plane_resources.size(); ++i) {
412 PlaneResource& plane_resource = *plane_resources[i]; 461 PlaneResource& plane_resource = *plane_resources[i];
413 // Update each plane's resource id with its content. 462 // Update each plane's resource id with its content.
414 DCHECK_EQ(plane_resource.resource_format(), 463 DCHECK_EQ(plane_resource.resource_format(),
415 resource_provider_->YuvResourceFormat(bits_per_channel)); 464 resource_provider_->YuvResourceFormat(bits_per_channel));
416 465
417 if (!plane_resource.Matches(video_frame->unique_id(), i)) { 466 if (!plane_resource.Matches(video_frame->unique_id(), i)) {
418 // We need to transfer data from |video_frame| to the plane resource. 467 // We need to transfer data from |video_frame| to the plane resource.
419 // TODO(reveman): Can use GpuMemoryBuffers here to improve performance. 468 // TODO(reveman): Can use GpuMemoryBuffers here to improve performance.
420 469
421 // The |resource_size_pixels| is the size of the resource we want to 470 // The |resource_size_pixels| is the size of the resource we want to
422 // upload to. 471 // upload to.
423 gfx::Size resource_size_pixels = plane_resource.resource_size(); 472 gfx::Size resource_size_pixels = plane_resource.resource_size();
424 // The |video_stride_bytes| is the width of the video frame we are 473 // The |video_stride_bytes| is the width of the video frame we are
425 // uploading (including non-frame data to fill in the stride). 474 // uploading (including non-frame data to fill in the stride).
426 int video_stride_bytes = video_frame->stride(i); 475 int video_stride_bytes = video_frame->stride(i);
427 476
428 size_t bytes_per_row = ResourceUtil::UncheckedWidthInBytes<size_t>( 477 size_t bytes_per_row = ResourceUtil::CheckedWidthInBytes<size_t>(
429 resource_size_pixels.width(), plane_resource.resource_format()); 478 resource_size_pixels.width(), plane_resource.resource_format());
430 // Use 4-byte row alignment (OpenGL default) for upload performance. 479 // Use 4-byte row alignment (OpenGL default) for upload performance.
431 // Assuming that GL_UNPACK_ALIGNMENT has not changed from default. 480 // Assuming that GL_UNPACK_ALIGNMENT has not changed from default.
432 size_t upload_image_stride = 481 size_t upload_image_stride =
433 MathUtil::UncheckedRoundUp<size_t>(bytes_per_row, 4u); 482 MathUtil::CheckedRoundUp<size_t>(bytes_per_row, 4u);
434 483
435 bool needs_conversion = false; 484 bool needs_conversion = false;
436 int shift = 0; 485 int shift = 0;
437 486
438 // LUMINANCE_F16 uses half-floats, so we always need a conversion step. 487 // LUMINANCE_F16 uses half-floats, so we always need a conversion step.
439 if (plane_resource.resource_format() == LUMINANCE_F16) { 488 if (plane_resource.resource_format() == LUMINANCE_F16) {
440 needs_conversion = true; 489 needs_conversion = true;
441 // Note that the current method of converting integers to half-floats 490 // Note that the current method of converting integers to half-floats
442 // stops working if you have more than 10 bits of data. 491 // stops working if you have more than 10 bits of data.
443 DCHECK_LE(bits_per_channel, 10); 492 DCHECK_LE(bits_per_channel, 10);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 // 561 //
513 // PLEASE NOTE: This doesn't work if bits_per_channel is > 10. 562 // PLEASE NOTE: This doesn't work if bits_per_channel is > 10.
514 // PLEASE NOTE: All planes are assumed to use the same multiplier/offset. 563 // PLEASE NOTE: All planes are assumed to use the same multiplier/offset.
515 external_resources.offset = 0.5f; 564 external_resources.offset = 0.5f;
516 // Max value from input data. 565 // Max value from input data.
517 int max_input_value = (1 << bits_per_channel) - 1; 566 int max_input_value = (1 << bits_per_channel) - 1;
518 // 2 << 11 = 2048 would be 1.0 with our exponent. 567 // 2 << 11 = 2048 would be 1.0 with our exponent.
519 external_resources.multiplier = 2048.0 / max_input_value; 568 external_resources.multiplier = 2048.0 / max_input_value;
520 } 569 }
521 570
571 // VideoResourceUpdater shares a context with the compositor so a
572 // sync token is not required.
522 TextureMailbox mailbox(plane_resource.mailbox(), gpu::SyncToken(), 573 TextureMailbox mailbox(plane_resource.mailbox(), gpu::SyncToken(),
523 resource_provider_->GetResourceTextureTarget( 574 resource_provider_->GetResourceTextureTarget(
524 plane_resource.resource_id())); 575 plane_resource.resource_id()));
525 mailbox.set_color_space(video_frame->ColorSpace()); 576 mailbox.set_color_space(video_frame->ColorSpace());
526 external_resources.mailboxes.push_back(mailbox); 577 external_resources.mailboxes.push_back(mailbox);
527 external_resources.release_callbacks.push_back(base::Bind( 578 external_resources.release_callbacks.push_back(base::Bind(
528 &RecycleResource, AsWeakPtr(), plane_resource.resource_id())); 579 &RecycleResource, AsWeakPtr(), plane_resource.resource_id()));
529 } 580 }
530 581
531 external_resources.type = VideoFrameExternalResources::YUV_RESOURCE; 582 external_resources.type = VideoFrameExternalResources::YUV_RESOURCE;
(...skipping 26 matching lines...) Expand all
558 const gpu::MailboxHolder& mailbox_holder, 609 const gpu::MailboxHolder& mailbox_holder,
559 VideoFrameExternalResources* external_resources) { 610 VideoFrameExternalResources* external_resources) {
560 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); 611 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL();
561 SyncTokenClientImpl client(gl, mailbox_holder.sync_token); 612 SyncTokenClientImpl client(gl, mailbox_holder.sync_token);
562 613
563 const gfx::Size output_plane_resource_size = video_frame->coded_size(); 614 const gfx::Size output_plane_resource_size = video_frame->coded_size();
564 // The copy needs to be a direct transfer of pixel data, so we use an RGBA8 615 // The copy needs to be a direct transfer of pixel data, so we use an RGBA8
565 // target to avoid loss of precision or dropping any alpha component. 616 // target to avoid loss of precision or dropping any alpha component.
566 const ResourceFormat copy_target_format = ResourceFormat::RGBA_8888; 617 const ResourceFormat copy_target_format = ResourceFormat::RGBA_8888;
567 618
568 // Search for an existing resource to reuse. 619 const bool is_immutable = false;
569 VideoResourceUpdater::ResourceList::iterator resource = all_resources_.end(); 620 const int no_unique_id = 0;
570 621 const int no_plane_index = -1; // Do not recycle referenced textures.
571 for (auto it = all_resources_.begin(); it != all_resources_.end(); ++it) { 622 VideoResourceUpdater::ResourceList::iterator resource =
572 // Reuse resource if attributes match and the resource is a currently 623 RecycleOrAllocateResource(output_plane_resource_size, copy_target_format,
573 // unreferenced texture. 624 video_frame->ColorSpace(), false, is_immutable,
574 if (it->resource_size() == output_plane_resource_size && 625 no_unique_id, no_plane_index);
575 it->resource_format() == copy_target_format &&
576 !it->mailbox().IsZero() && !it->has_refs() &&
577 resource_provider_->GetTextureHint(it->resource_id()) !=
578 ResourceProvider::TEXTURE_HINT_IMMUTABLE) {
579 resource = it;
580 break;
581 }
582 }
583
584 // Otherwise allocate a new resource.
585 if (resource == all_resources_.end()) {
586 const bool is_immutable = false;
587 resource = AllocateResource(output_plane_resource_size, copy_target_format,
588 video_frame->ColorSpace(), true, is_immutable);
589 }
590
591 resource->add_ref(); 626 resource->add_ref();
592 627
593 ResourceProvider::ScopedWriteLockGL lock(resource_provider_, 628 ResourceProvider::ScopedWriteLockGL lock(resource_provider_,
594 resource->resource_id(), false); 629 resource->resource_id(), false);
595 DCHECK_EQ( 630 DCHECK_EQ(
596 resource_provider_->GetResourceTextureTarget(resource->resource_id()), 631 resource_provider_->GetResourceTextureTarget(resource->resource_id()),
597 (GLenum)GL_TEXTURE_2D); 632 (GLenum)GL_TEXTURE_2D);
598 633
599 gl->WaitSyncTokenCHROMIUM(mailbox_holder.sync_token.GetConstData()); 634 gl->WaitSyncTokenCHROMIUM(mailbox_holder.sync_token.GetConstData());
600 uint32_t src_texture_id = gl->CreateAndConsumeTextureCHROMIUM( 635 uint32_t src_texture_id = gl->CreateAndConsumeTextureCHROMIUM(
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 void VideoResourceUpdater::RecycleResource( 707 void VideoResourceUpdater::RecycleResource(
673 base::WeakPtr<VideoResourceUpdater> updater, 708 base::WeakPtr<VideoResourceUpdater> updater,
674 ResourceId resource_id, 709 ResourceId resource_id,
675 const gpu::SyncToken& sync_token, 710 const gpu::SyncToken& sync_token,
676 bool lost_resource, 711 bool lost_resource,
677 BlockingTaskRunner* main_thread_task_runner) { 712 BlockingTaskRunner* main_thread_task_runner) {
678 if (!updater.get()) { 713 if (!updater.get()) {
679 // Resource was already deleted. 714 // Resource was already deleted.
680 return; 715 return;
681 } 716 }
682
683 const ResourceList::iterator resource_it = std::find_if( 717 const ResourceList::iterator resource_it = std::find_if(
684 updater->all_resources_.begin(), updater->all_resources_.end(), 718 updater->all_resources_.begin(), updater->all_resources_.end(),
685 [resource_id](const PlaneResource& plane_resource) { 719 [resource_id](const PlaneResource& plane_resource) {
686 return plane_resource.resource_id() == resource_id; 720 return plane_resource.resource_id() == resource_id;
687 }); 721 });
688 if (resource_it == updater->all_resources_.end()) 722 if (resource_it == updater->all_resources_.end())
689 return; 723 return;
690 724
691 ContextProvider* context_provider = updater->context_provider_; 725 ContextProvider* context_provider = updater->context_provider_;
692 if (context_provider && sync_token.HasData()) { 726 if (context_provider && sync_token.HasData()) {
693 context_provider->ContextGL()->WaitSyncTokenCHROMIUM( 727 context_provider->ContextGL()->WaitSyncTokenCHROMIUM(
694 sync_token.GetConstData()); 728 sync_token.GetConstData());
695 } 729 }
696 730
697 if (lost_resource) { 731 if (lost_resource) {
698 resource_it->clear_refs(); 732 resource_it->clear_refs();
699 updater->DeleteResource(resource_it); 733 updater->DeleteResource(resource_it);
700 return; 734 return;
701 } 735 }
702 736
703 resource_it->remove_ref(); 737 resource_it->remove_ref();
704 } 738 }
705 739
706 } // namespace cc 740 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698