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

Side by Side Diff: cc/playback/raster_source.cc

Issue 1837263005: cc: Rename DisplayListRasterSource to just RasterSource. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « cc/playback/raster_source.h ('k') | cc/playback/raster_source_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "cc/playback/display_list_raster_source.h" 5 #include "cc/playback/raster_source.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
11 #include "base/trace_event/memory_dump_manager.h" 11 #include "base/trace_event/memory_dump_manager.h"
12 #include "base/trace_event/trace_event.h" 12 #include "base/trace_event/trace_event.h"
13 #include "cc/base/region.h" 13 #include "cc/base/region.h"
14 #include "cc/debug/debug_colors.h" 14 #include "cc/debug/debug_colors.h"
15 #include "cc/playback/display_item_list.h" 15 #include "cc/playback/display_item_list.h"
16 #include "cc/playback/image_hijack_canvas.h" 16 #include "cc/playback/image_hijack_canvas.h"
17 #include "cc/playback/skip_image_canvas.h" 17 #include "cc/playback/skip_image_canvas.h"
18 #include "skia/ext/analysis_canvas.h" 18 #include "skia/ext/analysis_canvas.h"
19 #include "third_party/skia/include/core/SkCanvas.h" 19 #include "third_party/skia/include/core/SkCanvas.h"
20 #include "third_party/skia/include/core/SkPictureRecorder.h" 20 #include "third_party/skia/include/core/SkPictureRecorder.h"
21 #include "third_party/skia/include/core/SkTLazy.h" 21 #include "third_party/skia/include/core/SkTLazy.h"
22 #include "ui/gfx/geometry/rect_conversions.h" 22 #include "ui/gfx/geometry/rect_conversions.h"
23 23
24 namespace cc { 24 namespace cc {
25 25
26 scoped_refptr<DisplayListRasterSource> 26 scoped_refptr<RasterSource> RasterSource::CreateFromDisplayListRecordingSource(
27 DisplayListRasterSource::CreateFromDisplayListRecordingSource(
28 const DisplayListRecordingSource* other, 27 const DisplayListRecordingSource* other,
29 bool can_use_lcd_text) { 28 bool can_use_lcd_text) {
30 return make_scoped_refptr( 29 return make_scoped_refptr(new RasterSource(other, can_use_lcd_text));
31 new DisplayListRasterSource(other, can_use_lcd_text));
32 } 30 }
33 31
34 DisplayListRasterSource::DisplayListRasterSource( 32 RasterSource::RasterSource(const DisplayListRecordingSource* other,
35 const DisplayListRecordingSource* other, 33 bool can_use_lcd_text)
36 bool can_use_lcd_text)
37 : display_list_(other->display_list_), 34 : display_list_(other->display_list_),
38 painter_reported_memory_usage_(other->painter_reported_memory_usage_), 35 painter_reported_memory_usage_(other->painter_reported_memory_usage_),
39 background_color_(other->background_color_), 36 background_color_(other->background_color_),
40 requires_clear_(other->requires_clear_), 37 requires_clear_(other->requires_clear_),
41 can_use_lcd_text_(can_use_lcd_text), 38 can_use_lcd_text_(can_use_lcd_text),
42 is_solid_color_(other->is_solid_color_), 39 is_solid_color_(other->is_solid_color_),
43 solid_color_(other->solid_color_), 40 solid_color_(other->solid_color_),
44 recorded_viewport_(other->recorded_viewport_), 41 recorded_viewport_(other->recorded_viewport_),
45 size_(other->size_), 42 size_(other->size_),
46 clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_), 43 clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_),
47 slow_down_raster_scale_factor_for_debug_( 44 slow_down_raster_scale_factor_for_debug_(
48 other->slow_down_raster_scale_factor_for_debug_), 45 other->slow_down_raster_scale_factor_for_debug_),
49 should_attempt_to_use_distance_field_text_(false), 46 should_attempt_to_use_distance_field_text_(false),
50 image_decode_controller_(nullptr) { 47 image_decode_controller_(nullptr) {
51 // In certain cases, ThreadTaskRunnerHandle isn't set (Android Webview). 48 // In certain cases, ThreadTaskRunnerHandle isn't set (Android Webview).
52 // Don't register a dump provider in these cases. 49 // Don't register a dump provider in these cases.
53 // TODO(ericrk): Get this working in Android Webview. crbug.com/517156 50 // TODO(ericrk): Get this working in Android Webview. crbug.com/517156
54 if (base::ThreadTaskRunnerHandle::IsSet()) { 51 if (base::ThreadTaskRunnerHandle::IsSet()) {
55 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( 52 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
56 this, "cc::DisplayListRasterSource", 53 this, "cc::RasterSource", base::ThreadTaskRunnerHandle::Get());
57 base::ThreadTaskRunnerHandle::Get());
58 } 54 }
59 } 55 }
60 56
61 DisplayListRasterSource::DisplayListRasterSource( 57 RasterSource::RasterSource(const RasterSource* other, bool can_use_lcd_text)
62 const DisplayListRasterSource* other,
63 bool can_use_lcd_text)
64 : display_list_(other->display_list_), 58 : display_list_(other->display_list_),
65 painter_reported_memory_usage_(other->painter_reported_memory_usage_), 59 painter_reported_memory_usage_(other->painter_reported_memory_usage_),
66 background_color_(other->background_color_), 60 background_color_(other->background_color_),
67 requires_clear_(other->requires_clear_), 61 requires_clear_(other->requires_clear_),
68 can_use_lcd_text_(can_use_lcd_text), 62 can_use_lcd_text_(can_use_lcd_text),
69 is_solid_color_(other->is_solid_color_), 63 is_solid_color_(other->is_solid_color_),
70 solid_color_(other->solid_color_), 64 solid_color_(other->solid_color_),
71 recorded_viewport_(other->recorded_viewport_), 65 recorded_viewport_(other->recorded_viewport_),
72 size_(other->size_), 66 size_(other->size_),
73 clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_), 67 clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_),
74 slow_down_raster_scale_factor_for_debug_( 68 slow_down_raster_scale_factor_for_debug_(
75 other->slow_down_raster_scale_factor_for_debug_), 69 other->slow_down_raster_scale_factor_for_debug_),
76 should_attempt_to_use_distance_field_text_( 70 should_attempt_to_use_distance_field_text_(
77 other->should_attempt_to_use_distance_field_text_), 71 other->should_attempt_to_use_distance_field_text_),
78 image_decode_controller_(other->image_decode_controller_) { 72 image_decode_controller_(other->image_decode_controller_) {
79 // In certain cases, ThreadTaskRunnerHandle isn't set (Android Webview). 73 // In certain cases, ThreadTaskRunnerHandle isn't set (Android Webview).
80 // Don't register a dump provider in these cases. 74 // Don't register a dump provider in these cases.
81 // TODO(ericrk): Get this working in Android Webview. crbug.com/517156 75 // TODO(ericrk): Get this working in Android Webview. crbug.com/517156
82 if (base::ThreadTaskRunnerHandle::IsSet()) { 76 if (base::ThreadTaskRunnerHandle::IsSet()) {
83 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( 77 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
84 this, "cc::DisplayListRasterSource", 78 this, "cc::RasterSource", base::ThreadTaskRunnerHandle::Get());
85 base::ThreadTaskRunnerHandle::Get());
86 } 79 }
87 } 80 }
88 81
89 DisplayListRasterSource::~DisplayListRasterSource() { 82 RasterSource::~RasterSource() {
90 // For MemoryDumpProvider deregistration to work correctly, this must happen 83 // For MemoryDumpProvider deregistration to work correctly, this must happen
91 // on the same thread that the DisplayListRasterSource was created on. 84 // on the same thread that the RasterSource was created on.
92 DCHECK(memory_dump_thread_checker_.CalledOnValidThread()); 85 DCHECK(memory_dump_thread_checker_.CalledOnValidThread());
93 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( 86 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider(
94 this); 87 this);
95 } 88 }
96 89
97 void DisplayListRasterSource::PlaybackToSharedCanvas( 90 void RasterSource::PlaybackToSharedCanvas(SkCanvas* raster_canvas,
98 SkCanvas* raster_canvas, 91 const gfx::Rect& canvas_rect,
99 const gfx::Rect& canvas_rect, 92 float contents_scale,
100 float contents_scale, 93 bool include_images) const {
101 bool include_images) const {
102 // TODO(vmpstr): This can be improved by plumbing whether the tile itself has 94 // TODO(vmpstr): This can be improved by plumbing whether the tile itself has
103 // discardable images. This way we would only pay for the hijack canvas if the 95 // discardable images. This way we would only pay for the hijack canvas if the
104 // tile actually needed it. 96 // tile actually needed it.
105 if (!include_images) { 97 if (!include_images) {
106 SkipImageCanvas canvas(raster_canvas); 98 SkipImageCanvas canvas(raster_canvas);
107 RasterCommon(&canvas, nullptr, canvas_rect, canvas_rect, contents_scale); 99 RasterCommon(&canvas, nullptr, canvas_rect, canvas_rect, contents_scale);
108 } else if (display_list_->MayHaveDiscardableImages()) { 100 } else if (display_list_->MayHaveDiscardableImages()) {
109 const SkImageInfo& info = raster_canvas->imageInfo(); 101 const SkImageInfo& info = raster_canvas->imageInfo();
110 ImageHijackCanvas canvas(info.width(), info.height(), 102 ImageHijackCanvas canvas(info.width(), info.height(),
111 image_decode_controller_); 103 image_decode_controller_);
112 canvas.addCanvas(raster_canvas); 104 canvas.addCanvas(raster_canvas);
113 105
114 RasterCommon(&canvas, nullptr, canvas_rect, canvas_rect, contents_scale); 106 RasterCommon(&canvas, nullptr, canvas_rect, canvas_rect, contents_scale);
115 } else { 107 } else {
116 RasterCommon(raster_canvas, nullptr, canvas_rect, canvas_rect, 108 RasterCommon(raster_canvas, nullptr, canvas_rect, canvas_rect,
117 contents_scale); 109 contents_scale);
118 } 110 }
119 } 111 }
120 112
121 void DisplayListRasterSource::RasterForAnalysis(skia::AnalysisCanvas* canvas, 113 void RasterSource::RasterForAnalysis(skia::AnalysisCanvas* canvas,
122 const gfx::Rect& canvas_rect, 114 const gfx::Rect& canvas_rect,
123 float contents_scale) const { 115 float contents_scale) const {
124 RasterCommon(canvas, canvas, canvas_rect, canvas_rect, contents_scale); 116 RasterCommon(canvas, canvas, canvas_rect, canvas_rect, contents_scale);
125 } 117 }
126 118
127 void DisplayListRasterSource::PlaybackToCanvas( 119 void RasterSource::PlaybackToCanvas(SkCanvas* raster_canvas,
128 SkCanvas* raster_canvas, 120 const gfx::Rect& canvas_bitmap_rect,
129 const gfx::Rect& canvas_bitmap_rect, 121 const gfx::Rect& canvas_playback_rect,
130 const gfx::Rect& canvas_playback_rect, 122 float contents_scale,
131 float contents_scale, 123 bool include_images) const {
132 bool include_images) const {
133 PrepareForPlaybackToCanvas(raster_canvas, canvas_bitmap_rect, 124 PrepareForPlaybackToCanvas(raster_canvas, canvas_bitmap_rect,
134 canvas_playback_rect, contents_scale); 125 canvas_playback_rect, contents_scale);
135 126
136 if (!include_images) { 127 if (!include_images) {
137 SkipImageCanvas canvas(raster_canvas); 128 SkipImageCanvas canvas(raster_canvas);
138 RasterCommon(&canvas, nullptr, canvas_bitmap_rect, canvas_playback_rect, 129 RasterCommon(&canvas, nullptr, canvas_bitmap_rect, canvas_playback_rect,
139 contents_scale); 130 contents_scale);
140 } else if (display_list_->MayHaveDiscardableImages()) { 131 } else if (display_list_->MayHaveDiscardableImages()) {
141 const SkImageInfo& info = raster_canvas->imageInfo(); 132 const SkImageInfo& info = raster_canvas->imageInfo();
142 ImageHijackCanvas canvas(info.width(), info.height(), 133 ImageHijackCanvas canvas(info.width(), info.height(),
143 image_decode_controller_); 134 image_decode_controller_);
144 canvas.addCanvas(raster_canvas); 135 canvas.addCanvas(raster_canvas);
145 RasterCommon(&canvas, nullptr, canvas_bitmap_rect, canvas_playback_rect, 136 RasterCommon(&canvas, nullptr, canvas_bitmap_rect, canvas_playback_rect,
146 contents_scale); 137 contents_scale);
147 } else { 138 } else {
148 RasterCommon(raster_canvas, nullptr, canvas_bitmap_rect, 139 RasterCommon(raster_canvas, nullptr, canvas_bitmap_rect,
149 canvas_playback_rect, contents_scale); 140 canvas_playback_rect, contents_scale);
150 } 141 }
151 } 142 }
152 143
153 void DisplayListRasterSource::PrepareForPlaybackToCanvas( 144 void RasterSource::PrepareForPlaybackToCanvas(
154 SkCanvas* canvas, 145 SkCanvas* canvas,
155 const gfx::Rect& canvas_bitmap_rect, 146 const gfx::Rect& canvas_bitmap_rect,
156 const gfx::Rect& canvas_playback_rect, 147 const gfx::Rect& canvas_playback_rect,
157 float contents_scale) const { 148 float contents_scale) const {
158 // TODO(hendrikw): See if we can split this up into separate functions. 149 // TODO(hendrikw): See if we can split this up into separate functions.
159 bool partial_update = canvas_bitmap_rect != canvas_playback_rect; 150 bool partial_update = canvas_bitmap_rect != canvas_playback_rect;
160 151
161 if (!partial_update) 152 if (!partial_update)
162 canvas->discard(); 153 canvas->discard();
163 if (clear_canvas_with_debug_color_) { 154 if (clear_canvas_with_debug_color_) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 canvas->clipRect(gfx::RectToSkRect(inflated_content_rect), 221 canvas->clipRect(gfx::RectToSkRect(inflated_content_rect),
231 SkRegion::kReplace_Op); 222 SkRegion::kReplace_Op);
232 canvas->clipRect(gfx::RectToSkRect(deflated_content_rect), 223 canvas->clipRect(gfx::RectToSkRect(deflated_content_rect),
233 SkRegion::kDifference_Op); 224 SkRegion::kDifference_Op);
234 canvas->drawColor(background_color_, SkXfermode::kSrc_Mode); 225 canvas->drawColor(background_color_, SkXfermode::kSrc_Mode);
235 canvas->restore(); 226 canvas->restore();
236 } 227 }
237 } 228 }
238 } 229 }
239 230
240 void DisplayListRasterSource::RasterCommon( 231 void RasterSource::RasterCommon(SkCanvas* canvas,
241 SkCanvas* canvas, 232 SkPicture::AbortCallback* callback,
242 SkPicture::AbortCallback* callback, 233 const gfx::Rect& canvas_bitmap_rect,
243 const gfx::Rect& canvas_bitmap_rect, 234 const gfx::Rect& canvas_playback_rect,
244 const gfx::Rect& canvas_playback_rect, 235 float contents_scale) const {
245 float contents_scale) const {
246 canvas->translate(-canvas_bitmap_rect.x(), -canvas_bitmap_rect.y()); 236 canvas->translate(-canvas_bitmap_rect.x(), -canvas_bitmap_rect.y());
247 gfx::Rect content_rect = 237 gfx::Rect content_rect =
248 gfx::ScaleToEnclosingRect(gfx::Rect(size_), contents_scale); 238 gfx::ScaleToEnclosingRect(gfx::Rect(size_), contents_scale);
249 content_rect.Intersect(canvas_playback_rect); 239 content_rect.Intersect(canvas_playback_rect);
250 240
251 canvas->clipRect(gfx::RectToSkRect(content_rect), SkRegion::kIntersect_Op); 241 canvas->clipRect(gfx::RectToSkRect(content_rect), SkRegion::kIntersect_Op);
252 242
253 DCHECK(display_list_.get()); 243 DCHECK(display_list_.get());
254 gfx::Rect canvas_target_playback_rect = 244 gfx::Rect canvas_target_playback_rect =
255 canvas_playback_rect - canvas_bitmap_rect.OffsetFromOrigin(); 245 canvas_playback_rect - canvas_bitmap_rect.OffsetFromOrigin();
256 int repeat_count = std::max(1, slow_down_raster_scale_factor_for_debug_); 246 int repeat_count = std::max(1, slow_down_raster_scale_factor_for_debug_);
257 for (int i = 0; i < repeat_count; ++i) { 247 for (int i = 0; i < repeat_count; ++i) {
258 display_list_->Raster(canvas, callback, canvas_target_playback_rect, 248 display_list_->Raster(canvas, callback, canvas_target_playback_rect,
259 contents_scale); 249 contents_scale);
260 } 250 }
261 } 251 }
262 252
263 sk_sp<SkPicture> DisplayListRasterSource::GetFlattenedPicture() { 253 sk_sp<SkPicture> RasterSource::GetFlattenedPicture() {
264 TRACE_EVENT0("cc", "DisplayListRasterSource::GetFlattenedPicture"); 254 TRACE_EVENT0("cc", "RasterSource::GetFlattenedPicture");
265 255
266 gfx::Rect display_list_rect(size_); 256 gfx::Rect display_list_rect(size_);
267 SkPictureRecorder recorder; 257 SkPictureRecorder recorder;
268 SkCanvas* canvas = recorder.beginRecording(display_list_rect.width(), 258 SkCanvas* canvas = recorder.beginRecording(display_list_rect.width(),
269 display_list_rect.height()); 259 display_list_rect.height());
270 if (!display_list_rect.IsEmpty()) { 260 if (!display_list_rect.IsEmpty()) {
271 PrepareForPlaybackToCanvas(canvas, display_list_rect, display_list_rect, 261 PrepareForPlaybackToCanvas(canvas, display_list_rect, display_list_rect,
272 1.f); 262 1.f);
273 RasterCommon(canvas, nullptr, display_list_rect, display_list_rect, 1.f); 263 RasterCommon(canvas, nullptr, display_list_rect, display_list_rect, 1.f);
274 } 264 }
275 265
276 return recorder.finishRecordingAsPicture(); 266 return recorder.finishRecordingAsPicture();
277 } 267 }
278 268
279 size_t DisplayListRasterSource::GetPictureMemoryUsage() const { 269 size_t RasterSource::GetPictureMemoryUsage() const {
280 if (!display_list_) 270 if (!display_list_)
281 return 0; 271 return 0;
282 return display_list_->ApproximateMemoryUsage() + 272 return display_list_->ApproximateMemoryUsage() +
283 painter_reported_memory_usage_; 273 painter_reported_memory_usage_;
284 } 274 }
285 275
286 bool DisplayListRasterSource::PerformSolidColorAnalysis( 276 bool RasterSource::PerformSolidColorAnalysis(const gfx::Rect& content_rect,
287 const gfx::Rect& content_rect, 277 float contents_scale,
288 float contents_scale, 278 SkColor* color) const {
289 SkColor* color) const { 279 TRACE_EVENT0("cc", "RasterSource::PerformSolidColorAnalysis");
290 TRACE_EVENT0("cc", "DisplayListRasterSource::PerformSolidColorAnalysis");
291 280
292 gfx::Rect layer_rect = 281 gfx::Rect layer_rect =
293 gfx::ScaleToEnclosingRect(content_rect, 1.0f / contents_scale); 282 gfx::ScaleToEnclosingRect(content_rect, 1.0f / contents_scale);
294 283
295 layer_rect.Intersect(gfx::Rect(size_)); 284 layer_rect.Intersect(gfx::Rect(size_));
296 skia::AnalysisCanvas canvas(layer_rect.width(), layer_rect.height()); 285 skia::AnalysisCanvas canvas(layer_rect.width(), layer_rect.height());
297 RasterForAnalysis(&canvas, layer_rect, 1.0f); 286 RasterForAnalysis(&canvas, layer_rect, 1.0f);
298 return canvas.GetColorIfSolid(color); 287 return canvas.GetColorIfSolid(color);
299 } 288 }
300 289
301 void DisplayListRasterSource::GetDiscardableImagesInRect( 290 void RasterSource::GetDiscardableImagesInRect(
302 const gfx::Rect& layer_rect, 291 const gfx::Rect& layer_rect,
303 float raster_scale, 292 float raster_scale,
304 std::vector<DrawImage>* images) const { 293 std::vector<DrawImage>* images) const {
305 DCHECK_EQ(0u, images->size()); 294 DCHECK_EQ(0u, images->size());
306 display_list_->GetDiscardableImagesInRect(layer_rect, raster_scale, images); 295 display_list_->GetDiscardableImagesInRect(layer_rect, raster_scale, images);
307 } 296 }
308 297
309 bool DisplayListRasterSource::CoversRect(const gfx::Rect& layer_rect) const { 298 bool RasterSource::CoversRect(const gfx::Rect& layer_rect) const {
310 if (size_.IsEmpty()) 299 if (size_.IsEmpty())
311 return false; 300 return false;
312 gfx::Rect bounded_rect = layer_rect; 301 gfx::Rect bounded_rect = layer_rect;
313 bounded_rect.Intersect(gfx::Rect(size_)); 302 bounded_rect.Intersect(gfx::Rect(size_));
314 return recorded_viewport_.Contains(bounded_rect); 303 return recorded_viewport_.Contains(bounded_rect);
315 } 304 }
316 305
317 gfx::Size DisplayListRasterSource::GetSize() const { 306 gfx::Size RasterSource::GetSize() const {
318 return size_; 307 return size_;
319 } 308 }
320 309
321 bool DisplayListRasterSource::IsSolidColor() const { 310 bool RasterSource::IsSolidColor() const {
322 return is_solid_color_; 311 return is_solid_color_;
323 } 312 }
324 313
325 SkColor DisplayListRasterSource::GetSolidColor() const { 314 SkColor RasterSource::GetSolidColor() const {
326 DCHECK(IsSolidColor()); 315 DCHECK(IsSolidColor());
327 return solid_color_; 316 return solid_color_;
328 } 317 }
329 318
330 bool DisplayListRasterSource::HasRecordings() const { 319 bool RasterSource::HasRecordings() const {
331 return !!display_list_.get(); 320 return !!display_list_.get();
332 } 321 }
333 322
334 gfx::Rect DisplayListRasterSource::RecordedViewport() const { 323 gfx::Rect RasterSource::RecordedViewport() const {
335 return recorded_viewport_; 324 return recorded_viewport_;
336 } 325 }
337 326
338 void DisplayListRasterSource::SetShouldAttemptToUseDistanceFieldText() { 327 void RasterSource::SetShouldAttemptToUseDistanceFieldText() {
339 should_attempt_to_use_distance_field_text_ = true; 328 should_attempt_to_use_distance_field_text_ = true;
340 } 329 }
341 330
342 bool DisplayListRasterSource::ShouldAttemptToUseDistanceFieldText() const { 331 bool RasterSource::ShouldAttemptToUseDistanceFieldText() const {
343 return should_attempt_to_use_distance_field_text_; 332 return should_attempt_to_use_distance_field_text_;
344 } 333 }
345 334
346 void DisplayListRasterSource::AsValueInto( 335 void RasterSource::AsValueInto(base::trace_event::TracedValue* array) const {
347 base::trace_event::TracedValue* array) const {
348 if (display_list_.get()) 336 if (display_list_.get())
349 TracedValue::AppendIDRef(display_list_.get(), array); 337 TracedValue::AppendIDRef(display_list_.get(), array);
350 } 338 }
351 339
352 void DisplayListRasterSource::DidBeginTracing() { 340 void RasterSource::DidBeginTracing() {
353 if (display_list_.get()) 341 if (display_list_.get())
354 display_list_->EmitTraceSnapshot(); 342 display_list_->EmitTraceSnapshot();
355 } 343 }
356 344
357 bool DisplayListRasterSource::CanUseLCDText() const { 345 bool RasterSource::CanUseLCDText() const {
358 return can_use_lcd_text_; 346 return can_use_lcd_text_;
359 } 347 }
360 348
361 scoped_refptr<DisplayListRasterSource> 349 scoped_refptr<RasterSource> RasterSource::CreateCloneWithoutLCDText() const {
362 DisplayListRasterSource::CreateCloneWithoutLCDText() const {
363 bool can_use_lcd_text = false; 350 bool can_use_lcd_text = false;
364 return scoped_refptr<DisplayListRasterSource>( 351 return scoped_refptr<RasterSource>(new RasterSource(this, can_use_lcd_text));
365 new DisplayListRasterSource(this, can_use_lcd_text));
366 } 352 }
367 353
368 void DisplayListRasterSource::SetImageDecodeController( 354 void RasterSource::SetImageDecodeController(
369 ImageDecodeController* image_decode_controller) { 355 ImageDecodeController* image_decode_controller) {
370 DCHECK(image_decode_controller); 356 DCHECK(image_decode_controller);
371 image_decode_controller_ = image_decode_controller; 357 image_decode_controller_ = image_decode_controller;
372 } 358 }
373 359
374 bool DisplayListRasterSource::OnMemoryDump( 360 bool RasterSource::OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
375 const base::trace_event::MemoryDumpArgs& args, 361 base::trace_event::ProcessMemoryDump* pmd) {
376 base::trace_event::ProcessMemoryDump* pmd) {
377 DCHECK(memory_dump_thread_checker_.CalledOnValidThread()); 362 DCHECK(memory_dump_thread_checker_.CalledOnValidThread());
378 363
379 uint64_t memory_usage = GetPictureMemoryUsage(); 364 uint64_t memory_usage = GetPictureMemoryUsage();
380 if (memory_usage > 0) { 365 if (memory_usage > 0) {
381 std::string dump_name = base::StringPrintf( 366 std::string dump_name =
382 "cc/display_lists/display_list_raster_source_%p", this); 367 base::StringPrintf("cc/display_lists/raster_source_%p", this);
383 base::trace_event::MemoryAllocatorDump* dump = 368 base::trace_event::MemoryAllocatorDump* dump =
384 pmd->CreateAllocatorDump(dump_name); 369 pmd->CreateAllocatorDump(dump_name);
385 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, 370 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
386 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 371 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
387 memory_usage); 372 memory_usage);
388 } 373 }
389 return true; 374 return true;
390 } 375 }
391 376
392 } // namespace cc 377 } // namespace cc
OLDNEW
« no previous file with comments | « cc/playback/raster_source.h ('k') | cc/playback/raster_source_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698