Update rive-cpp to 2.0 version
[platform/core/uifw/rive-tizen.git] / submodule / skia / docs / examples / Surface_MakeRenderTarget.cpp
1 // Copyright 2019 Google LLC.
2 // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3 #include "tools/fiddle/examples.h"
4 // HASH=67b6609471a3f1ed0f4b1657004cdecb
5 REG_FIDDLE(Surface_MakeRenderTarget, 256, 64, false, 0) {
6 void draw(SkCanvas* canvas) {
7     SkFont font(nullptr, 32);
8     SkPaint paint;
9
10     auto dContext = GrAsDirectContext(canvas->recordingContext());
11     if (!dContext) {
12         return;
13     }
14
15     SkImageInfo info = SkImageInfo::MakeN32(256, 64, kOpaque_SkAlphaType);
16     for (auto surfaceOrigin : { kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin } ) {
17         auto gpuSurface(SkSurface::MakeRenderTarget(dContext, SkBudgeted::kNo, info, 0,
18                                                     surfaceOrigin, nullptr));
19         auto surfaceCanvas = gpuSurface->getCanvas();
20         surfaceCanvas->clear(SK_ColorWHITE);
21         surfaceCanvas->drawString("GPU rocks!", 20, 40, font, paint);
22         sk_sp<SkImage> image(gpuSurface->makeImageSnapshot());
23         canvas->drawImage(image, 0, 0);
24         canvas->translate(0, 128);
25     }
26 }
27 }  // END FIDDLE