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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 picture_->serialize(&stream, | 75 picture_->serialize(&stream, |
76 image_serialization_processor->GetPixelSerializer()); | 76 image_serialization_processor->GetPixelSerializer()); |
77 if (stream.bytesWritten() > 0) { | 77 if (stream.bytesWritten() > 0) { |
78 SkAutoDataUnref data(stream.copyToData()); | 78 SkAutoDataUnref data(stream.copyToData()); |
79 details->set_picture(data->data(), data->size()); | 79 details->set_picture(data->data(), data->size()); |
80 } | 80 } |
81 } | 81 } |
82 } | 82 } |
83 | 83 |
84 void DrawingDisplayItem::Raster(SkCanvas* canvas, | 84 void DrawingDisplayItem::Raster(SkCanvas* canvas, |
85 const gfx::Rect& canvas_target_playback_rect, | |
86 SkPicture::AbortCallback* callback) const { | 85 SkPicture::AbortCallback* callback) const { |
87 // The canvas_playback_rect can be empty to signify no culling is desired. | 86 if (canvas->quickReject(picture_->cullRect())) |
88 if (!canvas_target_playback_rect.IsEmpty()) { | 87 return; |
89 const SkMatrix& matrix = canvas->getTotalMatrix(); | |
90 const SkRect& cull_rect = picture_->cullRect(); | |
91 SkRect target_rect; | |
92 matrix.mapRect(&target_rect, cull_rect); | |
93 if (!target_rect.intersect(gfx::RectToSkRect(canvas_target_playback_rect))) | |
94 return; | |
95 } | |
96 | 88 |
97 // SkPicture always does a wrapping save/restore on the canvas, so it is not | 89 // SkPicture always does a wrapping save/restore on the canvas, so it is not |
98 // necessary here. | 90 // necessary here. |
99 if (callback) | 91 if (callback) |
100 picture_->playback(canvas, callback); | 92 picture_->playback(canvas, callback); |
101 else | 93 else |
102 canvas->drawPicture(picture_.get()); | 94 canvas->drawPicture(picture_.get()); |
103 } | 95 } |
104 | 96 |
105 void DrawingDisplayItem::AsValueInto( | 97 void DrawingDisplayItem::AsValueInto( |
(...skipping 28 matching lines...) Expand all Loading... |
134 | 126 |
135 size_t DrawingDisplayItem::ExternalMemoryUsage() const { | 127 size_t DrawingDisplayItem::ExternalMemoryUsage() const { |
136 return SkPictureUtils::ApproximateBytesUsed(picture_.get()); | 128 return SkPictureUtils::ApproximateBytesUsed(picture_.get()); |
137 } | 129 } |
138 | 130 |
139 int DrawingDisplayItem::ApproximateOpCount() const { | 131 int DrawingDisplayItem::ApproximateOpCount() const { |
140 return picture_->approximateOpCount(); | 132 return picture_->approximateOpCount(); |
141 } | 133 } |
142 | 134 |
143 } // namespace cc | 135 } // namespace cc |
OLD | NEW |