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/playback/display_list_raster_source.h" | 5 #include "cc/playback/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/playback/display_item_list.h" | 10 #include "cc/playback/display_item_list.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 other->should_attempt_to_use_distance_field_text_) { | 80 other->should_attempt_to_use_distance_field_text_) { |
81 } | 81 } |
82 | 82 |
83 DisplayListRasterSource::~DisplayListRasterSource() { | 83 DisplayListRasterSource::~DisplayListRasterSource() { |
84 } | 84 } |
85 | 85 |
86 void DisplayListRasterSource::PlaybackToSharedCanvas( | 86 void DisplayListRasterSource::PlaybackToSharedCanvas( |
87 SkCanvas* canvas, | 87 SkCanvas* canvas, |
88 const gfx::Rect& canvas_rect, | 88 const gfx::Rect& canvas_rect, |
89 float contents_scale) const { | 89 float contents_scale) const { |
90 RasterCommon(canvas, NULL, canvas_rect, contents_scale); | 90 RasterCommon(canvas, NULL, canvas_rect, canvas_rect, contents_scale); |
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, canvas_rect, contents_scale); |
97 } | 97 } |
98 | 98 |
99 void DisplayListRasterSource::PlaybackToCanvas(SkCanvas* canvas, | 99 void DisplayListRasterSource::PlaybackToCanvas( |
100 const gfx::Rect& canvas_rect, | 100 SkCanvas* canvas, |
101 float contents_scale) const { | 101 const gfx::Rect& canvas_bitmap_rect, |
| 102 const gfx::Rect& canvas_playback_rect, |
| 103 float contents_scale) const { |
102 RasterSourceHelper::PrepareForPlaybackToCanvas( | 104 RasterSourceHelper::PrepareForPlaybackToCanvas( |
103 canvas, canvas_rect, gfx::Rect(size_), contents_scale, background_color_, | 105 canvas, canvas_bitmap_rect, canvas_playback_rect, gfx::Rect(size_), |
104 clear_canvas_with_debug_color_, requires_clear_); | 106 contents_scale, background_color_, clear_canvas_with_debug_color_, |
| 107 requires_clear_); |
105 | 108 |
106 RasterCommon(canvas, NULL, canvas_rect, contents_scale); | 109 RasterCommon(canvas, NULL, canvas_bitmap_rect, canvas_playback_rect, |
| 110 contents_scale); |
107 } | 111 } |
108 | 112 |
109 void DisplayListRasterSource::RasterCommon(SkCanvas* canvas, | 113 void DisplayListRasterSource::RasterCommon( |
110 SkPicture::AbortCallback* callback, | 114 SkCanvas* canvas, |
111 const gfx::Rect& canvas_rect, | 115 SkPicture::AbortCallback* callback, |
112 float contents_scale) const { | 116 const gfx::Rect& canvas_bitmap_rect, |
113 canvas->translate(-canvas_rect.x(), -canvas_rect.y()); | 117 const gfx::Rect& canvas_playback_rect, |
| 118 float contents_scale) const { |
| 119 canvas->translate(-canvas_bitmap_rect.x(), -canvas_bitmap_rect.y()); |
114 gfx::Rect content_rect = | 120 gfx::Rect content_rect = |
115 gfx::ToEnclosingRect(gfx::ScaleRect(gfx::Rect(size_), contents_scale)); | 121 gfx::ToEnclosingRect(gfx::ScaleRect(gfx::Rect(size_), contents_scale)); |
116 content_rect.Intersect(canvas_rect); | 122 content_rect.Intersect(canvas_playback_rect); |
117 | 123 |
118 canvas->clipRect(gfx::RectToSkRect(content_rect), SkRegion::kIntersect_Op); | 124 canvas->clipRect(gfx::RectToSkRect(content_rect), SkRegion::kIntersect_Op); |
119 | 125 |
120 DCHECK(display_list_.get()); | 126 DCHECK(display_list_.get()); |
121 display_list_->Raster(canvas, callback, contents_scale); | 127 display_list_->Raster(canvas, callback, contents_scale); |
122 } | 128 } |
123 | 129 |
124 skia::RefPtr<SkPicture> DisplayListRasterSource::GetFlattenedPicture() { | 130 skia::RefPtr<SkPicture> DisplayListRasterSource::GetFlattenedPicture() { |
125 TRACE_EVENT0("cc", "DisplayListRasterSource::GetFlattenedPicture"); | 131 TRACE_EVENT0("cc", "DisplayListRasterSource::GetFlattenedPicture"); |
126 | 132 |
127 gfx::Rect display_list_rect(size_); | 133 gfx::Rect display_list_rect(size_); |
128 SkPictureRecorder recorder; | 134 SkPictureRecorder recorder; |
129 SkCanvas* canvas = recorder.beginRecording(display_list_rect.width(), | 135 SkCanvas* canvas = recorder.beginRecording(display_list_rect.width(), |
130 display_list_rect.height()); | 136 display_list_rect.height()); |
131 if (!display_list_rect.IsEmpty()) | 137 if (!display_list_rect.IsEmpty()) |
132 PlaybackToCanvas(canvas, display_list_rect, 1.0); | 138 PlaybackToCanvas(canvas, display_list_rect, display_list_rect, 1.0); |
133 skia::RefPtr<SkPicture> picture = | 139 skia::RefPtr<SkPicture> picture = |
134 skia::AdoptRef(recorder.endRecordingAsPicture()); | 140 skia::AdoptRef(recorder.endRecordingAsPicture()); |
135 | 141 |
136 return picture; | 142 return picture; |
137 } | 143 } |
138 | 144 |
139 size_t DisplayListRasterSource::GetPictureMemoryUsage() const { | 145 size_t DisplayListRasterSource::GetPictureMemoryUsage() const { |
140 if (!display_list_) | 146 if (!display_list_) |
141 return 0; | 147 return 0; |
142 return display_list_->PictureMemoryUsage(); | 148 return display_list_->PictureMemoryUsage(); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 } | 232 } |
227 | 233 |
228 scoped_refptr<RasterSource> DisplayListRasterSource::CreateCloneWithoutLCDText() | 234 scoped_refptr<RasterSource> DisplayListRasterSource::CreateCloneWithoutLCDText() |
229 const { | 235 const { |
230 bool can_use_lcd_text = false; | 236 bool can_use_lcd_text = false; |
231 return scoped_refptr<RasterSource>( | 237 return scoped_refptr<RasterSource>( |
232 new DisplayListRasterSource(this, can_use_lcd_text)); | 238 new DisplayListRasterSource(this, can_use_lcd_text)); |
233 } | 239 } |
234 | 240 |
235 } // namespace cc | 241 } // namespace cc |
OLD | NEW |