blob: 31aa9d0a818d045ad8ad0f03289954124bff1952 [file] [log] [blame]
halcanarydecb21e2015-12-10 07:52:45 -08001/*
2 * Copyright 2015 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// This is an example of the translation unit that needs to be
9// assembled by the fiddler program to compile into a fiddle: an
10// implementation of the GetDrawOptions() and draw() functions.
11
12#include "fiddle_main.h"
13DrawOptions GetDrawOptions() {
14 // path *should* be absolute.
mtklein5dbd2742016-08-02 11:13:48 -070015 static const char path[] = "resources/color_wheel.png";
Joe Gregorio1fd18232017-02-13 11:39:43 -050016 return DrawOptions(256, 256, true, true, true, true, true, false, false, path);
halcanarydecb21e2015-12-10 07:52:45 -080017}
18void draw(SkCanvas* canvas) {
19 canvas->clear(SK_ColorWHITE);
20 SkMatrix matrix;
21 matrix.setScale(0.75f, 0.75f);
Joe Gregorio1e735c02017-04-19 14:05:14 -040022 matrix.preRotate(frame * 30.0f * duration); // If an animation, rotate at 30 deg/s.
halcanarydecb21e2015-12-10 07:52:45 -080023 SkPaint paint;
halcanaryd0964592016-03-25 11:29:34 -070024 paint.setShader(image->makeShader(SkShader::kRepeat_TileMode,
25 SkShader::kRepeat_TileMode,
26 &matrix));
halcanarydecb21e2015-12-10 07:52:45 -080027 canvas->drawPaint(paint);
Joe Gregorio1fd18232017-02-13 11:39:43 -050028 SkDebugf("This is text output: %d", 2);
Robert Phillips57e08282017-11-16 14:59:48 -050029
30 GrContext* context = canvas->getGrContext();
31 if (context) {
32 sk_sp<SkImage> tmp = SkImage::MakeFromTexture(context,
33 backEndTexture,
34 kTopLeft_GrSurfaceOrigin,
35 kOpaque_SkAlphaType,
36 nullptr);
37
38 sk_sp<SkSurface> tmp2 = SkSurface::MakeFromBackendTexture(context,
39 backEndTextureRenderTarget,
40 kTopLeft_GrSurfaceOrigin,
41 0, nullptr, nullptr);
42
43 sk_sp<SkSurface> tmp3 = SkSurface::MakeFromBackendRenderTarget(context,
44 backEndRenderTarget,
45 kTopLeft_GrSurfaceOrigin,
46 nullptr, nullptr);
47
48 sk_sp<SkSurface> tmp4 = SkSurface::MakeFromBackendTextureAsRenderTarget(
49 context,
50 backEndTextureRenderTarget,
51 kTopLeft_GrSurfaceOrigin,
52 0, nullptr, nullptr);
53 }
54
halcanarydecb21e2015-12-10 07:52:45 -080055}