OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/resources/tile_manager.h" | 5 #include "cc/resources/tile_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 41 matching lines...) Loading... | |
52 content_rect_(content_rect), | 52 content_rect_(content_rect), |
53 contents_scale_(contents_scale), | 53 contents_scale_(contents_scale), |
54 raster_mode_(raster_mode), | 54 raster_mode_(raster_mode), |
55 tile_resolution_(tile_resolution), | 55 tile_resolution_(tile_resolution), |
56 layer_id_(layer_id), | 56 layer_id_(layer_id), |
57 tile_id_(tile_id), | 57 tile_id_(tile_id), |
58 source_frame_number_(source_frame_number), | 58 source_frame_number_(source_frame_number), |
59 analyze_picture_(analyze_picture), | 59 analyze_picture_(analyze_picture), |
60 rendering_stats_(rendering_stats), | 60 rendering_stats_(rendering_stats), |
61 reply_(reply), | 61 reply_(reply), |
62 canvas_(NULL) {} | 62 raster_buffer_(NULL) {} |
63 | 63 |
64 // Overridden from Task: | 64 // Overridden from Task: |
65 virtual void RunOnWorkerThread() OVERRIDE { | 65 virtual void RunOnWorkerThread() OVERRIDE { |
66 TRACE_EVENT0("cc", "RasterizerTaskImpl::RunOnWorkerThread"); | 66 TRACE_EVENT0("cc", "RasterizerTaskImpl::RunOnWorkerThread"); |
67 | 67 |
68 DCHECK(picture_pile_); | 68 DCHECK(picture_pile_); |
69 if (canvas_) { | 69 if (raster_buffer_) { |
70 AnalyzeAndRaster(picture_pile_->GetCloneForDrawingOnThread( | 70 AnalyzeAndRaster(picture_pile_->GetCloneForDrawingOnThread( |
71 RasterWorkerPool::GetPictureCloneIndexForCurrentThread())); | 71 RasterWorkerPool::GetPictureCloneIndexForCurrentThread())); |
72 } | 72 } |
73 } | 73 } |
74 | 74 |
75 // Overridden from RasterizerTask: | 75 // Overridden from RasterizerTask: |
76 virtual void ScheduleOnOriginThread(RasterizerTaskClient* client) OVERRIDE { | 76 virtual void ScheduleOnOriginThread(RasterizerTaskClient* client) OVERRIDE { |
77 DCHECK(!canvas_); | 77 DCHECK(!raster_buffer_); |
78 canvas_ = client->AcquireCanvasForRaster(this); | 78 raster_buffer_ = client->AcquireBufferForRaster(this); |
79 } | 79 } |
80 virtual void CompleteOnOriginThread(RasterizerTaskClient* client) OVERRIDE { | 80 virtual void CompleteOnOriginThread(RasterizerTaskClient* client) OVERRIDE { |
81 canvas_ = NULL; | 81 raster_buffer_ = NULL; |
82 client->ReleaseCanvasForRaster(this); | 82 client->ReleaseBufferForRaster(this); |
83 } | 83 } |
84 virtual void RunReplyOnOriginThread() OVERRIDE { | 84 virtual void RunReplyOnOriginThread() OVERRIDE { |
85 DCHECK(!canvas_); | 85 DCHECK(!raster_buffer_); |
86 reply_.Run(analysis_, !HasFinishedRunning()); | 86 reply_.Run(analysis_, !HasFinishedRunning()); |
87 } | 87 } |
88 | 88 |
89 protected: | 89 protected: |
90 virtual ~RasterTaskImpl() { DCHECK(!canvas_); } | 90 virtual ~RasterTaskImpl() { DCHECK(!raster_buffer_); } |
91 | 91 |
92 private: | 92 private: |
93 void AnalyzeAndRaster(PicturePileImpl* picture_pile) { | 93 void AnalyzeAndRaster(PicturePileImpl* picture_pile) { |
94 DCHECK(picture_pile); | 94 DCHECK(picture_pile); |
95 DCHECK(canvas_); | 95 DCHECK(raster_buffer_); |
96 | 96 |
97 if (analyze_picture_) { | 97 if (analyze_picture_) { |
98 Analyze(picture_pile); | 98 Analyze(picture_pile); |
99 if (analysis_.is_solid_color) | 99 if (analysis_.is_solid_color) |
100 return; | 100 return; |
101 } | 101 } |
102 | 102 |
103 Raster(picture_pile); | 103 Raster(picture_pile); |
104 } | 104 } |
105 | 105 |
(...skipping 17 matching lines...) Loading... | |
123 void Raster(PicturePileImpl* picture_pile) { | 123 void Raster(PicturePileImpl* picture_pile) { |
124 frame_viewer_instrumentation::ScopedRasterTask raster_task( | 124 frame_viewer_instrumentation::ScopedRasterTask raster_task( |
125 tile_id_, | 125 tile_id_, |
126 tile_resolution_, | 126 tile_resolution_, |
127 source_frame_number_, | 127 source_frame_number_, |
128 layer_id_, | 128 layer_id_, |
129 raster_mode_); | 129 raster_mode_); |
130 devtools_instrumentation::ScopedLayerTask layer_task( | 130 devtools_instrumentation::ScopedLayerTask layer_task( |
131 devtools_instrumentation::kRasterTask, layer_id_); | 131 devtools_instrumentation::kRasterTask, layer_id_); |
132 | 132 |
133 skia::RefPtr<SkCanvas> canvas = raster_buffer_->AcquireSkCanvas(); | |
134 DCHECK(canvas); | |
reveman
2014/08/16 08:36:18
I think this currently needs to be allowed to fail
auygun
2014/08/18 08:00:50
I'm adding a null-check here.
| |
135 | |
133 skia::RefPtr<SkDrawFilter> draw_filter; | 136 skia::RefPtr<SkDrawFilter> draw_filter; |
134 switch (raster_mode_) { | 137 switch (raster_mode_) { |
135 case LOW_QUALITY_RASTER_MODE: | 138 case LOW_QUALITY_RASTER_MODE: |
136 draw_filter = skia::AdoptRef(new skia::PaintSimplifier); | 139 draw_filter = skia::AdoptRef(new skia::PaintSimplifier); |
137 break; | 140 break; |
138 case HIGH_QUALITY_RASTER_MODE: | 141 case HIGH_QUALITY_RASTER_MODE: |
139 break; | 142 break; |
140 case NUM_RASTER_MODES: | 143 case NUM_RASTER_MODES: |
141 default: | 144 default: |
142 NOTREACHED(); | 145 NOTREACHED(); |
143 } | 146 } |
144 canvas_->setDrawFilter(draw_filter.get()); | 147 canvas->setDrawFilter(draw_filter.get()); |
145 | 148 |
146 base::TimeDelta prev_rasterize_time = | 149 base::TimeDelta prev_rasterize_time = |
147 rendering_stats_->impl_thread_rendering_stats().rasterize_time; | 150 rendering_stats_->impl_thread_rendering_stats().rasterize_time; |
148 | 151 |
149 // Only record rasterization time for highres tiles, because | 152 // Only record rasterization time for highres tiles, because |
150 // lowres tiles are not required for activation and therefore | 153 // lowres tiles are not required for activation and therefore |
151 // introduce noise in the measurement (sometimes they get rasterized | 154 // introduce noise in the measurement (sometimes they get rasterized |
152 // before we draw and sometimes they aren't) | 155 // before we draw and sometimes they aren't) |
153 RenderingStatsInstrumentation* stats = | 156 RenderingStatsInstrumentation* stats = |
154 tile_resolution_ == HIGH_RESOLUTION ? rendering_stats_ : NULL; | 157 tile_resolution_ == HIGH_RESOLUTION ? rendering_stats_ : NULL; |
155 DCHECK(picture_pile); | 158 DCHECK(picture_pile); |
156 picture_pile->RasterToBitmap( | 159 picture_pile->RasterToBitmap( |
157 canvas_, content_rect_, contents_scale_, stats); | 160 canvas.get(), content_rect_, contents_scale_, stats); |
158 | 161 |
159 if (rendering_stats_->record_rendering_stats()) { | 162 if (rendering_stats_->record_rendering_stats()) { |
160 base::TimeDelta current_rasterize_time = | 163 base::TimeDelta current_rasterize_time = |
161 rendering_stats_->impl_thread_rendering_stats().rasterize_time; | 164 rendering_stats_->impl_thread_rendering_stats().rasterize_time; |
162 HISTOGRAM_CUSTOM_COUNTS( | 165 HISTOGRAM_CUSTOM_COUNTS( |
163 "Renderer4.PictureRasterTimeUS", | 166 "Renderer4.PictureRasterTimeUS", |
164 (current_rasterize_time - prev_rasterize_time).InMicroseconds(), | 167 (current_rasterize_time - prev_rasterize_time).InMicroseconds(), |
165 0, | 168 0, |
166 100000, | 169 100000, |
167 100); | 170 100); |
168 } | 171 } |
172 | |
173 raster_buffer_->ReleaseSkCanvas(canvas); | |
169 } | 174 } |
170 | 175 |
171 PicturePileImpl::Analysis analysis_; | 176 PicturePileImpl::Analysis analysis_; |
172 scoped_refptr<PicturePileImpl> picture_pile_; | 177 scoped_refptr<PicturePileImpl> picture_pile_; |
173 gfx::Rect content_rect_; | 178 gfx::Rect content_rect_; |
174 float contents_scale_; | 179 float contents_scale_; |
175 RasterMode raster_mode_; | 180 RasterMode raster_mode_; |
176 TileResolution tile_resolution_; | 181 TileResolution tile_resolution_; |
177 int layer_id_; | 182 int layer_id_; |
178 const void* tile_id_; | 183 const void* tile_id_; |
179 int source_frame_number_; | 184 int source_frame_number_; |
180 bool analyze_picture_; | 185 bool analyze_picture_; |
181 RenderingStatsInstrumentation* rendering_stats_; | 186 RenderingStatsInstrumentation* rendering_stats_; |
182 const base::Callback<void(const PicturePileImpl::Analysis&, bool)> reply_; | 187 const base::Callback<void(const PicturePileImpl::Analysis&, bool)> reply_; |
183 SkCanvas* canvas_; | 188 RasterBuffer* raster_buffer_; |
184 | 189 |
185 DISALLOW_COPY_AND_ASSIGN(RasterTaskImpl); | 190 DISALLOW_COPY_AND_ASSIGN(RasterTaskImpl); |
186 }; | 191 }; |
187 | 192 |
188 class ImageDecodeTaskImpl : public ImageDecodeTask { | 193 class ImageDecodeTaskImpl : public ImageDecodeTask { |
189 public: | 194 public: |
190 ImageDecodeTaskImpl(SkPixelRef* pixel_ref, | 195 ImageDecodeTaskImpl(SkPixelRef* pixel_ref, |
191 int layer_id, | 196 int layer_id, |
192 RenderingStatsInstrumentation* rendering_stats, | 197 RenderingStatsInstrumentation* rendering_stats, |
193 const base::Callback<void(bool was_canceled)>& reply) | 198 const base::Callback<void(bool was_canceled)>& reply) |
(...skipping 987 matching lines...) Loading... | |
1181 TRACE_EVENT0("cc", "TileManager::CheckIfReadyToActivate"); | 1186 TRACE_EVENT0("cc", "TileManager::CheckIfReadyToActivate"); |
1182 | 1187 |
1183 rasterizer_->CheckForCompletedTasks(); | 1188 rasterizer_->CheckForCompletedTasks(); |
1184 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 1189 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
1185 | 1190 |
1186 if (IsReadyToActivate()) | 1191 if (IsReadyToActivate()) |
1187 client_->NotifyReadyToActivate(); | 1192 client_->NotifyReadyToActivate(); |
1188 } | 1193 } |
1189 | 1194 |
1190 } // namespace cc | 1195 } // namespace cc |
OLD | NEW |