OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_RASTER_ONE_COPY_TILE_TASK_WORKER_POOL_H_ | 5 #ifndef CC_RASTER_ONE_COPY_RASTER_BUFFER_PROVIDER_H_ |
6 #define CC_RASTER_ONE_COPY_TILE_TASK_WORKER_POOL_H_ | 6 #define CC_RASTER_ONE_COPY_RASTER_BUFFER_PROVIDER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "cc/output/context_provider.h" | 11 #include "cc/output/context_provider.h" |
12 #include "cc/raster/tile_task_worker_pool.h" | 12 #include "cc/raster/raster_buffer_provider.h" |
13 #include "cc/resources/resource_provider.h" | 13 #include "cc/resources/resource_provider.h" |
14 | 14 |
15 namespace cc { | 15 namespace cc { |
16 struct StagingBuffer; | 16 struct StagingBuffer; |
17 class StagingBufferPool; | 17 class StagingBufferPool; |
18 class ResourcePool; | 18 class ResourcePool; |
19 | 19 |
20 class CC_EXPORT OneCopyTileTaskWorkerPool : public TileTaskWorkerPool, | 20 class CC_EXPORT OneCopyRasterBufferProvider : public RasterBufferProvider { |
21 public RasterBufferProvider { | |
22 public: | 21 public: |
23 ~OneCopyTileTaskWorkerPool() override; | 22 ~OneCopyRasterBufferProvider() override; |
24 | 23 |
25 static std::unique_ptr<TileTaskWorkerPool> Create( | 24 static std::unique_ptr<RasterBufferProvider> Create( |
26 base::SequencedTaskRunner* task_runner, | 25 base::SequencedTaskRunner* task_runner, |
27 TaskGraphRunner* task_graph_runner, | |
28 ContextProvider* context_provider, | 26 ContextProvider* context_provider, |
29 ResourceProvider* resource_provider, | 27 ResourceProvider* resource_provider, |
30 int max_copy_texture_chromium_size, | 28 int max_copy_texture_chromium_size, |
31 bool use_partial_raster, | 29 bool use_partial_raster, |
32 int max_staging_buffer_usage_in_bytes, | 30 int max_staging_buffer_usage_in_bytes, |
33 ResourceFormat preferred_tile_format); | 31 ResourceFormat preferred_tile_format); |
34 | 32 |
35 // Overridden from TileTaskWorkerPool: | |
36 void Shutdown() override; | |
37 void ScheduleTasks(TaskGraph* graph) override; | |
38 void CheckForCompletedTasks() override; | |
39 ResourceFormat GetResourceFormat(bool must_support_alpha) const override; | |
40 bool GetResourceRequiresSwizzle(bool must_support_alpha) const override; | |
41 RasterBufferProvider* AsRasterBufferProvider() override; | |
42 | |
43 // Overridden from RasterBufferProvider: | 33 // Overridden from RasterBufferProvider: |
44 std::unique_ptr<RasterBuffer> AcquireBufferForRaster( | 34 std::unique_ptr<RasterBuffer> AcquireBufferForRaster( |
45 const Resource* resource, | 35 const Resource* resource, |
46 uint64_t resource_content_id, | 36 uint64_t resource_content_id, |
47 uint64_t previous_content_id) override; | 37 uint64_t previous_content_id) override; |
48 void ReleaseBufferForRaster(std::unique_ptr<RasterBuffer> buffer) override; | 38 void ReleaseBufferForRaster(std::unique_ptr<RasterBuffer> buffer) override; |
| 39 void BarrierToSyncResources() override; |
| 40 ResourceFormat GetResourceFormat(bool must_support_alpha) const override; |
| 41 bool GetResourceRequiresSwizzle(bool must_support_alpha) const override; |
49 | 42 |
50 // Playback raster source and copy result into |resource|. | 43 // Playback raster source and copy result into |resource|. |
51 void PlaybackAndCopyOnWorkerThread( | 44 void PlaybackAndCopyOnWorkerThread( |
52 const Resource* resource, | 45 const Resource* resource, |
53 ResourceProvider::ScopedWriteLockGL* resource_lock, | 46 ResourceProvider::ScopedWriteLockGL* resource_lock, |
54 const RasterSource* raster_source, | 47 const RasterSource* raster_source, |
55 const gfx::Rect& raster_full_rect, | 48 const gfx::Rect& raster_full_rect, |
56 const gfx::Rect& raster_dirty_rect, | 49 const gfx::Rect& raster_dirty_rect, |
57 float scale, | 50 float scale, |
58 const RasterSource::PlaybackSettings& playback_settings, | 51 const RasterSource::PlaybackSettings& playback_settings, |
59 uint64_t previous_content_id, | 52 uint64_t previous_content_id, |
60 uint64_t new_content_id); | 53 uint64_t new_content_id); |
61 | 54 |
62 protected: | 55 protected: |
63 OneCopyTileTaskWorkerPool(base::SequencedTaskRunner* task_runner, | 56 OneCopyRasterBufferProvider(base::SequencedTaskRunner* task_runner, |
64 TaskGraphRunner* task_graph_runner, | 57 ResourceProvider* resource_provider, |
65 ResourceProvider* resource_provider, | 58 int max_copy_texture_chromium_size, |
66 int max_copy_texture_chromium_size, | 59 bool use_partial_raster, |
67 bool use_partial_raster, | 60 int max_staging_buffer_usage_in_bytes, |
68 int max_staging_buffer_usage_in_bytes, | 61 ResourceFormat preferred_tile_format); |
69 ResourceFormat preferred_tile_format); | |
70 | 62 |
71 private: | 63 private: |
72 void PlaybackToStagingBuffer( | 64 void PlaybackToStagingBuffer( |
73 StagingBuffer* staging_buffer, | 65 StagingBuffer* staging_buffer, |
74 const Resource* resource, | 66 const Resource* resource, |
75 const RasterSource* raster_source, | 67 const RasterSource* raster_source, |
76 const gfx::Rect& raster_full_rect, | 68 const gfx::Rect& raster_full_rect, |
77 const gfx::Rect& raster_dirty_rect, | 69 const gfx::Rect& raster_dirty_rect, |
78 float scale, | 70 float scale, |
79 const RasterSource::PlaybackSettings& playback_settings, | 71 const RasterSource::PlaybackSettings& playback_settings, |
80 uint64_t previous_content_id, | 72 uint64_t previous_content_id, |
81 uint64_t new_content_id); | 73 uint64_t new_content_id); |
82 void CopyOnWorkerThread(StagingBuffer* staging_buffer, | 74 void CopyOnWorkerThread(StagingBuffer* staging_buffer, |
83 const Resource* resource, | 75 const Resource* resource, |
84 ResourceProvider::ScopedWriteLockGL* resource_lock, | 76 ResourceProvider::ScopedWriteLockGL* resource_lock, |
85 const RasterSource* raster_source, | 77 const RasterSource* raster_source, |
86 uint64_t previous_content_id, | 78 uint64_t previous_content_id, |
87 uint64_t new_content_id); | 79 uint64_t new_content_id); |
88 | 80 |
89 TaskGraphRunner* task_graph_runner_; | |
90 const NamespaceToken namespace_token_; | |
91 ResourceProvider* const resource_provider_; | 81 ResourceProvider* const resource_provider_; |
92 const int max_bytes_per_copy_operation_; | 82 const int max_bytes_per_copy_operation_; |
93 bool use_partial_raster_; | 83 bool use_partial_raster_; |
94 | 84 |
95 // Context lock must be acquired when accessing this member. | 85 // Context lock must be acquired when accessing this member. |
96 int bytes_scheduled_since_last_flush_; | 86 int bytes_scheduled_since_last_flush_; |
97 | 87 |
98 ResourceFormat preferred_tile_format_; | 88 ResourceFormat preferred_tile_format_; |
99 std::unique_ptr<StagingBufferPool> staging_pool_; | 89 std::unique_ptr<StagingBufferPool> staging_pool_; |
100 | 90 |
101 Task::Vector completed_tasks_; | 91 DISALLOW_COPY_AND_ASSIGN(OneCopyRasterBufferProvider); |
102 | |
103 DISALLOW_COPY_AND_ASSIGN(OneCopyTileTaskWorkerPool); | |
104 }; | 92 }; |
105 | 93 |
106 } // namespace cc | 94 } // namespace cc |
107 | 95 |
108 #endif // CC_RASTER_ONE_COPY_TILE_TASK_WORKER_POOL_H_ | 96 #endif // CC_RASTER_ONE_COPY_RASTER_BUFFER_PROVIDER_H_ |
OLD | NEW |