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

Side by Side Diff: cc/raster/staging_buffer_pool.h

Issue 1861623003: cc: Refactor OneCopyTileTaskWorkerPool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dependency_task
Patch Set: rebase Created 4 years, 8 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
« no previous file with comments | « cc/raster/one_copy_tile_task_worker_pool.cc ('k') | cc/raster/staging_buffer_pool.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CC_RASTER_STAGING_BUFFER_POOL_H_
6 #define CC_RASTER_STAGING_BUFFER_POOL_H_
7
8 #include <stdint.h>
9
10 #include <deque>
11 #include <set>
12
13 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h"
15 #include "base/synchronization/lock.h"
16 #include "base/time/time.h"
17 #include "base/trace_event/memory_dump_provider.h"
18 #include "cc/output/context_provider.h"
19 #include "cc/resources/resource_provider.h"
20
21 namespace gpu {
22 namespace gles2 {
23 class GLES2Interface;
24 }
25 }
26
27 namespace cc {
28 class Resource;
29 class RasterSource;
30 class ResourcePool;
31
32 struct StagingBuffer {
33 StagingBuffer(const gfx::Size& size, ResourceFormat format);
34 ~StagingBuffer();
35
36 void DestroyGLResources(gpu::gles2::GLES2Interface* gl);
37 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd,
38 ResourceFormat format,
39 bool is_free) const;
40
41 const gfx::Size size;
42 const ResourceFormat format;
43 scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer;
44 base::TimeTicks last_usage;
45 unsigned texture_id;
46 unsigned image_id;
47 unsigned query_id;
48 uint64_t content_id;
49 };
50
51 class CC_EXPORT StagingBufferPool
52 : public base::trace_event::MemoryDumpProvider {
53 public:
54 ~StagingBufferPool() final;
55
56 static scoped_ptr<StagingBufferPool> Create(
57 base::SequencedTaskRunner* task_runner,
58 ResourceProvider* resource_provider,
59 bool use_partial_raster,
60 int max_staging_buffer_usage_in_bytes);
61 void Shutdown();
62
63 // Overridden from base::trace_event::MemoryDumpProvider:
64 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
65 base::trace_event::ProcessMemoryDump* pmd) override;
66
67 scoped_ptr<StagingBuffer> AcquireStagingBuffer(const Resource* resource,
68 uint64_t previous_content_id);
69 void ReleaseStagingBuffer(scoped_ptr<StagingBuffer> staging_buffer);
70
71 private:
72 StagingBufferPool(base::SequencedTaskRunner* task_runner,
73 ResourceProvider* resource_provider,
74 bool use_partial_raster,
75 int max_staging_buffer_usage_in_bytes);
76
77 void AddStagingBuffer(const StagingBuffer* staging_buffer,
78 ResourceFormat format);
79 void RemoveStagingBuffer(const StagingBuffer* staging_buffer);
80 void MarkStagingBufferAsFree(const StagingBuffer* staging_buffer);
81 void MarkStagingBufferAsBusy(const StagingBuffer* staging_buffer);
82
83 base::TimeTicks GetUsageTimeForLRUBuffer();
84 void ScheduleReduceMemoryUsage();
85 void ReduceMemoryUsage();
86 void ReleaseBuffersNotUsedSince(base::TimeTicks time);
87
88 scoped_ptr<base::trace_event::ConvertableToTraceFormat> StateAsValue() const;
89 void StagingStateAsValueInto(
90 base::trace_event::TracedValue* staging_state) const;
91
92 scoped_refptr<base::SequencedTaskRunner> task_runner_;
93 ResourceProvider* const resource_provider_;
94 const bool use_partial_raster_;
95
96 mutable base::Lock lock_;
97 // |lock_| must be acquired when accessing the following members.
98 using StagingBufferSet = std::set<const StagingBuffer*>;
99 StagingBufferSet buffers_;
100 using StagingBufferDeque = std::deque<scoped_ptr<StagingBuffer>>;
101 StagingBufferDeque free_buffers_;
102 StagingBufferDeque busy_buffers_;
103 const int max_staging_buffer_usage_in_bytes_;
104 int staging_buffer_usage_in_bytes_;
105 int free_staging_buffer_usage_in_bytes_;
106 const base::TimeDelta staging_buffer_expiration_delay_;
107 bool reduce_memory_usage_pending_;
108 base::Closure reduce_memory_usage_callback_;
109
110 base::WeakPtrFactory<StagingBufferPool> weak_ptr_factory_;
111
112 DISALLOW_COPY_AND_ASSIGN(StagingBufferPool);
113 };
114
115 } // namespace cc
116
117 #endif // CC_RASTER_STAGING_BUFFER_POOL_H_
OLDNEW
« no previous file with comments | « cc/raster/one_copy_tile_task_worker_pool.cc ('k') | cc/raster/staging_buffer_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698