skia2/tools/fiddle/draw.cpp
Mike Klein c0bd9f9fe5 rewrite includes to not need so much -Ifoo
Current strategy: everything from the top

Things to look at first are the manual changes:

   - added tools/rewrite_includes.py
   - removed -Idirectives from BUILD.gn
   - various compile.sh simplifications
   - tweak tools/embed_resources.py
   - update gn/find_headers.py to write paths from the top
   - update gn/gn_to_bp.py SkUserConfig.h layout
     so that #include "include/config/SkUserConfig.h" always
     gets the header we want.

No-Presubmit: true
Change-Id: I73a4b181654e0e38d229bc456c0d0854bae3363e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/209706
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Hal Canary <halcanary@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2019-04-24 16:27:11 +00:00

53 lines
2.6 KiB
C++

/*
* 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 "tools/fiddle/fiddle_main.h"
DrawOptions GetDrawOptions() {
// path *should* be absolute.
static const char path[] = "resources/images/color_wheel.png";
return DrawOptions(256, 256, true, true, true, true, true, false, false, path,
GrMipMapped::kYes, 64, 64, 0, GrMipMapped::kYes);
}
void draw(SkCanvas* canvas) {
canvas->clear(SK_ColorWHITE);
SkMatrix matrix;
matrix.setScale(0.75f, 0.75f);
matrix.preRotate(frame * 30.0f * duration); // If an animation, rotate at 30 deg/s.
SkPaint paint;
paint.setShader(image->makeShader(SkTileMode::kRepeat, SkTileMode::kRepeat, &matrix));
canvas->drawPaint(paint);
SkDebugf("This is text output: %d", 2);
GrContext* context = canvas->getGrContext();
if (context) {
sk_sp<SkImage> tmp = SkImage::MakeFromTexture(context,
backEndTexture,
kTopLeft_GrSurfaceOrigin,
kRGBA_8888_SkColorType,
kOpaque_SkAlphaType,
nullptr);
// TODO: this sampleCnt parameter here should match that set in the options!
sk_sp<SkSurface> tmp2 = SkSurface::MakeFromBackendTexture(context,
backEndTextureRenderTarget,
kTopLeft_GrSurfaceOrigin,
0, kRGBA_8888_SkColorType,
nullptr, nullptr);
// Note: this surface should only be renderable (i.e., not textureable)
sk_sp<SkSurface> tmp3 = SkSurface::MakeFromBackendRenderTarget(context,
backEndRenderTarget,
kTopLeft_GrSurfaceOrigin,
kRGBA_8888_SkColorType,
nullptr, nullptr);
}
}