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

Side by Side Diff: cc/resources/tile_manager.cc

Issue 562833004: cc: Move RasterBuffer implementations from ResourceProvider to RasterWorkerPool implementations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: build fix Created 6 years, 3 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 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
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/debug/trace_event_argument.h" 12 #include "base/debug/trace_event_argument.h"
13 #include "base/json/json_writer.h" 13 #include "base/json/json_writer.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "cc/debug/devtools_instrumentation.h" 16 #include "cc/debug/devtools_instrumentation.h"
17 #include "cc/debug/frame_viewer_instrumentation.h" 17 #include "cc/debug/frame_viewer_instrumentation.h"
18 #include "cc/debug/traced_value.h" 18 #include "cc/debug/traced_value.h"
19 #include "cc/layers/picture_layer_impl.h" 19 #include "cc/layers/picture_layer_impl.h"
20 #include "cc/resources/raster_buffer.h"
20 #include "cc/resources/rasterizer.h" 21 #include "cc/resources/rasterizer.h"
21 #include "cc/resources/tile.h" 22 #include "cc/resources/tile.h"
22 #include "skia/ext/paint_simplifier.h" 23 #include "skia/ext/paint_simplifier.h"
23 #include "third_party/skia/include/core/SkBitmap.h" 24 #include "third_party/skia/include/core/SkBitmap.h"
24 #include "third_party/skia/include/core/SkPixelRef.h" 25 #include "third_party/skia/include/core/SkPixelRef.h"
25 #include "ui/gfx/rect_conversions.h" 26 #include "ui/gfx/rect_conversions.h"
26 27
27 namespace cc { 28 namespace cc {
28 namespace { 29 namespace {
29 30
(...skipping 21 matching lines...) Expand all
51 picture_pile_(picture_pile), 52 picture_pile_(picture_pile),
52 content_rect_(content_rect), 53 content_rect_(content_rect),
53 contents_scale_(contents_scale), 54 contents_scale_(contents_scale),
54 raster_mode_(raster_mode), 55 raster_mode_(raster_mode),
55 tile_resolution_(tile_resolution), 56 tile_resolution_(tile_resolution),
56 layer_id_(layer_id), 57 layer_id_(layer_id),
57 tile_id_(tile_id), 58 tile_id_(tile_id),
58 source_frame_number_(source_frame_number), 59 source_frame_number_(source_frame_number),
59 analyze_picture_(analyze_picture), 60 analyze_picture_(analyze_picture),
60 rendering_stats_(rendering_stats), 61 rendering_stats_(rendering_stats),
61 reply_(reply), 62 reply_(reply) {}
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_.get()); 68 DCHECK(picture_pile_.get());
69 DCHECK(raster_buffer_); 69 DCHECK(raster_buffer_);
70 70
71 if (analyze_picture_) { 71 if (analyze_picture_) {
72 Analyze(picture_pile_.get()); 72 Analyze(picture_pile_.get());
73 if (analysis_.is_solid_color) 73 if (analysis_.is_solid_color)
74 return; 74 return;
75 } 75 }
76 76
77 Raster(picture_pile_.get()); 77 Raster(picture_pile_.get());
78 } 78 }
79 79
80 // Overridden from RasterizerTask: 80 // Overridden from RasterizerTask:
81 virtual void ScheduleOnOriginThread(RasterizerTaskClient* client) OVERRIDE { 81 virtual void ScheduleOnOriginThread(RasterizerTaskClient* client) OVERRIDE {
82 DCHECK(!raster_buffer_); 82 DCHECK(!raster_buffer_);
83 raster_buffer_ = client->AcquireBufferForRaster(this); 83 raster_buffer_ = client->AcquireBufferForRaster(resource());
84 } 84 }
85 virtual void CompleteOnOriginThread(RasterizerTaskClient* client) OVERRIDE { 85 virtual void CompleteOnOriginThread(RasterizerTaskClient* client) OVERRIDE {
86 raster_buffer_ = NULL; 86 client->ReleaseBufferForRaster(raster_buffer_.Pass());
87 client->ReleaseBufferForRaster(this);
88 } 87 }
89 virtual void RunReplyOnOriginThread() OVERRIDE { 88 virtual void RunReplyOnOriginThread() OVERRIDE {
90 DCHECK(!raster_buffer_); 89 DCHECK(!raster_buffer_);
91 reply_.Run(analysis_, !HasFinishedRunning()); 90 reply_.Run(analysis_, !HasFinishedRunning());
92 } 91 }
93 92
94 protected: 93 protected:
95 virtual ~RasterTaskImpl() { DCHECK(!raster_buffer_); } 94 virtual ~RasterTaskImpl() { DCHECK(!raster_buffer_); }
96 95
97 private: 96 private:
(...skipping 18 matching lines...) Expand all
116 frame_viewer_instrumentation::ScopedRasterTask raster_task( 115 frame_viewer_instrumentation::ScopedRasterTask raster_task(
117 tile_id_, 116 tile_id_,
118 tile_resolution_, 117 tile_resolution_,
119 source_frame_number_, 118 source_frame_number_,
120 layer_id_, 119 layer_id_,
121 raster_mode_); 120 raster_mode_);
122 devtools_instrumentation::ScopedLayerTask layer_task( 121 devtools_instrumentation::ScopedLayerTask layer_task(
123 devtools_instrumentation::kRasterTask, layer_id_); 122 devtools_instrumentation::kRasterTask, layer_id_);
124 123
125 skia::RefPtr<SkCanvas> canvas = raster_buffer_->AcquireSkCanvas(); 124 skia::RefPtr<SkCanvas> canvas = raster_buffer_->AcquireSkCanvas();
126 if (!canvas) 125 DCHECK(canvas);
vmpstr 2014/09/16 22:15:55 Oh I see the change now from NULL ptr to NullCanva
reveman 2014/09/17 14:40:56 Good idea. Making this change using https://codere
127 return;
128 canvas->save();
129 126
130 skia::RefPtr<SkDrawFilter> draw_filter; 127 skia::RefPtr<SkDrawFilter> draw_filter;
131 switch (raster_mode_) { 128 switch (raster_mode_) {
132 case LOW_QUALITY_RASTER_MODE: 129 case LOW_QUALITY_RASTER_MODE:
133 draw_filter = skia::AdoptRef(new skia::PaintSimplifier); 130 draw_filter = skia::AdoptRef(new skia::PaintSimplifier);
134 break; 131 break;
135 case HIGH_QUALITY_RASTER_MODE: 132 case HIGH_QUALITY_RASTER_MODE:
136 break; 133 break;
137 case NUM_RASTER_MODES: 134 case NUM_RASTER_MODES:
138 default: 135 default:
(...skipping 18 matching lines...) Expand all
157 base::TimeDelta current_rasterize_time = 154 base::TimeDelta current_rasterize_time =
158 rendering_stats_->impl_thread_rendering_stats().rasterize_time; 155 rendering_stats_->impl_thread_rendering_stats().rasterize_time;
159 LOCAL_HISTOGRAM_CUSTOM_COUNTS( 156 LOCAL_HISTOGRAM_CUSTOM_COUNTS(
160 "Renderer4.PictureRasterTimeUS", 157 "Renderer4.PictureRasterTimeUS",
161 (current_rasterize_time - prev_rasterize_time).InMicroseconds(), 158 (current_rasterize_time - prev_rasterize_time).InMicroseconds(),
162 0, 159 0,
163 100000, 160 100000,
164 100); 161 100);
165 } 162 }
166 163
167 canvas->restore();
168 raster_buffer_->ReleaseSkCanvas(canvas); 164 raster_buffer_->ReleaseSkCanvas(canvas);
169 } 165 }
170 166
171 PicturePileImpl::Analysis analysis_; 167 PicturePileImpl::Analysis analysis_;
172 scoped_refptr<PicturePileImpl> picture_pile_; 168 scoped_refptr<PicturePileImpl> picture_pile_;
173 gfx::Rect content_rect_; 169 gfx::Rect content_rect_;
174 float contents_scale_; 170 float contents_scale_;
175 RasterMode raster_mode_; 171 RasterMode raster_mode_;
176 TileResolution tile_resolution_; 172 TileResolution tile_resolution_;
177 int layer_id_; 173 int layer_id_;
178 const void* tile_id_; 174 const void* tile_id_;
179 int source_frame_number_; 175 int source_frame_number_;
180 bool analyze_picture_; 176 bool analyze_picture_;
181 RenderingStatsInstrumentation* rendering_stats_; 177 RenderingStatsInstrumentation* rendering_stats_;
182 const base::Callback<void(const PicturePileImpl::Analysis&, bool)> reply_; 178 const base::Callback<void(const PicturePileImpl::Analysis&, bool)> reply_;
183 RasterBuffer* raster_buffer_; 179 scoped_ptr<RasterBuffer> raster_buffer_;
184 180
185 DISALLOW_COPY_AND_ASSIGN(RasterTaskImpl); 181 DISALLOW_COPY_AND_ASSIGN(RasterTaskImpl);
186 }; 182 };
187 183
188 class ImageDecodeTaskImpl : public ImageDecodeTask { 184 class ImageDecodeTaskImpl : public ImageDecodeTask {
189 public: 185 public:
190 ImageDecodeTaskImpl(SkPixelRef* pixel_ref, 186 ImageDecodeTaskImpl(SkPixelRef* pixel_ref,
191 int layer_id, 187 int layer_id,
192 RenderingStatsInstrumentation* rendering_stats, 188 RenderingStatsInstrumentation* rendering_stats,
193 const base::Callback<void(bool was_canceled)>& reply) 189 const base::Callback<void(bool was_canceled)>& reply)
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 TRACE_EVENT0("cc", "TileManager::CheckIfReadyToActivate"); 1167 TRACE_EVENT0("cc", "TileManager::CheckIfReadyToActivate");
1172 1168
1173 rasterizer_->CheckForCompletedTasks(); 1169 rasterizer_->CheckForCompletedTasks();
1174 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; 1170 did_check_for_completed_tasks_since_last_schedule_tasks_ = true;
1175 1171
1176 if (IsReadyToActivate()) 1172 if (IsReadyToActivate())
1177 client_->NotifyReadyToActivate(); 1173 client_->NotifyReadyToActivate();
1178 } 1174 }
1179 1175
1180 } // namespace cc 1176 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698