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/raster/raster_source.h" | 5 #include "cc/raster/raster_source.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 color_transform_canvas = SkCreateColorSpaceXformCanvas( | 94 color_transform_canvas = SkCreateColorSpaceXformCanvas( |
95 input_canvas, target_color_space.ToSkColorSpace()); | 95 input_canvas, target_color_space.ToSkColorSpace()); |
96 raster_canvas = color_transform_canvas.get(); | 96 raster_canvas = color_transform_canvas.get(); |
97 } | 97 } |
98 | 98 |
99 if (!settings.playback_to_shared_canvas) | 99 if (!settings.playback_to_shared_canvas) |
100 PrepareForPlaybackToCanvas(raster_canvas); | 100 PrepareForPlaybackToCanvas(raster_canvas); |
101 | 101 |
102 if (settings.skip_images) { | 102 if (settings.skip_images) { |
103 SkipImageCanvas canvas(raster_canvas); | 103 SkipImageCanvas canvas(raster_canvas); |
104 RasterCommon(&canvas, nullptr); | 104 RasterCommon(&canvas); |
105 } else if (settings.use_image_hijack_canvas) { | 105 } else if (settings.use_image_hijack_canvas) { |
106 const SkImageInfo& info = raster_canvas->imageInfo(); | 106 const SkImageInfo& info = raster_canvas->imageInfo(); |
107 ImageHijackCanvas canvas(info.width(), info.height(), image_decode_cache_, | 107 ImageHijackCanvas canvas(info.width(), info.height(), image_decode_cache_, |
108 &settings.images_to_skip, target_color_space); | 108 &settings.images_to_skip, target_color_space); |
109 // Before adding the canvas, make sure that the ImageHijackCanvas is aware | 109 // Before adding the canvas, make sure that the ImageHijackCanvas is aware |
110 // of the current transform and clip, which may affect the clip bounds. | 110 // of the current transform and clip, which may affect the clip bounds. |
111 // Since we query the clip bounds of the current canvas to get the list of | 111 // Since we query the clip bounds of the current canvas to get the list of |
112 // draw commands to process, this is important to produce correct content. | 112 // draw commands to process, this is important to produce correct content. |
113 canvas.clipRect( | 113 canvas.clipRect( |
114 SkRect::MakeFromIRect(raster_canvas->getDeviceClipBounds())); | 114 SkRect::MakeFromIRect(raster_canvas->getDeviceClipBounds())); |
115 canvas.setMatrix(raster_canvas->getTotalMatrix()); | 115 canvas.setMatrix(raster_canvas->getTotalMatrix()); |
116 canvas.addCanvas(raster_canvas); | 116 canvas.addCanvas(raster_canvas); |
117 | 117 |
118 RasterCommon(&canvas, nullptr); | 118 RasterCommon(&canvas); |
119 } else { | 119 } else { |
120 RasterCommon(raster_canvas, nullptr); | 120 RasterCommon(raster_canvas); |
121 } | 121 } |
122 } | 122 } |
123 | 123 |
124 namespace { | 124 namespace { |
125 | 125 |
126 bool CanvasIsUnclipped(const SkCanvas* canvas) { | 126 bool CanvasIsUnclipped(const SkCanvas* canvas) { |
127 if (!canvas->isClipRect()) | 127 if (!canvas->isClipRect()) |
128 return false; | 128 return false; |
129 | 129 |
130 SkIRect bounds; | 130 SkIRect bounds; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 display_list_->Raster(raster_canvas, callback); | 218 display_list_->Raster(raster_canvas, callback); |
219 } | 219 } |
220 | 220 |
221 sk_sp<SkPicture> RasterSource::GetFlattenedPicture() { | 221 sk_sp<SkPicture> RasterSource::GetFlattenedPicture() { |
222 TRACE_EVENT0("cc", "RasterSource::GetFlattenedPicture"); | 222 TRACE_EVENT0("cc", "RasterSource::GetFlattenedPicture"); |
223 | 223 |
224 SkPictureRecorder recorder; | 224 SkPictureRecorder recorder; |
225 SkCanvas* canvas = recorder.beginRecording(size_.width(), size_.height()); | 225 SkCanvas* canvas = recorder.beginRecording(size_.width(), size_.height()); |
226 if (!size_.IsEmpty()) { | 226 if (!size_.IsEmpty()) { |
227 PrepareForPlaybackToCanvas(canvas); | 227 PrepareForPlaybackToCanvas(canvas); |
228 RasterCommon(canvas, nullptr); | 228 RasterCommon(canvas); |
229 } | 229 } |
230 | 230 |
231 return recorder.finishRecordingAsPicture(); | 231 return recorder.finishRecordingAsPicture(); |
232 } | 232 } |
233 | 233 |
234 size_t RasterSource::GetMemoryUsage() const { | 234 size_t RasterSource::GetMemoryUsage() const { |
235 if (!display_list_) | 235 if (!display_list_) |
236 return 0; | 236 return 0; |
237 return display_list_->ApproximateMemoryUsage() + | 237 return display_list_->ApproximateMemoryUsage() + |
238 painter_reported_memory_usage_; | 238 painter_reported_memory_usage_; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 use_image_hijack_canvas(true) {} | 325 use_image_hijack_canvas(true) {} |
326 | 326 |
327 RasterSource::PlaybackSettings::PlaybackSettings(const PlaybackSettings&) = | 327 RasterSource::PlaybackSettings::PlaybackSettings(const PlaybackSettings&) = |
328 default; | 328 default; |
329 | 329 |
330 RasterSource::PlaybackSettings::PlaybackSettings(PlaybackSettings&&) = default; | 330 RasterSource::PlaybackSettings::PlaybackSettings(PlaybackSettings&&) = default; |
331 | 331 |
332 RasterSource::PlaybackSettings::~PlaybackSettings() = default; | 332 RasterSource::PlaybackSettings::~PlaybackSettings() = default; |
333 | 333 |
334 } // namespace cc | 334 } // namespace cc |
OLD | NEW |