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/resources/display_list_raster_source.h" | 5 #include "cc/resources/display_list_raster_source.h" |
6 | 6 |
7 #include "base/trace_event/trace_event.h" | 7 #include "base/trace_event/trace_event.h" |
8 #include "cc/base/region.h" | 8 #include "cc/base/region.h" |
9 #include "cc/debug/debug_colors.h" | 9 #include "cc/debug/debug_colors.h" |
10 #include "cc/resources/display_item_list.h" | 10 #include "cc/resources/display_item_list.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 } | 91 } |
92 | 92 |
93 void DisplayListRasterSource::RasterForAnalysis(skia::AnalysisCanvas* canvas, | 93 void DisplayListRasterSource::RasterForAnalysis(skia::AnalysisCanvas* canvas, |
94 const gfx::Rect& canvas_rect, | 94 const gfx::Rect& canvas_rect, |
95 float contents_scale) const { | 95 float contents_scale) const { |
96 RasterCommon(canvas, canvas, canvas_rect, contents_scale); | 96 RasterCommon(canvas, canvas, canvas_rect, contents_scale); |
97 } | 97 } |
98 | 98 |
99 void DisplayListRasterSource::PlaybackToCanvas(SkCanvas* canvas, | 99 void DisplayListRasterSource::PlaybackToCanvas(SkCanvas* canvas, |
100 const gfx::Rect& canvas_rect, | 100 const gfx::Rect& canvas_rect, |
101 float contents_scale) const { | 101 float contents_scale, |
102 bool partial_update) const { | |
102 RasterSourceHelper::PrepareForPlaybackToCanvas( | 103 RasterSourceHelper::PrepareForPlaybackToCanvas( |
103 canvas, canvas_rect, gfx::Rect(size_), contents_scale, background_color_, | 104 canvas, canvas_rect, gfx::Rect(size_), contents_scale, background_color_, |
104 clear_canvas_with_debug_color_, requires_clear_); | 105 clear_canvas_with_debug_color_, requires_clear_, partial_update); |
105 | 106 |
106 RasterCommon(canvas, NULL, canvas_rect, contents_scale); | 107 RasterCommon(canvas, NULL, canvas_rect, contents_scale); |
107 } | 108 } |
108 | 109 |
109 void DisplayListRasterSource::RasterCommon(SkCanvas* canvas, | 110 void DisplayListRasterSource::RasterCommon(SkCanvas* canvas, |
110 SkDrawPictureCallback* callback, | 111 SkDrawPictureCallback* callback, |
111 const gfx::Rect& canvas_rect, | 112 const gfx::Rect& canvas_rect, |
112 float contents_scale) const { | 113 float contents_scale) const { |
113 canvas->translate(-canvas_rect.x(), -canvas_rect.y()); | 114 canvas->translate(-canvas_rect.x(), -canvas_rect.y()); |
114 gfx::Rect content_rect = | 115 gfx::Rect content_rect = |
115 gfx::ToEnclosingRect(gfx::ScaleRect(gfx::Rect(size_), contents_scale)); | 116 gfx::ToEnclosingRect(gfx::ScaleRect(gfx::Rect(size_), contents_scale)); |
116 content_rect.Intersect(canvas_rect); | 117 content_rect.Intersect(canvas_rect); |
117 | 118 |
118 canvas->clipRect(gfx::RectToSkRect(content_rect), SkRegion::kIntersect_Op); | 119 canvas->clipRect(gfx::RectToSkRect(content_rect), SkRegion::kIntersect_Op); |
119 | 120 |
120 DCHECK(display_list_.get()); | 121 DCHECK(display_list_.get()); |
121 display_list_->Raster(canvas, callback, contents_scale); | 122 display_list_->Raster(canvas, callback, contents_scale); |
122 } | 123 } |
123 | 124 |
124 skia::RefPtr<SkPicture> DisplayListRasterSource::GetFlattenedPicture() { | 125 skia::RefPtr<SkPicture> DisplayListRasterSource::GetFlattenedPicture() { |
125 TRACE_EVENT0("cc", "DisplayListRasterSource::GetFlattenedPicture"); | 126 TRACE_EVENT0("cc", "DisplayListRasterSource::GetFlattenedPicture"); |
126 | 127 |
127 gfx::Rect display_list_rect(size_); | 128 gfx::Rect display_list_rect(size_); |
128 SkPictureRecorder recorder; | 129 SkPictureRecorder recorder; |
129 SkCanvas* canvas = recorder.beginRecording(display_list_rect.width(), | 130 SkCanvas* canvas = recorder.beginRecording(display_list_rect.width(), |
130 display_list_rect.height()); | 131 display_list_rect.height()); |
131 if (!display_list_rect.IsEmpty()) | 132 if (!display_list_rect.IsEmpty()) |
piman
2015/05/14 19:50:46
nit: {}
danakj
2015/05/14 22:03:42
Undone.
| |
132 PlaybackToCanvas(canvas, display_list_rect, 1.0); | 133 PlaybackToCanvas(canvas, display_list_rect, 1.0, |
134 false /* partial_update */); | |
133 skia::RefPtr<SkPicture> picture = | 135 skia::RefPtr<SkPicture> picture = |
134 skia::AdoptRef(recorder.endRecordingAsPicture()); | 136 skia::AdoptRef(recorder.endRecordingAsPicture()); |
135 | 137 |
136 return picture; | 138 return picture; |
137 } | 139 } |
138 | 140 |
139 size_t DisplayListRasterSource::GetPictureMemoryUsage() const { | 141 size_t DisplayListRasterSource::GetPictureMemoryUsage() const { |
140 if (!display_list_) | 142 if (!display_list_) |
141 return 0; | 143 return 0; |
142 return display_list_->PictureMemoryUsage(); | 144 return display_list_->PictureMemoryUsage(); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
226 } | 228 } |
227 | 229 |
228 scoped_refptr<RasterSource> DisplayListRasterSource::CreateCloneWithoutLCDText() | 230 scoped_refptr<RasterSource> DisplayListRasterSource::CreateCloneWithoutLCDText() |
229 const { | 231 const { |
230 bool can_use_lcd_text = false; | 232 bool can_use_lcd_text = false; |
231 return scoped_refptr<RasterSource>( | 233 return scoped_refptr<RasterSource>( |
232 new DisplayListRasterSource(this, can_use_lcd_text)); | 234 new DisplayListRasterSource(this, can_use_lcd_text)); |
233 } | 235 } |
234 | 236 |
235 } // namespace cc | 237 } // namespace cc |
OLD | NEW |