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

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

Issue 1256613002: Add tracing for GL texture objects (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@browser_process_id
Patch Set: review feedback Created 5 years, 4 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
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>
11 #include <utility> 11 #include <utility>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/basictypes.h" 14 #include "base/basictypes.h"
15 #include "base/callback.h" 15 #include "base/callback.h"
16 #include "base/containers/hash_tables.h" 16 #include "base/containers/hash_tables.h"
17 #include "base/memory/linked_ptr.h" 17 #include "base/memory/linked_ptr.h"
18 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
19 #include "base/threading/thread_checker.h" 19 #include "base/threading/thread_checker.h"
20 #include "base/trace_event/memory_allocator_dump.h"
21 #include "base/trace_event/memory_dump_provider.h"
20 #include "cc/base/cc_export.h" 22 #include "cc/base/cc_export.h"
21 #include "cc/base/resource_id.h" 23 #include "cc/base/resource_id.h"
22 #include "cc/output/context_provider.h" 24 #include "cc/output/context_provider.h"
23 #include "cc/output/output_surface.h" 25 #include "cc/output/output_surface.h"
24 #include "cc/resources/release_callback_impl.h" 26 #include "cc/resources/release_callback_impl.h"
25 #include "cc/resources/resource_format.h" 27 #include "cc/resources/resource_format.h"
26 #include "cc/resources/return_callback.h" 28 #include "cc/resources/return_callback.h"
27 #include "cc/resources/shared_bitmap.h" 29 #include "cc/resources/shared_bitmap.h"
28 #include "cc/resources/single_release_callback_impl.h" 30 #include "cc/resources/single_release_callback_impl.h"
29 #include "cc/resources/texture_mailbox.h" 31 #include "cc/resources/texture_mailbox.h"
(...skipping 20 matching lines...) Expand all
50 } 52 }
51 53
52 namespace cc { 54 namespace cc {
53 class BlockingTaskRunner; 55 class BlockingTaskRunner;
54 class IdAllocator; 56 class IdAllocator;
55 class SharedBitmap; 57 class SharedBitmap;
56 class SharedBitmapManager; 58 class SharedBitmapManager;
57 59
58 // This class is not thread-safe and can only be called from the thread it was 60 // This class is not thread-safe and can only be called from the thread it was
59 // created on (in practice, the impl thread). 61 // created on (in practice, the impl thread).
60 class CC_EXPORT ResourceProvider { 62 class CC_EXPORT ResourceProvider
63 : public base::trace_event::MemoryDumpProvider {
61 private: 64 private:
62 struct Resource; 65 struct Resource;
63 66
64 public: 67 public:
65 typedef std::vector<ResourceId> ResourceIdArray; 68 typedef std::vector<ResourceId> ResourceIdArray;
66 typedef base::hash_set<ResourceId> ResourceIdSet; 69 typedef base::hash_set<ResourceId> ResourceIdSet;
67 typedef base::hash_map<ResourceId, ResourceId> ResourceIdMap; 70 typedef base::hash_map<ResourceId, ResourceId> ResourceIdMap;
68 enum TextureHint { 71 enum TextureHint {
69 TEXTURE_HINT_DEFAULT = 0x0, 72 TEXTURE_HINT_DEFAULT = 0x0,
70 TEXTURE_HINT_IMMUTABLE = 0x1, 73 TEXTURE_HINT_IMMUTABLE = 0x1,
71 TEXTURE_HINT_FRAMEBUFFER = 0x2, 74 TEXTURE_HINT_FRAMEBUFFER = 0x2,
72 TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER = 75 TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER =
73 TEXTURE_HINT_IMMUTABLE | TEXTURE_HINT_FRAMEBUFFER 76 TEXTURE_HINT_IMMUTABLE | TEXTURE_HINT_FRAMEBUFFER
74 }; 77 };
75 enum ResourceType { 78 enum ResourceType {
76 RESOURCE_TYPE_GL_TEXTURE, 79 RESOURCE_TYPE_GL_TEXTURE,
77 RESOURCE_TYPE_BITMAP, 80 RESOURCE_TYPE_BITMAP,
78 }; 81 };
79 82
80 static scoped_ptr<ResourceProvider> Create( 83 static scoped_ptr<ResourceProvider> Create(
81 OutputSurface* output_surface, 84 OutputSurface* output_surface,
82 SharedBitmapManager* shared_bitmap_manager, 85 SharedBitmapManager* shared_bitmap_manager,
83 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, 86 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
84 BlockingTaskRunner* blocking_main_thread_task_runner, 87 BlockingTaskRunner* blocking_main_thread_task_runner,
85 int highp_threshold_min, 88 int highp_threshold_min,
86 bool use_rgba_4444_texture_format, 89 bool use_rgba_4444_texture_format,
87 size_t id_allocation_chunk_size, 90 size_t id_allocation_chunk_size,
88 bool use_persistent_map_for_gpu_memory_buffers); 91 bool use_persistent_map_for_gpu_memory_buffers);
89 virtual ~ResourceProvider(); 92 ~ResourceProvider() override;
90 93
91 void DidLoseOutputSurface() { lost_output_surface_ = true; } 94 void DidLoseOutputSurface() { lost_output_surface_ = true; }
92 95
93 int max_texture_size() const { return max_texture_size_; } 96 int max_texture_size() const { return max_texture_size_; }
94 ResourceFormat memory_efficient_texture_format() const { 97 ResourceFormat memory_efficient_texture_format() const {
95 return use_rgba_4444_texture_format_ ? RGBA_4444 : best_texture_format_; 98 return use_rgba_4444_texture_format_ ? RGBA_4444 : best_texture_format_;
96 } 99 }
97 ResourceFormat best_texture_format() const { return best_texture_format_; } 100 ResourceFormat best_texture_format() const { return best_texture_format_; }
98 ResourceFormat best_render_buffer_format() const { 101 ResourceFormat best_render_buffer_format() const {
99 return best_render_buffer_format_; 102 return best_render_buffer_format_;
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 void WaitSyncPointIfNeeded(ResourceId id); 434 void WaitSyncPointIfNeeded(ResourceId id);
432 435
433 void WaitReadLockIfNeeded(ResourceId id); 436 void WaitReadLockIfNeeded(ResourceId id);
434 437
435 static GLint GetActiveTextureUnit(gpu::gles2::GLES2Interface* gl); 438 static GLint GetActiveTextureUnit(gpu::gles2::GLES2Interface* gl);
436 439
437 OutputSurface* output_surface() { return output_surface_; } 440 OutputSurface* output_surface() { return output_surface_; }
438 441
439 void ValidateResource(ResourceId id) const; 442 void ValidateResource(ResourceId id) const;
440 443
444 // base::trace_event::MemoryDumpProvider implementation.
445 bool OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd) override;
446
441 protected: 447 protected:
442 ResourceProvider(OutputSurface* output_surface, 448 ResourceProvider(OutputSurface* output_surface,
443 SharedBitmapManager* shared_bitmap_manager, 449 SharedBitmapManager* shared_bitmap_manager,
444 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, 450 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
445 BlockingTaskRunner* blocking_main_thread_task_runner, 451 BlockingTaskRunner* blocking_main_thread_task_runner,
446 int highp_threshold_min, 452 int highp_threshold_min,
447 bool use_rgba_4444_texture_format, 453 bool use_rgba_4444_texture_format,
448 size_t id_allocation_chunk_size, 454 size_t id_allocation_chunk_size,
449 bool use_persistent_map_for_gpu_memory_buffers); 455 bool use_persistent_map_for_gpu_memory_buffers);
450 void Initialize(); 456 void Initialize();
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 void BindImageForSampling(Resource* resource); 569 void BindImageForSampling(Resource* resource);
564 // Binds the given GL resource to a texture target for sampling using the 570 // Binds the given GL resource to a texture target for sampling using the
565 // specified filter for both minification and magnification. Returns the 571 // specified filter for both minification and magnification. Returns the
566 // texture target used. The resource must be locked for reading. 572 // texture target used. The resource must be locked for reading.
567 GLenum BindForSampling(ResourceId resource_id, GLenum unit, GLenum filter); 573 GLenum BindForSampling(ResourceId resource_id, GLenum unit, GLenum filter);
568 574
569 // Returns NULL if the output_surface_ does not have a ContextProvider. 575 // Returns NULL if the output_surface_ does not have a ContextProvider.
570 gpu::gles2::GLES2Interface* ContextGL() const; 576 gpu::gles2::GLES2Interface* ContextGL() const;
571 class GrContext* GrContext(bool worker_context) const; 577 class GrContext* GrContext(bool worker_context) const;
572 578
579 base::trace_event::MemoryAllocatorDump* DumpForResource(
580 base::trace_event::ProcessMemoryDump* pmd,
581 const ResourceId& id,
reveman 2015/07/28 21:38:49 nit: no need to pass the id by reference
ericrk 2015/07/29 18:46:46 removed this fn.
582 const Resource& resource) const;
583
573 OutputSurface* output_surface_; 584 OutputSurface* output_surface_;
574 SharedBitmapManager* shared_bitmap_manager_; 585 SharedBitmapManager* shared_bitmap_manager_;
575 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; 586 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_;
576 BlockingTaskRunner* blocking_main_thread_task_runner_; 587 BlockingTaskRunner* blocking_main_thread_task_runner_;
577 bool lost_output_surface_; 588 bool lost_output_surface_;
578 int highp_threshold_min_; 589 int highp_threshold_min_;
579 ResourceId next_id_; 590 ResourceId next_id_;
580 ResourceMap resources_; 591 ResourceMap resources_;
581 int next_child_; 592 int next_child_;
582 ChildMap children_; 593 ChildMap children_;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 return format_gl_data_format[format]; 670 return format_gl_data_format[format];
660 } 671 }
661 672
662 inline GLenum GLInternalFormat(ResourceFormat format) { 673 inline GLenum GLInternalFormat(ResourceFormat format) {
663 return GLDataFormat(format); 674 return GLDataFormat(format);
664 } 675 }
665 676
666 } // namespace cc 677 } // namespace cc
667 678
668 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ 679 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698