1 /*
2  * Copyright 2016 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  */
7 
8 #include "include/core/SkAlphaType.h"
9 #include "include/core/SkCanvas.h"
10 #include "include/core/SkColorType.h"
11 #include "include/core/SkFont.h"
12 #include "include/core/SkImageInfo.h"
13 #include "include/core/SkPaint.h"
14 #include "include/core/SkRefCnt.h"
15 #include "include/core/SkSurface.h"
16 #include "include/core/SkTypes.h"
17 #include "include/gpu/GpuTypes.h"
18 #include "include/gpu/GrDirectContext.h"
19 #include "tests/CtsEnforcement.h"
20 #include "tests/Test.h"
21 
22 struct GrContextOptions;
23 
24 // This passes by not crashing.
test(SkCanvas * canvas)25 static void test(SkCanvas* canvas) {
26     canvas->scale(63, 0);
27     canvas->drawString("A", 50, 50, SkFont(), SkPaint());
28 }
29 
DEF_TEST(skbug5221,r)30 DEF_TEST(skbug5221, r) {
31     sk_sp<SkSurface> surface(SkSurface::MakeRaster(SkImageInfo::MakeN32Premul(256, 256)));
32     test(surface->getCanvas());
33 }
34 
DEF_GANESH_TEST_FOR_ALL_CONTEXTS(skbug5221_GPU,r,contextInfo,CtsEnforcement::kNever)35 DEF_GANESH_TEST_FOR_ALL_CONTEXTS(skbug5221_GPU, r, contextInfo, CtsEnforcement::kNever) {
36     sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(
37             contextInfo.directContext(),
38             skgpu::Budgeted::kYes,
39             SkImageInfo::Make(256, 256, kRGBA_8888_SkColorType, kPremul_SkAlphaType)));
40     test(surface->getCanvas());
41 }
42