2015-12-10 15:52:45 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2015 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// This is an example of the translation unit that needs to be
|
|
|
|
// assembled by the fiddler program to compile into a fiddle: an
|
|
|
|
// implementation of the GetDrawOptions() and draw() functions.
|
|
|
|
|
|
|
|
#include "fiddle_main.h"
|
|
|
|
DrawOptions GetDrawOptions() {
|
|
|
|
// path *should* be absolute.
|
2017-12-11 15:26:18 +00:00
|
|
|
static const char path[] = "resources/images/color_wheel.png";
|
2017-11-17 19:59:43 +00:00
|
|
|
return DrawOptions(256, 256, true, true, true, true, true, false, false, path,
|
|
|
|
GrMipMapped::kYes, 64, 64, 0, GrMipMapped::kYes);
|
2015-12-10 15:52:45 +00:00
|
|
|
}
|
|
|
|
void draw(SkCanvas* canvas) {
|
|
|
|
canvas->clear(SK_ColorWHITE);
|
|
|
|
SkMatrix matrix;
|
|
|
|
matrix.setScale(0.75f, 0.75f);
|
2017-04-19 18:05:14 +00:00
|
|
|
matrix.preRotate(frame * 30.0f * duration); // If an animation, rotate at 30 deg/s.
|
2015-12-10 15:52:45 +00:00
|
|
|
SkPaint paint;
|
2016-03-25 18:29:34 +00:00
|
|
|
paint.setShader(image->makeShader(SkShader::kRepeat_TileMode,
|
|
|
|
SkShader::kRepeat_TileMode,
|
|
|
|
&matrix));
|
2015-12-10 15:52:45 +00:00
|
|
|
canvas->drawPaint(paint);
|
2017-02-13 16:39:43 +00:00
|
|
|
SkDebugf("This is text output: %d", 2);
|
2017-11-16 19:59:48 +00:00
|
|
|
|
|
|
|
GrContext* context = canvas->getGrContext();
|
|
|
|
if (context) {
|
|
|
|
sk_sp<SkImage> tmp = SkImage::MakeFromTexture(context,
|
|
|
|
backEndTexture,
|
|
|
|
kTopLeft_GrSurfaceOrigin,
|
2017-12-19 18:15:02 +00:00
|
|
|
kRGBA_8888_SkColorType,
|
2017-11-16 19:59:48 +00:00
|
|
|
kOpaque_SkAlphaType,
|
|
|
|
nullptr);
|
|
|
|
|
2017-11-17 19:59:43 +00:00
|
|
|
// TODO: this sampleCnt parameter here should match that set in the options!
|
2017-11-16 19:59:48 +00:00
|
|
|
sk_sp<SkSurface> tmp2 = SkSurface::MakeFromBackendTexture(context,
|
|
|
|
backEndTextureRenderTarget,
|
|
|
|
kTopLeft_GrSurfaceOrigin,
|
2017-12-19 18:15:02 +00:00
|
|
|
0, kRGBA_8888_SkColorType,
|
|
|
|
nullptr, nullptr);
|
2017-11-16 19:59:48 +00:00
|
|
|
|
2017-11-17 19:59:43 +00:00
|
|
|
// Note: this surface should only be renderable (i.e., not textureable)
|
2017-11-16 19:59:48 +00:00
|
|
|
sk_sp<SkSurface> tmp3 = SkSurface::MakeFromBackendRenderTarget(context,
|
|
|
|
backEndRenderTarget,
|
|
|
|
kTopLeft_GrSurfaceOrigin,
|
2017-12-19 18:15:02 +00:00
|
|
|
kRGBA_8888_SkColorType,
|
2017-11-16 19:59:48 +00:00
|
|
|
nullptr, nullptr);
|
|
|
|
}
|
2015-12-10 15:52:45 +00:00
|
|
|
}
|