| 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/resources/resource_provider.h" | 14 #include "cc/resources/resource_provider.h" |
| 14 | 15 |
| 15 namespace cc { | 16 namespace cc { |
| 16 struct StagingBuffer; | 17 struct StagingBuffer; |
| 17 class StagingBufferPool; | 18 class StagingBufferPool; |
| 18 class ResourcePool; | 19 class ResourcePool; |
| 19 | 20 |
| 20 class CC_EXPORT OneCopyRasterBufferProvider : public RasterBufferProvider { | 21 class CC_EXPORT OneCopyRasterBufferProvider : public RasterBufferProvider { |
| 21 public: | 22 public: |
| 23 OneCopyRasterBufferProvider(base::SequencedTaskRunner* task_runner, |
| 24 ContextProvider* compositor_context_provider, |
| 25 ContextProvider* worker_context_provider, |
| 26 ResourceProvider* resource_provider, |
| 27 int max_copy_texture_chromium_size, |
| 28 bool use_partial_raster, |
| 29 int max_staging_buffer_usage_in_bytes, |
| 30 ResourceFormat preferred_tile_format); |
| 22 ~OneCopyRasterBufferProvider() override; | 31 ~OneCopyRasterBufferProvider() override; |
| 23 | 32 |
| 24 static std::unique_ptr<RasterBufferProvider> Create( | |
| 25 base::SequencedTaskRunner* task_runner, | |
| 26 ContextProvider* context_provider, | |
| 27 ResourceProvider* resource_provider, | |
| 28 int max_copy_texture_chromium_size, | |
| 29 bool use_partial_raster, | |
| 30 int max_staging_buffer_usage_in_bytes, | |
| 31 ResourceFormat preferred_tile_format); | |
| 32 | |
| 33 // Overridden from RasterBufferProvider: | 33 // Overridden from RasterBufferProvider: |
| 34 std::unique_ptr<RasterBuffer> AcquireBufferForRaster( | 34 std::unique_ptr<RasterBuffer> AcquireBufferForRaster( |
| 35 const Resource* resource, | 35 const Resource* resource, |
| 36 uint64_t resource_content_id, | 36 uint64_t resource_content_id, |
| 37 uint64_t previous_content_id) override; | 37 uint64_t previous_content_id) override; |
| 38 void ReleaseBufferForRaster(std::unique_ptr<RasterBuffer> buffer) override; | 38 void ReleaseBufferForRaster(std::unique_ptr<RasterBuffer> buffer) override; |
| 39 void OrderingBarrier() override; | 39 void OrderingBarrier() override; |
| 40 ResourceFormat GetResourceFormat(bool must_support_alpha) const override; | 40 ResourceFormat GetResourceFormat(bool must_support_alpha) const override; |
| 41 bool GetResourceRequiresSwizzle(bool must_support_alpha) const override; | 41 bool GetResourceRequiresSwizzle(bool must_support_alpha) const override; |
| 42 void Shutdown() override; | 42 void Shutdown() override; |
| 43 | 43 |
| 44 // Playback raster source and copy result into |resource|. | 44 // Playback raster source and copy result into |resource|. |
| 45 void PlaybackAndCopyOnWorkerThread( | 45 void PlaybackAndCopyOnWorkerThread( |
| 46 const Resource* resource, | 46 const Resource* resource, |
| 47 ResourceProvider::ScopedWriteLockGL* resource_lock, | 47 ResourceProvider::ScopedWriteLockGL* resource_lock, |
| 48 const RasterSource* raster_source, | 48 const RasterSource* raster_source, |
| 49 const gfx::Rect& raster_full_rect, | 49 const gfx::Rect& raster_full_rect, |
| 50 const gfx::Rect& raster_dirty_rect, | 50 const gfx::Rect& raster_dirty_rect, |
| 51 float scale, | 51 float scale, |
| 52 const RasterSource::PlaybackSettings& playback_settings, | 52 const RasterSource::PlaybackSettings& playback_settings, |
| 53 uint64_t previous_content_id, | 53 uint64_t previous_content_id, |
| 54 uint64_t new_content_id); | 54 uint64_t new_content_id); |
| 55 | 55 |
| 56 protected: | |
| 57 OneCopyRasterBufferProvider(base::SequencedTaskRunner* task_runner, | |
| 58 ResourceProvider* resource_provider, | |
| 59 int max_copy_texture_chromium_size, | |
| 60 bool use_partial_raster, | |
| 61 int max_staging_buffer_usage_in_bytes, | |
| 62 ResourceFormat preferred_tile_format); | |
| 63 | |
| 64 private: | 56 private: |
| 65 void PlaybackToStagingBuffer( | 57 void PlaybackToStagingBuffer( |
| 66 StagingBuffer* staging_buffer, | 58 StagingBuffer* staging_buffer, |
| 67 const Resource* resource, | 59 const Resource* resource, |
| 68 const RasterSource* raster_source, | 60 const RasterSource* raster_source, |
| 69 const gfx::Rect& raster_full_rect, | 61 const gfx::Rect& raster_full_rect, |
| 70 const gfx::Rect& raster_dirty_rect, | 62 const gfx::Rect& raster_dirty_rect, |
| 71 float scale, | 63 float scale, |
| 72 const RasterSource::PlaybackSettings& playback_settings, | 64 const RasterSource::PlaybackSettings& playback_settings, |
| 73 uint64_t previous_content_id, | 65 uint64_t previous_content_id, |
| 74 uint64_t new_content_id); | 66 uint64_t new_content_id); |
| 75 void CopyOnWorkerThread(StagingBuffer* staging_buffer, | 67 void CopyOnWorkerThread(StagingBuffer* staging_buffer, |
| 76 const Resource* resource, | 68 const Resource* resource, |
| 77 ResourceProvider::ScopedWriteLockGL* resource_lock, | 69 ResourceProvider::ScopedWriteLockGL* resource_lock, |
| 78 const RasterSource* raster_source, | 70 const RasterSource* raster_source, |
| 79 uint64_t previous_content_id, | 71 uint64_t previous_content_id, |
| 80 uint64_t new_content_id); | 72 uint64_t new_content_id); |
| 81 | 73 |
| 74 ContextProvider* const compositor_context_provider_; |
| 75 ContextProvider* const worker_context_provider_; |
| 82 ResourceProvider* const resource_provider_; | 76 ResourceProvider* const resource_provider_; |
| 83 const int max_bytes_per_copy_operation_; | 77 const int max_bytes_per_copy_operation_; |
| 84 bool use_partial_raster_; | 78 bool use_partial_raster_; |
| 85 | 79 |
| 86 // Context lock must be acquired when accessing this member. | 80 // Context lock must be acquired when accessing this member. |
| 87 int bytes_scheduled_since_last_flush_; | 81 int bytes_scheduled_since_last_flush_; |
| 88 | 82 |
| 89 ResourceFormat preferred_tile_format_; | 83 ResourceFormat preferred_tile_format_; |
| 90 std::unique_ptr<StagingBufferPool> staging_pool_; | 84 StagingBufferPool staging_pool_; |
| 91 | 85 |
| 92 DISALLOW_COPY_AND_ASSIGN(OneCopyRasterBufferProvider); | 86 DISALLOW_COPY_AND_ASSIGN(OneCopyRasterBufferProvider); |
| 93 }; | 87 }; |
| 94 | 88 |
| 95 } // namespace cc | 89 } // namespace cc |
| 96 | 90 |
| 97 #endif // CC_RASTER_ONE_COPY_RASTER_BUFFER_PROVIDER_H_ | 91 #endif // CC_RASTER_ONE_COPY_RASTER_BUFFER_PROVIDER_H_ |
| OLD | NEW |