blob: f9c149e300c456dd17524c564dbbfd1b5060f5e3 [file] [log] [blame]
Hal Canary83c2f702019-03-07 14:53:03 -05001#if 0 // Disabled until updated to use current API.
2// Copyright 2019 Google LLC.
3// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
4#include "fiddle/examples.h"
5// HASH=640321e8ecfb3f9329f3bc6e1f02485f
6REG_FIDDLE(Surface_008, 256, 256, false, 0) {
7void draw(SkCanvas* canvas) {
8 auto test_draw = [](SkCanvas* surfaceCanvas) -> void {
9 SkPaint paint;
10 paint.setAntiAlias(true);
11 paint.setLCDRenderText(true);
12 paint.setColor(0xFFBBBBBB);
13 surfaceCanvas->drawRect(SkRect::MakeWH(128, 64), paint);
14 paint.setColor(SK_ColorWHITE);
15 paint.setTextSize(32);
16 surfaceCanvas->drawString("Pest", 0, 25, paint);
17 };
18 GrContext* context = canvas->getGrContext();
19 SkImageInfo info = SkImageInfo::MakeN32(128, 64, kOpaque_SkAlphaType);
20 int y = 0;
21 for (auto geometry : { kRGB_H_SkPixelGeometry, kBGR_H_SkPixelGeometry,
22 kRGB_V_SkPixelGeometry, kBGR_V_SkPixelGeometry } ) {
23 SkSurfaceProps props(0, geometry);
24 sk_sp<SkSurface> surface = context ? SkSurface::MakeRenderTarget(
25 context, SkBudgeted::kNo, info, 0, &props) : SkSurface::MakeRaster(info, &props);
26 test_draw(surface->getCanvas());
27 surface->draw(canvas, 0, y, nullptr);
28 sk_sp<SkImage> image(surface->makeImageSnapshot());
29 SkAutoCanvasRestore acr(canvas, true);
30 canvas->scale(8, 8);
31 canvas->drawImage(image, 12, y / 8);
32 y += 64;
33 }
34}
35} // END FIDDLE
36#endif // Disabled until updated to use current API.