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 #include "cc/raster/bitmap_tile_task_worker_pool.h" | 5 #include "cc/raster/bitmap_raster_buffer_provider.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
15 #include "base/trace_event/trace_event.h" | 15 #include "base/trace_event/trace_event.h" |
(...skipping 27 matching lines...) Loading... | |
43 float scale, | 43 float scale, |
44 const RasterSource::PlaybackSettings& playback_settings) override { | 44 const RasterSource::PlaybackSettings& playback_settings) override { |
45 gfx::Rect playback_rect = raster_full_rect; | 45 gfx::Rect playback_rect = raster_full_rect; |
46 if (resource_has_previous_content_) { | 46 if (resource_has_previous_content_) { |
47 playback_rect.Intersect(raster_dirty_rect); | 47 playback_rect.Intersect(raster_dirty_rect); |
48 } | 48 } |
49 DCHECK(!playback_rect.IsEmpty()) | 49 DCHECK(!playback_rect.IsEmpty()) |
50 << "Why are we rastering a tile that's not dirty?"; | 50 << "Why are we rastering a tile that's not dirty?"; |
51 | 51 |
52 size_t stride = 0u; | 52 size_t stride = 0u; |
53 TileTaskWorkerPool::PlaybackToMemory( | 53 RasterBufferProvider::PlaybackToMemory( |
54 lock_.sk_bitmap().getPixels(), resource_->format(), resource_->size(), | 54 lock_.sk_bitmap().getPixels(), resource_->format(), resource_->size(), |
55 stride, raster_source, raster_full_rect, playback_rect, scale, | 55 stride, raster_source, raster_full_rect, playback_rect, scale, |
56 playback_settings); | 56 playback_settings); |
57 } | 57 } |
58 | 58 |
59 private: | 59 private: |
60 ResourceProvider::ScopedWriteLockSoftware lock_; | 60 ResourceProvider::ScopedWriteLockSoftware lock_; |
61 const Resource* resource_; | 61 const Resource* resource_; |
62 bool resource_has_previous_content_; | 62 bool resource_has_previous_content_; |
63 | 63 |
64 DISALLOW_COPY_AND_ASSIGN(RasterBufferImpl); | 64 DISALLOW_COPY_AND_ASSIGN(RasterBufferImpl); |
65 }; | 65 }; |
66 | 66 |
67 } // namespace | 67 } // namespace |
68 | 68 |
69 // static | 69 // static |
70 std::unique_ptr<TileTaskWorkerPool> BitmapTileTaskWorkerPool::Create( | 70 std::unique_ptr<RasterBufferProvider> BitmapRasterBufferProvider::Create( |
71 base::SequencedTaskRunner* task_runner, | |
72 TaskGraphRunner* task_graph_runner, | |
73 ResourceProvider* resource_provider) { | 71 ResourceProvider* resource_provider) { |
74 return base::WrapUnique<TileTaskWorkerPool>(new BitmapTileTaskWorkerPool( | 72 return base::WrapUnique<RasterBufferProvider>( |
75 task_runner, task_graph_runner, resource_provider)); | 73 new BitmapRasterBufferProvider(resource_provider)); |
76 } | 74 } |
77 | 75 |
78 BitmapTileTaskWorkerPool::BitmapTileTaskWorkerPool( | 76 BitmapRasterBufferProvider::BitmapRasterBufferProvider( |
79 base::SequencedTaskRunner* task_runner, | |
80 TaskGraphRunner* task_graph_runner, | |
81 ResourceProvider* resource_provider) | 77 ResourceProvider* resource_provider) |
82 : task_runner_(task_runner), | 78 : resource_provider_(resource_provider) {} |
83 task_graph_runner_(task_graph_runner), | |
84 namespace_token_(task_graph_runner->GetNamespaceToken()), | |
85 resource_provider_(resource_provider) {} | |
86 | 79 |
87 BitmapTileTaskWorkerPool::~BitmapTileTaskWorkerPool() { | 80 BitmapRasterBufferProvider::~BitmapRasterBufferProvider() {} |
88 } | |
89 | 81 |
90 void BitmapTileTaskWorkerPool::Shutdown() { | 82 std::unique_ptr<RasterBuffer> |
91 TRACE_EVENT0("cc", "BitmapTileTaskWorkerPool::Shutdown"); | 83 BitmapRasterBufferProvider::AcquireBufferForRaster( |
92 | |
93 TaskGraph empty; | |
94 task_graph_runner_->ScheduleTasks(namespace_token_, &empty); | |
95 task_graph_runner_->WaitForTasksToFinishRunning(namespace_token_); | |
96 } | |
97 | |
98 void BitmapTileTaskWorkerPool::ScheduleTasks(TaskGraph* graph) { | |
99 TRACE_EVENT0("cc", "BitmapTileTaskWorkerPool::ScheduleTasks"); | |
100 | |
101 ScheduleTasksOnOriginThread(this, graph); | |
102 task_graph_runner_->ScheduleTasks(namespace_token_, graph); | |
103 } | |
104 | |
105 void BitmapTileTaskWorkerPool::CheckForCompletedTasks() { | |
106 TRACE_EVENT0("cc", "BitmapTileTaskWorkerPool::CheckForCompletedTasks"); | |
107 | |
108 task_graph_runner_->CollectCompletedTasks(namespace_token_, | |
109 &completed_tasks_); | |
110 for (Task::Vector::const_iterator it = completed_tasks_.begin(); | |
111 it != completed_tasks_.end(); ++it) { | |
112 TileTask* task = static_cast<TileTask*>(it->get()); | |
113 | |
114 task->WillComplete(); | |
115 task->CompleteOnOriginThread(this); | |
116 task->DidComplete(); | |
117 } | |
118 completed_tasks_.clear(); | |
119 } | |
120 | |
121 ResourceFormat BitmapTileTaskWorkerPool::GetResourceFormat( | |
122 bool must_support_alpha) const { | |
123 return resource_provider_->best_texture_format(); | |
124 } | |
125 | |
126 bool BitmapTileTaskWorkerPool::GetResourceRequiresSwizzle( | |
127 bool must_support_alpha) const { | |
128 return ResourceFormatRequiresSwizzle(GetResourceFormat(must_support_alpha)); | |
129 } | |
130 | |
131 RasterBufferProvider* BitmapTileTaskWorkerPool::AsRasterBufferProvider() { | |
132 return this; | |
133 } | |
134 | |
135 std::unique_ptr<RasterBuffer> BitmapTileTaskWorkerPool::AcquireBufferForRaster( | |
136 const Resource* resource, | 84 const Resource* resource, |
137 uint64_t resource_content_id, | 85 uint64_t resource_content_id, |
138 uint64_t previous_content_id) { | 86 uint64_t previous_content_id) { |
139 return std::unique_ptr<RasterBuffer>(new RasterBufferImpl( | 87 return std::unique_ptr<RasterBuffer>(new RasterBufferImpl( |
140 resource_provider_, resource, resource_content_id, previous_content_id)); | 88 resource_provider_, resource, resource_content_id, previous_content_id)); |
141 } | 89 } |
142 | 90 |
143 void BitmapTileTaskWorkerPool::ReleaseBufferForRaster( | 91 void BitmapRasterBufferProvider::ReleaseBufferForRaster( |
144 std::unique_ptr<RasterBuffer> buffer) { | 92 std::unique_ptr<RasterBuffer> buffer) { |
145 // Nothing to do here. RasterBufferImpl destructor cleans up after itself. | 93 // Nothing to do here. RasterBufferImpl destructor cleans up after itself. |
146 } | 94 } |
147 | 95 |
96 void BitmapRasterBufferProvider::BarrierToSyncResources() {} | |
ericrk
2016/04/29 07:24:38
Please add a comment explaining that we do not nee
| |
97 | |
98 ResourceFormat BitmapRasterBufferProvider::GetResourceFormat( | |
99 bool must_support_alpha) const { | |
100 return resource_provider_->best_texture_format(); | |
101 } | |
102 | |
103 bool BitmapRasterBufferProvider::GetResourceRequiresSwizzle( | |
104 bool must_support_alpha) const { | |
105 return ResourceFormatRequiresSwizzle(GetResourceFormat(must_support_alpha)); | |
106 } | |
107 | |
148 } // namespace cc | 108 } // namespace cc |
OLD | NEW |