Chromium Code Reviews| 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 <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 "skia/ext/analysis_canvas.h" | 18 #include "skia/ext/analysis_canvas.h" |
| 18 #include "third_party/skia/include/core/SkCanvas.h" | 19 #include "third_party/skia/include/core/SkCanvas.h" |
| 19 #include "third_party/skia/include/core/SkPictureRecorder.h" | 20 #include "third_party/skia/include/core/SkPictureRecorder.h" |
| 20 #include "third_party/skia/include/core/SkTLazy.h" | 21 #include "third_party/skia/include/core/SkTLazy.h" |
| 21 #include "ui/gfx/geometry/rect_conversions.h" | 22 #include "ui/gfx/geometry/rect_conversions.h" |
| 22 | 23 |
| 23 namespace cc { | 24 namespace cc { |
| 24 | 25 |
| 25 scoped_refptr<DisplayListRasterSource> | 26 scoped_refptr<DisplayListRasterSource> |
| 26 DisplayListRasterSource::CreateFromDisplayListRecordingSource( | 27 DisplayListRasterSource::CreateFromDisplayListRecordingSource( |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 // For MemoryDumpProvider deregistration to work correctly, this must happen | 90 // For MemoryDumpProvider deregistration to work correctly, this must happen |
| 90 // on the same thread that the DisplayListRasterSource was created on. | 91 // on the same thread that the DisplayListRasterSource was created on. |
| 91 DCHECK(memory_dump_thread_checker_.CalledOnValidThread()); | 92 DCHECK(memory_dump_thread_checker_.CalledOnValidThread()); |
| 92 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( | 93 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( |
| 93 this); | 94 this); |
| 94 } | 95 } |
| 95 | 96 |
| 96 void DisplayListRasterSource::PlaybackToSharedCanvas( | 97 void DisplayListRasterSource::PlaybackToSharedCanvas( |
| 97 SkCanvas* raster_canvas, | 98 SkCanvas* raster_canvas, |
| 98 const gfx::Rect& canvas_rect, | 99 const gfx::Rect& canvas_rect, |
| 99 float contents_scale) const { | 100 float contents_scale, |
| 101 bool include_images) const { | |
| 100 // TODO(vmpstr): This can be improved by plumbing whether the tile itself has | 102 // TODO(vmpstr): This can be improved by plumbing whether the tile itself has |
| 101 // discardable images. This way we would only pay for the hijack canvas if the | 103 // discardable images. This way we would only pay for the hijack canvas if the |
|
ericrk
2016/03/14 21:40:13
nit: comment probably applies to both cases - not
| |
| 102 // tile actually needed it. | 104 // tile actually needed it. |
| 103 if (display_list_->MayHaveDiscardableImages()) { | 105 if (!include_images) { |
| 106 SkipImageCanvas canvas(raster_canvas); | |
| 107 RasterCommon(&canvas, nullptr, canvas_rect, canvas_rect, contents_scale); | |
| 108 } else if (display_list_->MayHaveDiscardableImages()) { | |
| 104 const SkImageInfo& info = raster_canvas->imageInfo(); | 109 const SkImageInfo& info = raster_canvas->imageInfo(); |
| 105 ImageHijackCanvas canvas(info.width(), info.height(), | 110 ImageHijackCanvas canvas(info.width(), info.height(), |
| 106 image_decode_controller_); | 111 image_decode_controller_); |
| 107 canvas.addCanvas(raster_canvas); | 112 canvas.addCanvas(raster_canvas); |
| 108 | 113 |
| 109 RasterCommon(&canvas, nullptr, canvas_rect, canvas_rect, contents_scale); | 114 RasterCommon(&canvas, nullptr, canvas_rect, canvas_rect, contents_scale); |
| 110 } else { | 115 } else { |
| 111 RasterCommon(raster_canvas, nullptr, canvas_rect, canvas_rect, | 116 RasterCommon(raster_canvas, nullptr, canvas_rect, canvas_rect, |
| 112 contents_scale); | 117 contents_scale); |
| 113 } | 118 } |
| 114 } | 119 } |
| 115 | 120 |
| 116 void DisplayListRasterSource::RasterForAnalysis(skia::AnalysisCanvas* canvas, | 121 void DisplayListRasterSource::RasterForAnalysis(skia::AnalysisCanvas* canvas, |
| 117 const gfx::Rect& canvas_rect, | 122 const gfx::Rect& canvas_rect, |
| 118 float contents_scale) const { | 123 float contents_scale) const { |
| 119 RasterCommon(canvas, canvas, canvas_rect, canvas_rect, contents_scale); | 124 RasterCommon(canvas, canvas, canvas_rect, canvas_rect, contents_scale); |
| 120 } | 125 } |
| 121 | 126 |
| 122 void DisplayListRasterSource::PlaybackToCanvas( | 127 void DisplayListRasterSource::PlaybackToCanvas( |
| 123 SkCanvas* raster_canvas, | 128 SkCanvas* raster_canvas, |
| 124 const gfx::Rect& canvas_bitmap_rect, | 129 const gfx::Rect& canvas_bitmap_rect, |
| 125 const gfx::Rect& canvas_playback_rect, | 130 const gfx::Rect& canvas_playback_rect, |
| 126 float contents_scale) const { | 131 float contents_scale, |
| 132 bool include_images) const { | |
| 127 PrepareForPlaybackToCanvas(raster_canvas, canvas_bitmap_rect, | 133 PrepareForPlaybackToCanvas(raster_canvas, canvas_bitmap_rect, |
| 128 canvas_playback_rect, contents_scale); | 134 canvas_playback_rect, contents_scale); |
| 129 | 135 |
| 130 if (display_list_->MayHaveDiscardableImages()) { | 136 if (!include_images) { |
| 137 SkipImageCanvas canvas(raster_canvas); | |
| 138 RasterCommon(&canvas, nullptr, canvas_bitmap_rect, canvas_playback_rect, | |
| 139 contents_scale); | |
| 140 } else if (display_list_->MayHaveDiscardableImages()) { | |
| 131 const SkImageInfo& info = raster_canvas->imageInfo(); | 141 const SkImageInfo& info = raster_canvas->imageInfo(); |
| 132 ImageHijackCanvas canvas(info.width(), info.height(), | 142 ImageHijackCanvas canvas(info.width(), info.height(), |
| 133 image_decode_controller_); | 143 image_decode_controller_); |
| 134 canvas.addCanvas(raster_canvas); | 144 canvas.addCanvas(raster_canvas); |
| 135 RasterCommon(&canvas, nullptr, canvas_bitmap_rect, canvas_playback_rect, | 145 RasterCommon(&canvas, nullptr, canvas_bitmap_rect, canvas_playback_rect, |
| 136 contents_scale); | 146 contents_scale); |
| 137 } else { | 147 } else { |
| 138 RasterCommon(raster_canvas, nullptr, canvas_bitmap_rect, | 148 RasterCommon(raster_canvas, nullptr, canvas_bitmap_rect, |
| 139 canvas_playback_rect, contents_scale); | 149 canvas_playback_rect, contents_scale); |
| 140 } | 150 } |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 375 base::trace_event::MemoryAllocatorDump* dump = | 385 base::trace_event::MemoryAllocatorDump* dump = |
| 376 pmd->CreateAllocatorDump(dump_name); | 386 pmd->CreateAllocatorDump(dump_name); |
| 377 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, | 387 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
| 378 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 388 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
| 379 memory_usage); | 389 memory_usage); |
| 380 } | 390 } |
| 381 return true; | 391 return true; |
| 382 } | 392 } |
| 383 | 393 |
| 384 } // namespace cc | 394 } // namespace cc |
| OLD | NEW |