skia2/docs/examples/Surface_MakeRenderTarget_2.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

37 lines
1.6 KiB
C++

#if 0 // Disabled until updated to use current API.
// Copyright 2019 Google LLC.
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
#include "tools/fiddle/examples.h"
// HASH=640321e8ecfb3f9329f3bc6e1f02485f
REG_FIDDLE(Surface_MakeRenderTarget_2, 256, 256, false, 0) {
void draw(SkCanvas* canvas) {
auto test_draw = [](SkCanvas* surfaceCanvas) -> void {
SkPaint paint;
paint.setAntiAlias(true);
paint.setLCDRenderText(true);
paint.setColor(0xFFBBBBBB);
surfaceCanvas->drawRect(SkRect::MakeWH(128, 64), paint);
paint.setColor(SK_ColorWHITE);
paint.setTextSize(32);
surfaceCanvas->drawString("Pest", 0, 25, paint);
};
GrContext* context = canvas->getGrContext();
SkImageInfo info = SkImageInfo::MakeN32(128, 64, kOpaque_SkAlphaType);
int y = 0;
for (auto geometry : { kRGB_H_SkPixelGeometry, kBGR_H_SkPixelGeometry,
kRGB_V_SkPixelGeometry, kBGR_V_SkPixelGeometry } ) {
SkSurfaceProps props(0, geometry);
sk_sp<SkSurface> surface = context ? SkSurface::MakeRenderTarget(
context, SkBudgeted::kNo, info, 0, &props) : SkSurface::MakeRaster(info, &props);
test_draw(surface->getCanvas());
surface->draw(canvas, 0, y, nullptr);
sk_sp<SkImage> image(surface->makeImageSnapshot());
SkAutoCanvasRestore acr(canvas, true);
canvas->scale(8, 8);
canvas->drawImage(image, 12, y / 8);
y += 64;
}
}
} // END FIDDLE
#endif // Disabled until updated to use current API.