| 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/drawing_display_item.h" | 5 #include "cc/playback/drawing_display_item.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/trace_event/trace_event_argument.h" | 10 #include "base/trace_event/trace_event_argument.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 SkMemoryStream stream(details.picture().data(), details.picture().size()); | 62 SkMemoryStream stream(details.picture().data(), details.picture().size()); |
| 63 | 63 |
| 64 // TODO(dtrainor, nyquist): Add an image decoder. | 64 // TODO(dtrainor, nyquist): Add an image decoder. |
| 65 picture = skia::AdoptRef(SkPicture::CreateFromStream(&stream, nullptr)); | 65 picture = skia::AdoptRef(SkPicture::CreateFromStream(&stream, nullptr)); |
| 66 } | 66 } |
| 67 | 67 |
| 68 SetNew(std::move(picture)); | 68 SetNew(std::move(picture)); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void DrawingDisplayItem::Raster(SkCanvas* canvas, | 71 void DrawingDisplayItem::Raster(SkCanvas* canvas, |
| 72 const gfx::Rect& canvas_target_playback_rect, | |
| 73 SkPicture::AbortCallback* callback) const { | 72 SkPicture::AbortCallback* callback) const { |
| 74 // The canvas_playback_rect can be empty to signify no culling is desired. | |
| 75 if (!canvas_target_playback_rect.IsEmpty()) { | |
| 76 const SkMatrix& matrix = canvas->getTotalMatrix(); | |
| 77 const SkRect& cull_rect = picture_->cullRect(); | |
| 78 SkRect target_rect; | |
| 79 matrix.mapRect(&target_rect, cull_rect); | |
| 80 if (!target_rect.intersect(gfx::RectToSkRect(canvas_target_playback_rect))) | |
| 81 return; | |
| 82 } | |
| 83 | |
| 84 // SkPicture always does a wrapping save/restore on the canvas, so it is not | 73 // SkPicture always does a wrapping save/restore on the canvas, so it is not |
| 85 // necessary here. | 74 // necessary here. |
| 86 if (callback) | 75 if (callback) |
| 87 picture_->playback(canvas, callback); | 76 picture_->playback(canvas, callback); |
| 88 else | 77 else |
| 89 canvas->drawPicture(picture_.get()); | 78 canvas->drawPicture(picture_.get()); |
| 90 } | 79 } |
| 91 | 80 |
| 92 void DrawingDisplayItem::AsValueInto( | 81 void DrawingDisplayItem::AsValueInto( |
| 93 const gfx::Rect& visual_rect, | 82 const gfx::Rect& visual_rect, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 113 PictureDebugUtil::SerializeAsBase64(picture_.get(), &b64_picture); | 102 PictureDebugUtil::SerializeAsBase64(picture_.get(), &b64_picture); |
| 114 array->SetString("skp64", b64_picture); | 103 array->SetString("skp64", b64_picture); |
| 115 array->EndDictionary(); | 104 array->EndDictionary(); |
| 116 } | 105 } |
| 117 | 106 |
| 118 void DrawingDisplayItem::CloneTo(DrawingDisplayItem* item) const { | 107 void DrawingDisplayItem::CloneTo(DrawingDisplayItem* item) const { |
| 119 item->SetNew(picture_); | 108 item->SetNew(picture_); |
| 120 } | 109 } |
| 121 | 110 |
| 122 } // namespace cc | 111 } // namespace cc |
| OLD | NEW |