c0bd9f9fe5
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>
90 lines
2.3 KiB
C++
90 lines
2.3 KiB
C++
/*
|
|
* Copyright 2013 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "gm/gm.h"
|
|
#include "include/core/SkCanvas.h"
|
|
#include "include/core/SkRSXform.h"
|
|
#include "include/core/SkSurface.h"
|
|
#include "include/effects/SkBlurImageFilter.h"
|
|
|
|
static void make_bm(SkBitmap* bm) {
|
|
bm->allocN32Pixels(100, 100);
|
|
bm->eraseColor(SK_ColorBLUE);
|
|
|
|
SkCanvas canvas(*bm);
|
|
SkPaint paint;
|
|
paint.setAntiAlias(true);
|
|
paint.setColor(SK_ColorRED);
|
|
canvas.drawCircle(50, 50, 50, paint);
|
|
}
|
|
|
|
static void draw_1_bitmap(SkCanvas* canvas, const SkBitmap& bm, bool doClip,
|
|
int dx, int dy, sk_sp<SkImageFilter> filter) {
|
|
SkAutoCanvasRestore acr(canvas, true);
|
|
SkPaint paint;
|
|
|
|
SkRect clipR = SkRect::MakeXYWH(SkIntToScalar(dx),
|
|
SkIntToScalar(dy),
|
|
SkIntToScalar(bm.width()),
|
|
SkIntToScalar(bm.height()));
|
|
|
|
paint.setImageFilter(std::move(filter));
|
|
clipR.inset(5, 5);
|
|
|
|
canvas->translate(SkIntToScalar(bm.width() + 20), 0);
|
|
|
|
if (doClip) {
|
|
canvas->save();
|
|
canvas->clipRect(clipR);
|
|
}
|
|
canvas->drawBitmap(bm, SkIntToScalar(dx), SkIntToScalar(dy), &paint);
|
|
if (doClip) {
|
|
canvas->restore();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Compare output of drawSprite and drawBitmap (esp. clipping and imagefilters)
|
|
*/
|
|
class SpriteBitmapGM : public skiagm::GM {
|
|
public:
|
|
SpriteBitmapGM() {}
|
|
|
|
protected:
|
|
|
|
SkString onShortName() override {
|
|
return SkString("spritebitmap");
|
|
}
|
|
|
|
SkISize onISize() override {
|
|
return SkISize::Make(640, 480);
|
|
}
|
|
|
|
void onDraw(SkCanvas* canvas) override {
|
|
SkBitmap bm;
|
|
make_bm(&bm);
|
|
|
|
int dx = 10;
|
|
int dy = 10;
|
|
|
|
SkScalar sigma = 8;
|
|
sk_sp<SkImageFilter> filter(SkBlurImageFilter::Make(sigma, sigma, nullptr));
|
|
|
|
draw_1_bitmap(canvas, bm, false, dx, dy, nullptr);
|
|
dy += bm.height() + 20;
|
|
draw_1_bitmap(canvas, bm, false, dx, dy, filter);
|
|
dy += bm.height() + 20;
|
|
draw_1_bitmap(canvas, bm, true, dx, dy, nullptr);
|
|
dy += bm.height() + 20;
|
|
draw_1_bitmap(canvas, bm, true, dx, dy, filter);
|
|
}
|
|
|
|
private:
|
|
typedef GM INHERITED;
|
|
};
|
|
DEF_GM( return new SpriteBitmapGM; )
|