blob: b7718ae91ae1da72ea4893658d840f85dafefff5 [file] [log] [blame]
Hal Canary87515122019-03-15 14:22:51 -04001#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.
Mike Kleinc0bd9f92019-04-23 12:05:21 -05004#include "tools/fiddle/examples.h"
Hal Canary87515122019-03-15 14:22:51 -04005// HASH=640321e8ecfb3f9329f3bc6e1f02485f
Hal Canarya7181e7c2019-03-18 16:06:34 -04006REG_FIDDLE(Surface_MakeRenderTarget_2, 256, 256, false, 0) {
Hal Canary87515122019-03-15 14:22:51 -04007void 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.