blob: 05866e316b3f94d5b764c06e301e1d5e6b824313 [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.
Hal Canary036fe5f2017-12-11 10:26:18 -050015 static const char path[] = "resources/images/color_wheel.png";
Robert Phillipsc34aa9d2017-11-17 14:59:43 -050016 return DrawOptions(256, 256, true, true, true, true, true, false, false, path,
17 GrMipMapped::kYes, 64, 64, 0, GrMipMapped::kYes);
halcanarydecb21e2015-12-10 07:52:45 -080018}
19void draw(SkCanvas* canvas) {
20 canvas->clear(SK_ColorWHITE);
21 SkMatrix matrix;
22 matrix.setScale(0.75f, 0.75f);
Joe Gregorio1e735c02017-04-19 14:05:14 -040023 matrix.preRotate(frame * 30.0f * duration); // If an animation, rotate at 30 deg/s.
halcanarydecb21e2015-12-10 07:52:45 -080024 SkPaint paint;
halcanaryd0964592016-03-25 11:29:34 -070025 paint.setShader(image->makeShader(SkShader::kRepeat_TileMode,
26 SkShader::kRepeat_TileMode,
27 &matrix));
halcanarydecb21e2015-12-10 07:52:45 -080028 canvas->drawPaint(paint);
Joe Gregorio1fd18232017-02-13 11:39:43 -050029 SkDebugf("This is text output: %d", 2);
Robert Phillips57e08282017-11-16 14:59:48 -050030
31 GrContext* context = canvas->getGrContext();
32 if (context) {
33 sk_sp<SkImage> tmp = SkImage::MakeFromTexture(context,
34 backEndTexture,
35 kTopLeft_GrSurfaceOrigin,
36 kOpaque_SkAlphaType,
37 nullptr);
38
Robert Phillipsc34aa9d2017-11-17 14:59:43 -050039 // TODO: this sampleCnt parameter here should match that set in the options!
Robert Phillips57e08282017-11-16 14:59:48 -050040 sk_sp<SkSurface> tmp2 = SkSurface::MakeFromBackendTexture(context,
41 backEndTextureRenderTarget,
42 kTopLeft_GrSurfaceOrigin,
43 0, nullptr, nullptr);
44
Robert Phillipsc34aa9d2017-11-17 14:59:43 -050045 // Note: this surface should only be renderable (i.e., not textureable)
Robert Phillips57e08282017-11-16 14:59:48 -050046 sk_sp<SkSurface> tmp3 = SkSurface::MakeFromBackendRenderTarget(context,
47 backEndRenderTarget,
48 kTopLeft_GrSurfaceOrigin,
49 nullptr, nullptr);
Robert Phillips57e08282017-11-16 14:59:48 -050050 }
51
halcanarydecb21e2015-12-10 07:52:45 -080052}