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

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

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

Powered by Google App Engine
This is Rietveld 408576698