1 /*
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 "tools/fiddle/fiddle_main.h"
GetDrawOptions()13 DrawOptions GetDrawOptions() {
14 // path *should* be absolute.
15 static const char path[] = "resources/images/color_wheel.png";
16 return DrawOptions(256, 256, true, true, true, true, true, false, false, path,
17 GrMipMapped::kYes, 64, 64, 0, GrMipMapped::kYes);
18 }
draw(SkCanvas * canvas)19 void draw(SkCanvas* canvas) {
20 canvas->clear(SK_ColorWHITE);
21 SkMatrix matrix;
22 matrix.setScale(0.75f, 0.75f);
23 matrix.preRotate(frame * 30.0f * duration); // If an animation, rotate at 30 deg/s.
24 SkPaint paint;
25 paint.setShader(image->makeShader(SkTileMode::kRepeat, SkTileMode::kRepeat, &matrix));
26 canvas->drawPaint(paint);
27 SkDebugf("This is text output: %d", 2);
28
29 GrContext* context = canvas->getGrContext();
30 if (context) {
31 sk_sp<SkImage> tmp = SkImage::MakeFromTexture(context,
32 backEndTexture,
33 kTopLeft_GrSurfaceOrigin,
34 kRGBA_8888_SkColorType,
35 kOpaque_SkAlphaType,
36 nullptr);
37
38 // TODO: this sampleCnt parameter here should match that set in the options!
39 sk_sp<SkSurface> tmp2 = SkSurface::MakeFromBackendTexture(context,
40 backEndTextureRenderTarget,
41 kTopLeft_GrSurfaceOrigin,
42 0, kRGBA_8888_SkColorType,
43 nullptr, nullptr);
44
45 // Note: this surface should only be renderable (i.e., not textureable)
46 sk_sp<SkSurface> tmp3 = SkSurface::MakeFromBackendRenderTarget(context,
47 backEndRenderTarget,
48 kTopLeft_GrSurfaceOrigin,
49 kRGBA_8888_SkColorType,
50 nullptr, nullptr);
51 }
52 }
53