| 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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 | 350 |
| 351 // static | 351 // static |
| 352 void VideoResourceUpdater::RecycleResource( | 352 void VideoResourceUpdater::RecycleResource( |
| 353 base::WeakPtr<VideoResourceUpdater> updater, | 353 base::WeakPtr<VideoResourceUpdater> updater, |
| 354 ResourceProvider* resource_provider, | 354 ResourceProvider* resource_provider, |
| 355 RecycleResourceData data, | 355 RecycleResourceData data, |
| 356 unsigned sync_point, | 356 unsigned sync_point, |
| 357 bool lost_resource) { | 357 bool lost_resource) { |
| 358 WebKit::WebGraphicsContext3D* context = | 358 WebKit::WebGraphicsContext3D* context = |
| 359 resource_provider->GraphicsContext3D(); | 359 resource_provider->GraphicsContext3D(); |
| 360 if (context && sync_point) | 360 if (lost_resource) |
| 361 return; |
| 362 |
| 363 if (context) { |
| 364 if (sync_point) |
| 361 GLC(context, context->waitSyncPoint(sync_point)); | 365 GLC(context, context->waitSyncPoint(sync_point)); |
| 362 if (context && !lost_resource) { | |
| 363 ResourceProvider::ScopedWriteLockGL lock(resource_provider, | 366 ResourceProvider::ScopedWriteLockGL lock(resource_provider, |
| 364 data.resource_id); | 367 data.resource_id); |
| 365 GLC(context, context->bindTexture(GL_TEXTURE_2D, lock.texture_id())); | 368 GLC(context, context->bindTexture(GL_TEXTURE_2D, lock.texture_id())); |
| 366 GLC(context, context->consumeTextureCHROMIUM(GL_TEXTURE_2D, | 369 GLC(context, context->consumeTextureCHROMIUM(GL_TEXTURE_2D, |
| 367 data.mailbox.name)); | 370 data.mailbox.name)); |
| 368 GLC(context, context->bindTexture(GL_TEXTURE_2D, 0)); | 371 GLC(context, context->bindTexture(GL_TEXTURE_2D, 0)); |
| 369 } | 372 } |
| 370 | 373 |
| 371 if (!updater || lost_resource) { | 374 if (!updater) { |
| 372 resource_provider->DeleteResource(data.resource_id); | 375 resource_provider->DeleteResource(data.resource_id); |
| 373 return; | 376 return; |
| 374 } | 377 } |
| 375 | 378 |
| 376 // Drop recycled resources that are the wrong format. | 379 // Drop recycled resources that are the wrong format. |
| 377 while (!updater->recycled_resources_.empty() && | 380 while (!updater->recycled_resources_.empty() && |
| 378 updater->recycled_resources_.back().resource_format != | 381 updater->recycled_resources_.back().resource_format != |
| 379 data.resource_format) { | 382 data.resource_format) { |
| 380 resource_provider->DeleteResource( | 383 resource_provider->DeleteResource( |
| 381 updater->recycled_resources_.back().resource_id); | 384 updater->recycled_resources_.back().resource_id); |
| 382 updater->recycled_resources_.pop_back(); | 385 updater->recycled_resources_.pop_back(); |
| 383 } | 386 } |
| 384 | 387 |
| 385 PlaneResource recycled_resource(data.resource_id, | 388 PlaneResource recycled_resource(data.resource_id, |
| 386 data.resource_size, | 389 data.resource_size, |
| 387 data.resource_format, | 390 data.resource_format, |
| 388 sync_point); | 391 sync_point); |
| 389 updater->recycled_resources_.push_back(recycled_resource); | 392 updater->recycled_resources_.push_back(recycled_resource); |
| 390 } | 393 } |
| 391 | 394 |
| 392 } // namespace cc | 395 } // namespace cc |
| OLD | NEW |