1cb93a386Sopenharmony_ci// Copyright 2019 Google LLC. 2cb93a386Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. 3cb93a386Sopenharmony_ci#include "tools/fiddle/examples.h" 4cb93a386Sopenharmony_ci// HASH=5c7629c15e9ac93f098335e72560fa2e 5cb93a386Sopenharmony_ciREG_FIDDLE(Surface_MakeRenderTarget_3, 256, 256, false, 0) { 6cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) { 7cb93a386Sopenharmony_ci SkFont font(nullptr, 32); 8cb93a386Sopenharmony_ci SkPaint paint; 9cb93a386Sopenharmony_ci auto context = canvas->recordingContext(); 10cb93a386Sopenharmony_ci if (!context) { 11cb93a386Sopenharmony_ci canvas->drawString("GPU only!", 20, 40, font, paint); 12cb93a386Sopenharmony_ci return; 13cb93a386Sopenharmony_ci } 14cb93a386Sopenharmony_ci SkImageInfo info = SkImageInfo::MakeN32(256, 64, kOpaque_SkAlphaType); 15cb93a386Sopenharmony_ci auto gpuSurface(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info)); 16cb93a386Sopenharmony_ci auto surfaceCanvas = gpuSurface->getCanvas(); 17cb93a386Sopenharmony_ci surfaceCanvas->clear(SK_ColorWHITE); 18cb93a386Sopenharmony_ci surfaceCanvas->drawString("GPU rocks!", 20, 40, font, paint); 19cb93a386Sopenharmony_ci sk_sp<SkImage> image(gpuSurface->makeImageSnapshot()); 20cb93a386Sopenharmony_ci canvas->drawImage(image, 0, 0); 21cb93a386Sopenharmony_ci} 22cb93a386Sopenharmony_ci} // END FIDDLE 23