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

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

Issue 58603002: cc: Reduce command buffer flushes related to creating buffer ids. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | « no previous file | 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 21 matching lines...) Expand all
32 #include "ui/gfx/size.h" 32 #include "ui/gfx/size.h"
33 33
34 namespace WebKit { class WebGraphicsContext3D; } 34 namespace WebKit { class WebGraphicsContext3D; }
35 35
36 namespace gfx { 36 namespace gfx {
37 class Rect; 37 class Rect;
38 class Vector2d; 38 class Vector2d;
39 } 39 }
40 40
41 namespace cc { 41 namespace cc {
42 class IdAllocator;
42 class SharedBitmap; 43 class SharedBitmap;
43 class SharedBitmapManager; 44 class SharedBitmapManager;
44 class TextureUploader; 45 class TextureUploader;
45 46
46 // This class is not thread-safe and can only be called from the thread it was 47 // This class is not thread-safe and can only be called from the thread it was
47 // created on (in practice, the impl thread). 48 // created on (in practice, the impl thread).
48 class CC_EXPORT ResourceProvider { 49 class CC_EXPORT ResourceProvider {
49 public: 50 public:
50 typedef unsigned ResourceId; 51 typedef unsigned ResourceId;
51 typedef std::vector<ResourceId> ResourceIdArray; 52 typedef std::vector<ResourceId> ResourceIdArray;
52 typedef std::set<ResourceId> ResourceIdSet; 53 typedef std::set<ResourceId> ResourceIdSet;
53 typedef base::hash_map<ResourceId, ResourceId> ResourceIdMap; 54 typedef base::hash_map<ResourceId, ResourceId> ResourceIdMap;
54 enum TextureUsageHint { 55 enum TextureUsageHint {
55 TextureUsageAny, 56 TextureUsageAny,
56 TextureUsageFramebuffer, 57 TextureUsageFramebuffer,
57 }; 58 };
58 enum ResourceType { 59 enum ResourceType {
59 InvalidType = 0, 60 InvalidType = 0,
60 GLTexture = 1, 61 GLTexture = 1,
61 Bitmap, 62 Bitmap,
62 }; 63 };
63 64
64 static scoped_ptr<ResourceProvider> Create( 65 static scoped_ptr<ResourceProvider> Create(
65 OutputSurface* output_surface, 66 OutputSurface* output_surface,
66 SharedBitmapManager* shared_bitmap_manager, 67 SharedBitmapManager* shared_bitmap_manager,
67 int highp_threshold_min, 68 int highp_threshold_min,
68 bool use_rgba_4444_texture_format, 69 bool use_rgba_4444_texture_format,
69 size_t texture_id_allocation_chunk_size); 70 size_t id_allocation_chunk_size);
70 virtual ~ResourceProvider(); 71 virtual ~ResourceProvider();
71 72
72 void InitializeSoftware(); 73 void InitializeSoftware();
73 bool InitializeGL(); 74 bool InitializeGL();
74 75
75 void DidLoseOutputSurface() { lost_output_surface_ = true; } 76 void DidLoseOutputSurface() { lost_output_surface_ = true; }
76 77
77 int max_texture_size() const { return max_texture_size_; } 78 int max_texture_size() const { return max_texture_size_; }
78 ResourceFormat memory_efficient_texture_format() const { 79 ResourceFormat memory_efficient_texture_format() const {
79 return use_rgba_4444_texture_format_ ? RGBA_4444 : best_texture_format_; 80 return use_rgba_4444_texture_format_ ? RGBA_4444 : best_texture_format_;
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 428
428 bool ReadLockFenceHasPassed(Resource* resource) { 429 bool ReadLockFenceHasPassed(Resource* resource) {
429 return !resource->read_lock_fence.get() || 430 return !resource->read_lock_fence.get() ||
430 resource->read_lock_fence->HasPassed(); 431 resource->read_lock_fence->HasPassed();
431 } 432 }
432 433
433 ResourceProvider(OutputSurface* output_surface, 434 ResourceProvider(OutputSurface* output_surface,
434 SharedBitmapManager* shared_bitmap_manager, 435 SharedBitmapManager* shared_bitmap_manager,
435 int highp_threshold_min, 436 int highp_threshold_min,
436 bool use_rgba_4444_texture_format, 437 bool use_rgba_4444_texture_format,
437 size_t texture_id_allocation_chunk_size); 438 size_t id_allocation_chunk_size);
438 439
439 void CleanUpGLIfNeeded(); 440 void CleanUpGLIfNeeded();
440 441
441 Resource* GetResource(ResourceId id); 442 Resource* GetResource(ResourceId id);
442 const Resource* LockForRead(ResourceId id); 443 const Resource* LockForRead(ResourceId id);
443 void UnlockForRead(ResourceId id); 444 void UnlockForRead(ResourceId id);
444 const Resource* LockForWrite(ResourceId id); 445 const Resource* LockForWrite(ResourceId id);
445 void UnlockForWrite(ResourceId id); 446 void UnlockForWrite(ResourceId id);
446 static void PopulateSkBitmapWithResource(SkBitmap* sk_bitmap, 447 static void PopulateSkBitmapWithResource(SkBitmap* sk_bitmap,
447 const Resource* resource); 448 const Resource* resource);
(...skipping 16 matching lines...) Expand all
464 // specified filter for both minification and magnification. The resource 465 // specified filter for both minification and magnification. The resource
465 // must be locked for reading. 466 // must be locked for reading.
466 void BindForSampling(ResourceProvider::ResourceId resource_id, 467 void BindForSampling(ResourceProvider::ResourceId resource_id,
467 GLenum target, 468 GLenum target,
468 GLenum unit, 469 GLenum unit,
469 GLenum filter); 470 GLenum filter);
470 471
471 // Returns NULL if the output_surface_ does not have a ContextProvider. 472 // Returns NULL if the output_surface_ does not have a ContextProvider.
472 WebKit::WebGraphicsContext3D* Context3d() const; 473 WebKit::WebGraphicsContext3D* Context3d() const;
473 474
474 unsigned NextTextureId();
475
476 OutputSurface* output_surface_; 475 OutputSurface* output_surface_;
477 SharedBitmapManager* shared_bitmap_manager_; 476 SharedBitmapManager* shared_bitmap_manager_;
478 bool lost_output_surface_; 477 bool lost_output_surface_;
479 int highp_threshold_min_; 478 int highp_threshold_min_;
480 ResourceId next_id_; 479 ResourceId next_id_;
481 ResourceMap resources_; 480 ResourceMap resources_;
482 int next_child_; 481 int next_child_;
483 ChildMap children_; 482 ChildMap children_;
484 483
485 ResourceType default_resource_type_; 484 ResourceType default_resource_type_;
486 bool use_texture_storage_ext_; 485 bool use_texture_storage_ext_;
487 bool use_texture_usage_hint_; 486 bool use_texture_usage_hint_;
488 bool use_shallow_flush_; 487 bool use_shallow_flush_;
489 bool use_compressed_texture_etc1_; 488 bool use_compressed_texture_etc1_;
490 scoped_ptr<TextureUploader> texture_uploader_; 489 scoped_ptr<TextureUploader> texture_uploader_;
491 int max_texture_size_; 490 int max_texture_size_;
492 ResourceFormat best_texture_format_; 491 ResourceFormat best_texture_format_;
493 492
494 base::ThreadChecker thread_checker_; 493 base::ThreadChecker thread_checker_;
495 494
496 scoped_refptr<Fence> current_read_lock_fence_; 495 scoped_refptr<Fence> current_read_lock_fence_;
497 bool use_rgba_4444_texture_format_; 496 bool use_rgba_4444_texture_format_;
498 497
499 size_t texture_id_allocation_chunk_size_; 498 const size_t id_allocation_chunk_size_;
500 std::deque<unsigned> unused_texture_ids_; 499 scoped_ptr<IdAllocator> texture_id_allocator_;
500 scoped_ptr<IdAllocator> buffer_id_allocator_;
501 501
502 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); 502 DISALLOW_COPY_AND_ASSIGN(ResourceProvider);
503 }; 503 };
504 504
505 505
506 // TODO(epenner): Move these format conversions to resource_format.h 506 // TODO(epenner): Move these format conversions to resource_format.h
507 // once that builds on mac (npapi.h currently #includes OpenGL.h). 507 // once that builds on mac (npapi.h currently #includes OpenGL.h).
508 inline unsigned BitsPerPixel(ResourceFormat format) { 508 inline unsigned BitsPerPixel(ResourceFormat format) {
509 DCHECK_LE(format, RESOURCE_FORMAT_MAX); 509 DCHECK_LE(format, RESOURCE_FORMAT_MAX);
510 static const unsigned format_bits_per_pixel[RESOURCE_FORMAT_MAX + 1] = { 510 static const unsigned format_bits_per_pixel[RESOURCE_FORMAT_MAX + 1] = {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 return format_gl_data_format[format]; 544 return format_gl_data_format[format];
545 } 545 }
546 546
547 inline GLenum GLInternalFormat(ResourceFormat format) { 547 inline GLenum GLInternalFormat(ResourceFormat format) {
548 return GLDataFormat(format); 548 return GLDataFormat(format);
549 } 549 }
550 550
551 } // namespace cc 551 } // namespace cc
552 552
553 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ 553 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_
OLDNEW
« no previous file with comments | « no previous file | cc/resources/resource_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698