skia2/gm/draw_bitmap_rect_skbug4374.cpp
Robert Phillips 0fb10ab912 [graphite] Update GMs to have graphite-backed gpu SkImages (take 2)
This makes part of of our testing infrastructure (i.e., the GMs)
compatible with Graphite's more stringent requirements.

Bug: skia:12701
Change-Id: I5e42d93050eccc1e455f46e07b64654ad3d4548c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/531997
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2022-04-21 14:59:41 +00:00

28 lines
866 B
C++

/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "gm/gm.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkRect.h"
#include "tools/Resources.h"
#include "tools/ToolUtils.h"
// https://bug.skia.org/4374
DEF_SIMPLE_GM(draw_bitmap_rect_skbug4734, canvas, 64, 64) {
auto img = ToolUtils::MakeTextureImage(canvas, GetResourceAsImage("images/randPixels.png"));
if (img) {
SkRect rect = SkRect::Make(img->bounds());
rect.inset(0.5, 1.5);
SkRect dst;
SkMatrix::Scale(8, 8).mapRect(&dst, rect);
canvas->drawImageRect(img, rect, dst, SkSamplingOptions(), nullptr,
SkCanvas::kStrict_SrcRectConstraint);
}
}