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 "skia/ext/pixel_ref_utils.h" | 5 #include "skia/ext/pixel_ref_utils.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "third_party/skia/include/core/SkBitmapDevice.h" | 9 #include "third_party/skia/include/core/SkBitmapDevice.h" |
10 #include "third_party/skia/include/core/SkCanvas.h" | 10 #include "third_party/skia/include/core/SkCanvas.h" |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 }; | 344 }; |
345 | 345 |
346 } // namespace | 346 } // namespace |
347 | 347 |
348 void PixelRefUtils::GatherDiscardablePixelRefs( | 348 void PixelRefUtils::GatherDiscardablePixelRefs( |
349 SkPicture* picture, | 349 SkPicture* picture, |
350 std::vector<PositionPixelRef>* pixel_refs) { | 350 std::vector<PositionPixelRef>* pixel_refs) { |
351 pixel_refs->clear(); | 351 pixel_refs->clear(); |
352 DiscardablePixelRefSet pixel_ref_set(pixel_refs); | 352 DiscardablePixelRefSet pixel_ref_set(pixel_refs); |
353 | 353 |
| 354 SkRect picture_bounds = picture->cullRect(); |
| 355 SkIRect picture_ibounds = picture_bounds.roundOut(); |
354 SkBitmap empty_bitmap; | 356 SkBitmap empty_bitmap; |
355 empty_bitmap.setInfo(SkImageInfo::MakeUnknown(picture->width(), picture->heigh
t())); | 357 empty_bitmap.setInfo(SkImageInfo::MakeUnknown(picture_ibounds.width(), |
| 358 picture_ibounds.height())); |
356 | 359 |
357 GatherPixelRefDevice device(empty_bitmap, &pixel_ref_set); | 360 GatherPixelRefDevice device(empty_bitmap, &pixel_ref_set); |
358 SkNoSaveLayerCanvas canvas(&device); | 361 SkNoSaveLayerCanvas canvas(&device); |
359 | 362 |
360 canvas.clipRect(SkRect::MakeWH(picture->width(), picture->height()), | 363 // Draw the picture pinned against our top/left corner. |
361 SkRegion::kIntersect_Op, | 364 canvas.translate(-picture_bounds.left(), -picture_bounds.top()); |
362 false); | |
363 canvas.drawPicture(picture); | 365 canvas.drawPicture(picture); |
364 } | 366 } |
365 | 367 |
366 } // namespace skia | 368 } // namespace skia |
OLD | NEW |