• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "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(SkShader::kRepeat_TileMode,
26                                       SkShader::kRepeat_TileMode,
27                                       &matrix));
28     canvas->drawPaint(paint);
29     SkDebugf("This is text output: %d", 2);
30 
31     GrContext* context = canvas->getGrContext();
32     if (context) {
33         sk_sp<SkImage> tmp = SkImage::MakeFromTexture(context,
34                                                       backEndTexture,
35                                                       kTopLeft_GrSurfaceOrigin,
36                                                       kRGBA_8888_SkColorType,
37                                                       kOpaque_SkAlphaType,
38                                                       nullptr);
39 
40         // TODO: this sampleCnt parameter here should match that set in the options!
41         sk_sp<SkSurface> tmp2 = SkSurface::MakeFromBackendTexture(context,
42                                                                   backEndTextureRenderTarget,
43                                                                   kTopLeft_GrSurfaceOrigin,
44                                                                   0, kRGBA_8888_SkColorType,
45                                                                   nullptr, nullptr);
46 
47         // Note: this surface should only be renderable (i.e., not textureable)
48         sk_sp<SkSurface> tmp3 = SkSurface::MakeFromBackendRenderTarget(context,
49                                                                        backEndRenderTarget,
50                                                                        kTopLeft_GrSurfaceOrigin,
51                                                                        kRGBA_8888_SkColorType,
52                                                                        nullptr, nullptr);
53     }
54 }
55