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/paint/display_item_list.h" | 5 #include "cc/paint/display_item_list.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 } | 156 } |
157 | 157 |
158 } // namespace | 158 } // namespace |
159 | 159 |
160 DisplayItemList::DisplayItemList() | 160 DisplayItemList::DisplayItemList() |
161 : items_(LargestDisplayItemSize(), | 161 : items_(LargestDisplayItemSize(), |
162 LargestDisplayItemSize() * kDefaultNumDisplayItemsToReserve) {} | 162 LargestDisplayItemSize() * kDefaultNumDisplayItemsToReserve) {} |
163 | 163 |
164 DisplayItemList::~DisplayItemList() = default; | 164 DisplayItemList::~DisplayItemList() = default; |
165 | 165 |
166 void DisplayItemList::Raster(SkCanvas* canvas, | |
167 SkPicture::AbortCallback* callback, | |
168 const gfx::Rect& canvas_target_playback_rect, | |
169 float contents_scale) const { | |
170 canvas->save(); | |
171 if (!canvas_target_playback_rect.IsEmpty()) { | |
172 // canvas_target_playback_rect is specified in device space. We can't | |
173 // use clipRect because canvas CTM will be applied on it. Use clipRegion | |
174 // instead because it ignores canvas CTM. | |
175 SkRegion device_clip; | |
176 device_clip.setRect(gfx::RectToSkIRect(canvas_target_playback_rect)); | |
177 canvas->clipRegion(device_clip); | |
178 } | |
179 canvas->scale(contents_scale, contents_scale); | |
180 Raster(canvas, callback); | |
181 canvas->restore(); | |
182 } | |
183 | |
184 // Atttempts to merge a CompositingDisplayItem and DrawingDisplayItem | 166 // Atttempts to merge a CompositingDisplayItem and DrawingDisplayItem |
185 // into a single "draw with alpha". This function returns true if | 167 // into a single "draw with alpha". This function returns true if |
186 // it was successful. If false, then the caller is responsible for | 168 // it was successful. If false, then the caller is responsible for |
187 // drawing these items. This is a DisplayItemList version of the | 169 // drawing these items. This is a DisplayItemList version of the |
188 // SkRecord optimization SkRecordNoopSaveLayerDrawRestores. | 170 // SkRecord optimization SkRecordNoopSaveLayerDrawRestores. |
189 static bool MergeAndDrawIfPossible(const CompositingDisplayItem& save_item, | 171 static bool MergeAndDrawIfPossible(const CompositingDisplayItem& save_item, |
190 const DrawingDisplayItem& draw_item, | 172 const DrawingDisplayItem& draw_item, |
191 SkCanvas* canvas) { | 173 SkCanvas* canvas) { |
192 if (save_item.color_filter) | 174 if (save_item.color_filter) |
193 return false; | 175 return false; |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 | 488 |
507 MathUtil::AddToTracedValue("layer_rect", rtree_.GetBounds(), state.get()); | 489 MathUtil::AddToTracedValue("layer_rect", rtree_.GetBounds(), state.get()); |
508 state->EndDictionary(); // "params". | 490 state->EndDictionary(); // "params". |
509 | 491 |
510 { | 492 { |
511 SkPictureRecorder recorder; | 493 SkPictureRecorder recorder; |
512 gfx::Rect bounds = rtree_.GetBounds(); | 494 gfx::Rect bounds = rtree_.GetBounds(); |
513 SkCanvas* canvas = recorder.beginRecording(bounds.width(), bounds.height()); | 495 SkCanvas* canvas = recorder.beginRecording(bounds.width(), bounds.height()); |
514 canvas->translate(-bounds.x(), -bounds.y()); | 496 canvas->translate(-bounds.x(), -bounds.y()); |
515 canvas->clipRect(gfx::RectToSkRect(bounds)); | 497 canvas->clipRect(gfx::RectToSkRect(bounds)); |
516 Raster(canvas, nullptr, gfx::Rect(), 1.f); | 498 Raster(canvas); |
517 sk_sp<SkPicture> picture = recorder.finishRecordingAsPicture(); | 499 sk_sp<SkPicture> picture = recorder.finishRecordingAsPicture(); |
518 | 500 |
519 std::string b64_picture; | 501 std::string b64_picture; |
520 PictureDebugUtil::SerializeAsBase64(picture.get(), &b64_picture); | 502 PictureDebugUtil::SerializeAsBase64(picture.get(), &b64_picture); |
521 state->SetString("skp64", b64_picture); | 503 state->SetString("skp64", b64_picture); |
522 } | 504 } |
523 | 505 |
524 return state; | 506 return state; |
525 } | 507 } |
526 | 508 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 std::vector<DrawImage>* images) { | 540 std::vector<DrawImage>* images) { |
559 image_map_.GetDiscardableImagesInRect(rect, contents_scale, | 541 image_map_.GetDiscardableImagesInRect(rect, contents_scale, |
560 target_color_space, images); | 542 target_color_space, images); |
561 } | 543 } |
562 | 544 |
563 gfx::Rect DisplayItemList::GetRectForImage(ImageId image_id) const { | 545 gfx::Rect DisplayItemList::GetRectForImage(ImageId image_id) const { |
564 return image_map_.GetRectForImage(image_id); | 546 return image_map_.GetRectForImage(image_id); |
565 } | 547 } |
566 | 548 |
567 } // namespace cc | 549 } // namespace cc |
OLD | NEW |