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

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

Issue 14925009: Run all LayerTreeHost tests with a delegating renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: uber-unittests: for landing2 Created 7 years, 7 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/layer_tree_pixel_test.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 11 matching lines...) Expand all
22 VideoFrameExternalResources::VideoFrameExternalResources() 22 VideoFrameExternalResources::VideoFrameExternalResources()
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 (!all_resources_.empty()) {
33 resource_provider_->DeleteResource(recycled_resources_.back().resource_id); 33 resource_provider_->DeleteResource(all_resources_.back());
34 recycled_resources_.pop_back(); 34 all_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);
44 DCHECK_EQ(video_frame->visible_rect().y(), 0); 44 DCHECK_EQ(video_frame->visible_rect().y(), 0);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 } 169 }
170 } 170 }
171 171
172 if (resource_id == 0) { 172 if (resource_id == 0) {
173 // TODO(danakj): Abstract out hw/sw resource create/delete from 173 // TODO(danakj): Abstract out hw/sw resource create/delete from
174 // ResourceProvider and stop using ResourceProvider in this class. 174 // ResourceProvider and stop using ResourceProvider in this class.
175 resource_id = 175 resource_id =
176 resource_provider_->CreateResource(output_plane_resource_size, 176 resource_provider_->CreateResource(output_plane_resource_size,
177 output_resource_format, 177 output_resource_format,
178 ResourceProvider::TextureUsageAny); 178 ResourceProvider::TextureUsageAny);
179 if (resource_id)
180 all_resources_.push_back(resource_id);
179 } 181 }
180 182
181 if (resource_id == 0) { 183 if (resource_id == 0) {
182 allocation_success = false; 184 allocation_success = false;
183 break; 185 break;
184 } 186 }
185 187
186 plane_resources.push_back(PlaneResource(resource_id, 188 plane_resources.push_back(PlaneResource(resource_id,
187 output_plane_resource_size, 189 output_plane_resource_size,
188 output_resource_format, 190 output_resource_format,
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 break; 325 break;
324 default: 326 default:
325 NOTREACHED(); 327 NOTREACHED();
326 return VideoFrameExternalResources(); 328 return VideoFrameExternalResources();
327 } 329 }
328 330
329 external_resources.hardware_resource = 331 external_resources.hardware_resource =
330 resource_provider_->CreateResourceFromExternalTexture( 332 resource_provider_->CreateResourceFromExternalTexture(
331 video_frame->texture_target(), 333 video_frame->texture_target(),
332 video_frame->texture_id()); 334 video_frame->texture_id());
335 if (external_resources.hardware_resource)
336 all_resources_.push_back(external_resources.hardware_resource);
333 337
334 TextureMailbox::ReleaseCallback callback_to_return_resource = 338 TextureMailbox::ReleaseCallback callback_to_return_resource =
335 base::Bind(&ReturnTexture, 339 base::Bind(&ReturnTexture,
340 AsWeakPtr(),
336 base::Unretained(resource_provider_), 341 base::Unretained(resource_provider_),
337 external_resources.hardware_resource); 342 external_resources.hardware_resource);
338 external_resources.hardware_release_callback = callback_to_return_resource; 343 external_resources.hardware_release_callback = callback_to_return_resource;
339 return external_resources; 344 return external_resources;
340 } 345 }
341 346
342 // static 347 // static
343 void VideoResourceUpdater::ReturnTexture( 348 void VideoResourceUpdater::ReturnTexture(
349 base::WeakPtr<VideoResourceUpdater> updater,
344 ResourceProvider* resource_provider, 350 ResourceProvider* resource_provider,
345 unsigned resource_id, 351 unsigned resource_id,
346 unsigned sync_point, 352 unsigned sync_point,
347 bool lost_resource) { 353 bool lost_resource) {
354 if (!updater) {
355 // Resource was already deleted.
356 return;
357 }
358
348 resource_provider->DeleteResource(resource_id); 359 resource_provider->DeleteResource(resource_id);
360 std::vector<unsigned>& all_resources = updater->all_resources_;
361 all_resources.erase(std::remove(all_resources.begin(),
362 all_resources.end(),
363 resource_id));
349 } 364 }
350 365
351 // static 366 // static
352 void VideoResourceUpdater::RecycleResource( 367 void VideoResourceUpdater::RecycleResource(
353 base::WeakPtr<VideoResourceUpdater> updater, 368 base::WeakPtr<VideoResourceUpdater> updater,
354 ResourceProvider* resource_provider, 369 ResourceProvider* resource_provider,
355 RecycleResourceData data, 370 RecycleResourceData data,
356 unsigned sync_point, 371 unsigned sync_point,
357 bool lost_resource) { 372 bool lost_resource) {
373 if (!updater) {
374 // Resource was already deleted.
375 return;
376 }
377
358 WebKit::WebGraphicsContext3D* context = 378 WebKit::WebGraphicsContext3D* context =
359 resource_provider->GraphicsContext3D(); 379 resource_provider->GraphicsContext3D();
360 if (context && sync_point) 380 if (context && sync_point)
361 GLC(context, context->waitSyncPoint(sync_point)); 381 GLC(context, context->waitSyncPoint(sync_point));
362 if (context && !lost_resource) { 382 if (context && !lost_resource) {
363 ResourceProvider::ScopedWriteLockGL lock(resource_provider, 383 ResourceProvider::ScopedWriteLockGL lock(resource_provider,
364 data.resource_id); 384 data.resource_id);
365 GLC(context, context->bindTexture(GL_TEXTURE_2D, lock.texture_id())); 385 GLC(context, context->bindTexture(GL_TEXTURE_2D, lock.texture_id()));
366 GLC(context, context->consumeTextureCHROMIUM(GL_TEXTURE_2D, 386 GLC(context, context->consumeTextureCHROMIUM(GL_TEXTURE_2D,
367 data.mailbox.name)); 387 data.mailbox.name));
368 GLC(context, context->bindTexture(GL_TEXTURE_2D, 0)); 388 GLC(context, context->bindTexture(GL_TEXTURE_2D, 0));
369 } 389 }
370 390
371 if (!updater || lost_resource) { 391 if (lost_resource) {
372 resource_provider->DeleteResource(data.resource_id); 392 resource_provider->DeleteResource(data.resource_id);
393 std::vector<unsigned>& all_resources = updater->all_resources_;
394 all_resources.erase(std::remove(all_resources.begin(),
395 all_resources.end(),
396 data.resource_id));
373 return; 397 return;
374 } 398 }
375 399
376 // Drop recycled resources that are the wrong format. 400 // Drop recycled resources that are the wrong format.
377 while (!updater->recycled_resources_.empty() && 401 while (!updater->recycled_resources_.empty() &&
378 updater->recycled_resources_.back().resource_format != 402 updater->recycled_resources_.back().resource_format !=
379 data.resource_format) { 403 data.resource_format) {
380 resource_provider->DeleteResource( 404 resource_provider->DeleteResource(
381 updater->recycled_resources_.back().resource_id); 405 updater->recycled_resources_.back().resource_id);
382 updater->recycled_resources_.pop_back(); 406 updater->recycled_resources_.pop_back();
383 } 407 }
384 408
385 PlaneResource recycled_resource(data.resource_id, 409 PlaneResource recycled_resource(data.resource_id,
386 data.resource_size, 410 data.resource_size,
387 data.resource_format, 411 data.resource_format,
388 sync_point); 412 sync_point);
389 updater->recycled_resources_.push_back(recycled_resource); 413 updater->recycled_resources_.push_back(recycled_resource);
390 } 414 }
391 415
392 } // namespace cc 416 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/video_resource_updater.h ('k') | cc/test/layer_tree_pixel_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698