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 12 matching lines...) Expand all Loading... | |
23 : type(NONE), hardware_resource(0) {} | 23 : type(NONE), hardware_resource(0) {} |
24 | 24 |
25 VideoFrameExternalResources::~VideoFrameExternalResources() {} | 25 VideoFrameExternalResources::~VideoFrameExternalResources() {} |
26 | 26 |
27 VideoResourceUpdater::VideoResourceUpdater(ResourceProvider* resource_provider) | 27 VideoResourceUpdater::VideoResourceUpdater(ResourceProvider* resource_provider) |
28 : resource_provider_(resource_provider) { | 28 : resource_provider_(resource_provider) { |
29 } | 29 } |
30 | 30 |
31 VideoResourceUpdater::~VideoResourceUpdater() { | 31 VideoResourceUpdater::~VideoResourceUpdater() { |
32 while (!recycled_resources_.empty()) { | 32 while (!recycled_resources_.empty()) { |
33 resource_provider_->DeleteResource(recycled_resources_.back().resource_id); | 33 resource_provider_->DeleteResource(recycled_resources_.back().resource_id); |
piman
2013/05/09 20:38:47
Don't you need to delete all resources here, rathe
danakj
2013/05/09 22:42:37
Oh gosh, yes, thanks. Since the early out in Recyc
| |
34 recycled_resources_.pop_back(); | 34 recycled_resources_.pop_back(); |
35 } | 35 } |
36 } | 36 } |
37 | 37 |
38 bool VideoResourceUpdater::VerifyFrame( | 38 bool VideoResourceUpdater::VerifyFrame( |
39 const scoped_refptr<media::VideoFrame>& video_frame) { | 39 const scoped_refptr<media::VideoFrame>& video_frame) { |
40 // If these fail, we'll have to add logic that handles offset bitmap/texture | 40 // If these fail, we'll have to add logic that handles offset bitmap/texture |
41 // UVs. For now, just expect (0, 0) offset, since all our decoders so far | 41 // UVs. For now, just expect (0, 0) offset, since all our decoders so far |
42 // don't offset. | 42 // don't offset. |
43 DCHECK_EQ(video_frame->visible_rect().x(), 0); | 43 DCHECK_EQ(video_frame->visible_rect().x(), 0); |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
348 resource_provider->DeleteResource(resource_id); | 348 resource_provider->DeleteResource(resource_id); |
349 } | 349 } |
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 if (!updater) { | |
359 // Resource was already deleted. | |
360 return; | |
361 } | |
362 | |
358 WebKit::WebGraphicsContext3D* context = | 363 WebKit::WebGraphicsContext3D* context = |
359 resource_provider->GraphicsContext3D(); | 364 resource_provider->GraphicsContext3D(); |
360 if (context && sync_point) | 365 if (context && sync_point) |
361 GLC(context, context->waitSyncPoint(sync_point)); | 366 GLC(context, context->waitSyncPoint(sync_point)); |
362 if (context && !lost_resource) { | 367 if (context && !lost_resource) { |
363 ResourceProvider::ScopedWriteLockGL lock(resource_provider, | 368 ResourceProvider::ScopedWriteLockGL lock(resource_provider, |
364 data.resource_id); | 369 data.resource_id); |
365 GLC(context, context->bindTexture(GL_TEXTURE_2D, lock.texture_id())); | 370 GLC(context, context->bindTexture(GL_TEXTURE_2D, lock.texture_id())); |
366 GLC(context, context->consumeTextureCHROMIUM(GL_TEXTURE_2D, | 371 GLC(context, context->consumeTextureCHROMIUM(GL_TEXTURE_2D, |
367 data.mailbox.name)); | 372 data.mailbox.name)); |
368 GLC(context, context->bindTexture(GL_TEXTURE_2D, 0)); | 373 GLC(context, context->bindTexture(GL_TEXTURE_2D, 0)); |
369 } | 374 } |
370 | 375 |
371 if (!updater || lost_resource) { | 376 if (lost_resource) { |
372 resource_provider->DeleteResource(data.resource_id); | 377 resource_provider->DeleteResource(data.resource_id); |
373 return; | 378 return; |
374 } | 379 } |
375 | 380 |
376 // Drop recycled resources that are the wrong format. | 381 // Drop recycled resources that are the wrong format. |
377 while (!updater->recycled_resources_.empty() && | 382 while (!updater->recycled_resources_.empty() && |
378 updater->recycled_resources_.back().resource_format != | 383 updater->recycled_resources_.back().resource_format != |
379 data.resource_format) { | 384 data.resource_format) { |
380 resource_provider->DeleteResource( | 385 resource_provider->DeleteResource( |
381 updater->recycled_resources_.back().resource_id); | 386 updater->recycled_resources_.back().resource_id); |
382 updater->recycled_resources_.pop_back(); | 387 updater->recycled_resources_.pop_back(); |
383 } | 388 } |
384 | 389 |
385 PlaneResource recycled_resource(data.resource_id, | 390 PlaneResource recycled_resource(data.resource_id, |
386 data.resource_size, | 391 data.resource_size, |
387 data.resource_format, | 392 data.resource_format, |
388 sync_point); | 393 sync_point); |
389 updater->recycled_resources_.push_back(recycled_resource); | 394 updater->recycled_resources_.push_back(recycled_resource); |
390 } | 395 } |
391 | 396 |
392 } // namespace cc | 397 } // namespace cc |
OLD | NEW |