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_RASTER_BUFFER_PROVIDER_H_ | 5 #ifndef CC_RASTER_ONE_COPY_RASTER_BUFFER_PROVIDER_H_ |
6 #define CC_RASTER_ONE_COPY_RASTER_BUFFER_PROVIDER_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/raster_buffer_provider.h" | 12 #include "cc/raster/raster_buffer_provider.h" |
13 #include "cc/raster/staging_buffer_pool.h" | 13 #include "cc/raster/staging_buffer_pool.h" |
14 #include "cc/resources/resource_provider.h" | 14 #include "cc/resources/resource_provider.h" |
15 #include "gpu/command_buffer/common/sync_token.h" | |
16 | 15 |
17 namespace cc { | 16 namespace cc { |
18 struct StagingBuffer; | 17 struct StagingBuffer; |
19 class StagingBufferPool; | 18 class StagingBufferPool; |
20 class ResourcePool; | 19 class ResourcePool; |
21 | 20 |
22 class CC_EXPORT OneCopyRasterBufferProvider : public RasterBufferProvider { | 21 class CC_EXPORT OneCopyRasterBufferProvider : public RasterBufferProvider { |
23 public: | 22 public: |
24 OneCopyRasterBufferProvider(base::SequencedTaskRunner* task_runner, | 23 OneCopyRasterBufferProvider(base::SequencedTaskRunner* task_runner, |
25 ContextProvider* compositor_context_provider, | 24 ContextProvider* compositor_context_provider, |
26 ContextProvider* worker_context_provider, | 25 ContextProvider* worker_context_provider, |
27 ResourceProvider* resource_provider, | 26 ResourceProvider* resource_provider, |
28 int max_copy_texture_chromium_size, | 27 int max_copy_texture_chromium_size, |
29 bool use_partial_raster, | 28 bool use_partial_raster, |
30 int max_staging_buffer_usage_in_bytes, | 29 int max_staging_buffer_usage_in_bytes, |
31 ResourceFormat preferred_tile_format, | 30 ResourceFormat preferred_tile_format); |
32 bool async_worker_context_enabled); | |
33 ~OneCopyRasterBufferProvider() override; | 31 ~OneCopyRasterBufferProvider() override; |
34 | 32 |
35 // Overridden from RasterBufferProvider: | 33 // Overridden from RasterBufferProvider: |
36 std::unique_ptr<RasterBuffer> AcquireBufferForRaster( | 34 std::unique_ptr<RasterBuffer> AcquireBufferForRaster( |
37 const Resource* resource, | 35 const Resource* resource, |
38 uint64_t resource_content_id, | 36 uint64_t resource_content_id, |
39 uint64_t previous_content_id) override; | 37 uint64_t previous_content_id) override; |
40 void ReleaseBufferForRaster(std::unique_ptr<RasterBuffer> buffer) override; | 38 void ReleaseBufferForRaster(std::unique_ptr<RasterBuffer> buffer) override; |
41 void OrderingBarrier() override; | 39 void OrderingBarrier() override; |
42 ResourceFormat GetResourceFormat(bool must_support_alpha) const override; | 40 ResourceFormat GetResourceFormat(bool must_support_alpha) const override; |
43 bool GetResourceRequiresSwizzle(bool must_support_alpha) const override; | 41 bool GetResourceRequiresSwizzle(bool must_support_alpha) const override; |
44 void Shutdown() override; | 42 void Shutdown() override; |
45 | 43 |
46 // Playback raster source and copy result into |resource|. | 44 // Playback raster source and copy result into |resource|. |
47 void PlaybackAndCopyOnWorkerThread( | 45 void PlaybackAndCopyOnWorkerThread( |
48 const Resource* resource, | 46 const Resource* resource, |
49 ResourceProvider::ScopedWriteLockGL* resource_lock, | 47 ResourceProvider::ScopedWriteLockGL* resource_lock, |
50 const gpu::SyncToken& sync_token, | |
51 const RasterSource* raster_source, | 48 const RasterSource* raster_source, |
52 const gfx::Rect& raster_full_rect, | 49 const gfx::Rect& raster_full_rect, |
53 const gfx::Rect& raster_dirty_rect, | 50 const gfx::Rect& raster_dirty_rect, |
54 float scale, | 51 float scale, |
55 const RasterSource::PlaybackSettings& playback_settings, | 52 const RasterSource::PlaybackSettings& playback_settings, |
56 uint64_t previous_content_id, | 53 uint64_t previous_content_id, |
57 uint64_t new_content_id); | 54 uint64_t new_content_id); |
58 | 55 |
59 private: | 56 private: |
60 class RasterBufferImpl : public RasterBuffer { | |
61 public: | |
62 RasterBufferImpl(OneCopyRasterBufferProvider* client, | |
63 ResourceProvider* resource_provider, | |
64 const Resource* resource, | |
65 uint64_t previous_content_id, | |
66 bool async_worker_context_enabled); | |
67 ~RasterBufferImpl() override; | |
68 | |
69 // Overridden from RasterBuffer: | |
70 void Playback( | |
71 const RasterSource* raster_source, | |
72 const gfx::Rect& raster_full_rect, | |
73 const gfx::Rect& raster_dirty_rect, | |
74 uint64_t new_content_id, | |
75 float scale, | |
76 const RasterSource::PlaybackSettings& playback_settings) override; | |
77 | |
78 void set_sync_token(const gpu::SyncToken& sync_token) { | |
79 sync_token_ = sync_token; | |
80 } | |
81 | |
82 private: | |
83 OneCopyRasterBufferProvider* client_; | |
84 const Resource* resource_; | |
85 ResourceProvider::ScopedWriteLockGL lock_; | |
86 uint64_t previous_content_id_; | |
87 | |
88 gpu::SyncToken sync_token_; | |
89 | |
90 DISALLOW_COPY_AND_ASSIGN(RasterBufferImpl); | |
91 }; | |
92 | |
93 void PlaybackToStagingBuffer( | 57 void PlaybackToStagingBuffer( |
94 StagingBuffer* staging_buffer, | 58 StagingBuffer* staging_buffer, |
95 const Resource* resource, | 59 const Resource* resource, |
96 const RasterSource* raster_source, | 60 const RasterSource* raster_source, |
97 const gfx::Rect& raster_full_rect, | 61 const gfx::Rect& raster_full_rect, |
98 const gfx::Rect& raster_dirty_rect, | 62 const gfx::Rect& raster_dirty_rect, |
99 float scale, | 63 float scale, |
100 const RasterSource::PlaybackSettings& playback_settings, | 64 const RasterSource::PlaybackSettings& playback_settings, |
101 uint64_t previous_content_id, | 65 uint64_t previous_content_id, |
102 uint64_t new_content_id); | 66 uint64_t new_content_id); |
103 void CopyOnWorkerThread(StagingBuffer* staging_buffer, | 67 void CopyOnWorkerThread(StagingBuffer* staging_buffer, |
| 68 const Resource* resource, |
104 ResourceProvider::ScopedWriteLockGL* resource_lock, | 69 ResourceProvider::ScopedWriteLockGL* resource_lock, |
105 const gpu::SyncToken& sync_token, | |
106 const RasterSource* raster_source, | 70 const RasterSource* raster_source, |
107 uint64_t previous_content_id, | 71 uint64_t previous_content_id, |
108 uint64_t new_content_id); | 72 uint64_t new_content_id); |
109 | 73 |
110 ContextProvider* const compositor_context_provider_; | 74 ContextProvider* const compositor_context_provider_; |
111 ContextProvider* const worker_context_provider_; | 75 ContextProvider* const worker_context_provider_; |
112 ResourceProvider* const resource_provider_; | 76 ResourceProvider* const resource_provider_; |
113 const int max_bytes_per_copy_operation_; | 77 const int max_bytes_per_copy_operation_; |
114 const bool use_partial_raster_; | 78 bool use_partial_raster_; |
115 | 79 |
116 // Context lock must be acquired when accessing this member. | 80 // Context lock must be acquired when accessing this member. |
117 int bytes_scheduled_since_last_flush_; | 81 int bytes_scheduled_since_last_flush_; |
118 | 82 |
119 const ResourceFormat preferred_tile_format_; | 83 ResourceFormat preferred_tile_format_; |
120 StagingBufferPool staging_pool_; | 84 StagingBufferPool staging_pool_; |
121 | 85 |
122 const bool async_worker_context_enabled_; | |
123 | |
124 std::set<RasterBufferImpl*> pending_raster_buffers_; | |
125 | |
126 DISALLOW_COPY_AND_ASSIGN(OneCopyRasterBufferProvider); | 86 DISALLOW_COPY_AND_ASSIGN(OneCopyRasterBufferProvider); |
127 }; | 87 }; |
128 | 88 |
129 } // namespace cc | 89 } // namespace cc |
130 | 90 |
131 #endif // CC_RASTER_ONE_COPY_RASTER_BUFFER_PROVIDER_H_ | 91 #endif // CC_RASTER_ONE_COPY_RASTER_BUFFER_PROVIDER_H_ |
OLD | NEW |