halcanary | 5cd406f | 2015-09-23 12:46:24 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 7 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "gm/gm.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 9 | #include "include/core/SkBitmap.h" |
| 10 | #include "include/core/SkCanvas.h" |
| 11 | #include "include/core/SkMatrix.h" |
| 12 | #include "include/core/SkRect.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 13 | #include "tools/Resources.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 14 | |
halcanary | 6950de6 | 2015-11-07 05:29:00 -0800 | [diff] [blame] | 15 | // https://bug.skia.org/4374 |
halcanary | 5cd406f | 2015-09-23 12:46:24 -0700 | [diff] [blame] | 16 | DEF_SIMPLE_GM(draw_bitmap_rect_skbug4734, canvas, 64, 64) { |
Mike Reed | fa582c8 | 2021-01-23 22:07:05 -0500 | [diff] [blame] | 17 | if (auto img = GetResourceAsImage("images/randPixels.png")) { |
| 18 | SkRect rect = SkRect::Make(img->bounds()); |
halcanary | 5cd406f | 2015-09-23 12:46:24 -0700 | [diff] [blame] | 19 | rect.inset(0.5, 1.5); |
| 20 | SkRect dst; |
Mike Reed | 1f60733 | 2020-05-21 12:11:27 -0400 | [diff] [blame] | 21 | SkMatrix::Scale(8, 8).mapRect(&dst, rect); |
Mike Reed | fa582c8 | 2021-01-23 22:07:05 -0500 | [diff] [blame] | 22 | canvas->drawImageRect(img, rect, dst, SkSamplingOptions(), nullptr, |
| 23 | SkCanvas::kStrict_SrcRectConstraint); |
halcanary | 5cd406f | 2015-09-23 12:46:24 -0700 | [diff] [blame] | 24 | } |
| 25 | } |