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

Side by Side Diff: cc/resources/resource_provider.h

Issue 49163004: cc: Reduce command buffer flushes related to creating texture ids. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 1 month 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/raster_worker_pool_unittest.cc ('k') | cc/resources/resource_provider.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 #ifndef CC_RESOURCES_RESOURCE_PROVIDER_H_ 5 #ifndef CC_RESOURCES_RESOURCE_PROVIDER_H_
6 #define CC_RESOURCES_RESOURCE_PROVIDER_H_ 6 #define CC_RESOURCES_RESOURCE_PROVIDER_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 enum ResourceType { 58 enum ResourceType {
59 InvalidType = 0, 59 InvalidType = 0,
60 GLTexture = 1, 60 GLTexture = 1,
61 Bitmap, 61 Bitmap,
62 }; 62 };
63 63
64 static scoped_ptr<ResourceProvider> Create( 64 static scoped_ptr<ResourceProvider> Create(
65 OutputSurface* output_surface, 65 OutputSurface* output_surface,
66 SharedBitmapManager* shared_bitmap_manager, 66 SharedBitmapManager* shared_bitmap_manager,
67 int highp_threshold_min, 67 int highp_threshold_min,
68 bool use_rgba_4444_texture_format); 68 bool use_rgba_4444_texture_format,
69 size_t texture_id_allocation_chunk_size);
69 virtual ~ResourceProvider(); 70 virtual ~ResourceProvider();
70 71
71 void InitializeSoftware(); 72 void InitializeSoftware();
72 bool InitializeGL(); 73 bool InitializeGL();
73 74
74 void DidLoseOutputSurface() { lost_output_surface_ = true; } 75 void DidLoseOutputSurface() { lost_output_surface_ = true; }
75 76
76 int max_texture_size() const { return max_texture_size_; } 77 int max_texture_size() const { return max_texture_size_; }
77 ResourceFormat memory_efficient_texture_format() const { 78 ResourceFormat memory_efficient_texture_format() const {
78 return use_rgba_4444_texture_format_ ? RGBA_4444 : best_texture_format_; 79 return use_rgba_4444_texture_format_ ? RGBA_4444 : best_texture_format_;
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 typedef base::hash_map<int, Child> ChildMap; 426 typedef base::hash_map<int, Child> ChildMap;
426 427
427 bool ReadLockFenceHasPassed(Resource* resource) { 428 bool ReadLockFenceHasPassed(Resource* resource) {
428 return !resource->read_lock_fence.get() || 429 return !resource->read_lock_fence.get() ||
429 resource->read_lock_fence->HasPassed(); 430 resource->read_lock_fence->HasPassed();
430 } 431 }
431 432
432 ResourceProvider(OutputSurface* output_surface, 433 ResourceProvider(OutputSurface* output_surface,
433 SharedBitmapManager* shared_bitmap_manager, 434 SharedBitmapManager* shared_bitmap_manager,
434 int highp_threshold_min, 435 int highp_threshold_min,
435 bool use_rgba_4444_texture_format); 436 bool use_rgba_4444_texture_format,
437 size_t texture_id_allocation_chunk_size);
436 438
437 void CleanUpGLIfNeeded(); 439 void CleanUpGLIfNeeded();
438 440
439 Resource* GetResource(ResourceId id); 441 Resource* GetResource(ResourceId id);
440 const Resource* LockForRead(ResourceId id); 442 const Resource* LockForRead(ResourceId id);
441 void UnlockForRead(ResourceId id); 443 void UnlockForRead(ResourceId id);
442 const Resource* LockForWrite(ResourceId id); 444 const Resource* LockForWrite(ResourceId id);
443 void UnlockForWrite(ResourceId id); 445 void UnlockForWrite(ResourceId id);
444 static void PopulateSkBitmapWithResource(SkBitmap* sk_bitmap, 446 static void PopulateSkBitmapWithResource(SkBitmap* sk_bitmap,
445 const Resource* resource); 447 const Resource* resource);
(...skipping 16 matching lines...) Expand all
462 // specified filter for both minification and magnification. The resource 464 // specified filter for both minification and magnification. The resource
463 // must be locked for reading. 465 // must be locked for reading.
464 void BindForSampling(ResourceProvider::ResourceId resource_id, 466 void BindForSampling(ResourceProvider::ResourceId resource_id,
465 GLenum target, 467 GLenum target,
466 GLenum unit, 468 GLenum unit,
467 GLenum filter); 469 GLenum filter);
468 470
469 // Returns NULL if the output_surface_ does not have a ContextProvider. 471 // Returns NULL if the output_surface_ does not have a ContextProvider.
470 WebKit::WebGraphicsContext3D* Context3d() const; 472 WebKit::WebGraphicsContext3D* Context3d() const;
471 473
474 unsigned NextTextureId();
475
472 OutputSurface* output_surface_; 476 OutputSurface* output_surface_;
473 SharedBitmapManager* shared_bitmap_manager_; 477 SharedBitmapManager* shared_bitmap_manager_;
474 bool lost_output_surface_; 478 bool lost_output_surface_;
475 int highp_threshold_min_; 479 int highp_threshold_min_;
476 ResourceId next_id_; 480 ResourceId next_id_;
477 ResourceMap resources_; 481 ResourceMap resources_;
478 int next_child_; 482 int next_child_;
479 ChildMap children_; 483 ChildMap children_;
480 484
481 ResourceType default_resource_type_; 485 ResourceType default_resource_type_;
482 bool use_texture_storage_ext_; 486 bool use_texture_storage_ext_;
483 bool use_texture_usage_hint_; 487 bool use_texture_usage_hint_;
484 bool use_shallow_flush_; 488 bool use_shallow_flush_;
485 bool use_compressed_texture_etc1_; 489 bool use_compressed_texture_etc1_;
486 scoped_ptr<TextureUploader> texture_uploader_; 490 scoped_ptr<TextureUploader> texture_uploader_;
487 int max_texture_size_; 491 int max_texture_size_;
488 ResourceFormat best_texture_format_; 492 ResourceFormat best_texture_format_;
489 493
490 base::ThreadChecker thread_checker_; 494 base::ThreadChecker thread_checker_;
491 495
492 scoped_refptr<Fence> current_read_lock_fence_; 496 scoped_refptr<Fence> current_read_lock_fence_;
493 bool use_rgba_4444_texture_format_; 497 bool use_rgba_4444_texture_format_;
494 498
499 size_t texture_id_allocation_chunk_size_;
500 std::deque<unsigned> unused_texture_ids_;
501
495 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); 502 DISALLOW_COPY_AND_ASSIGN(ResourceProvider);
496 }; 503 };
497 504
498 505
499 // TODO(epenner): Move these format conversions to resource_format.h 506 // TODO(epenner): Move these format conversions to resource_format.h
500 // once that builds on mac (npapi.h currently #includes OpenGL.h). 507 // once that builds on mac (npapi.h currently #includes OpenGL.h).
501 inline unsigned BitsPerPixel(ResourceFormat format) { 508 inline unsigned BitsPerPixel(ResourceFormat format) {
502 DCHECK_LE(format, RESOURCE_FORMAT_MAX); 509 DCHECK_LE(format, RESOURCE_FORMAT_MAX);
503 static const unsigned format_bits_per_pixel[RESOURCE_FORMAT_MAX + 1] = { 510 static const unsigned format_bits_per_pixel[RESOURCE_FORMAT_MAX + 1] = {
504 32, // RGBA_8888 511 32, // RGBA_8888
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 return format_gl_data_format[format]; 544 return format_gl_data_format[format];
538 } 545 }
539 546
540 inline GLenum GLInternalFormat(ResourceFormat format) { 547 inline GLenum GLInternalFormat(ResourceFormat format) {
541 return GLDataFormat(format); 548 return GLDataFormat(format);
542 } 549 }
543 550
544 } // namespace cc 551 } // namespace cc
545 552
546 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ 553 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_
OLDNEW
« no previous file with comments | « cc/resources/raster_worker_pool_unittest.cc ('k') | cc/resources/resource_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698