skia2/gm/emboss.cpp
mtklein 72c9faab45 Fix up all the easy virtual ... SK_OVERRIDE cases.
This fixes every case where virtual and SK_OVERRIDE were on the same line,
which should be the bulk of cases.  We'll have to manually clean up the rest
over time unless I level up in regexes.

for f in (find . -type f); perl -p -i -e 's/virtual (.*)SK_OVERRIDE/\1SK_OVERRIDE/g' $f; end

BUG=skia:

Review URL: https://codereview.chromium.org/806653007
2015-01-09 10:06:40 -08:00

62 lines
1.5 KiB
C++

/*
* Copyright 2014 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "gm.h"
#include "SkBlurMaskFilter.h"
#include "SkCanvas.h"
#include "SkColorFilter.h"
#include "SkColorFilter.h"
static SkBitmap make_bm() {
SkBitmap bm;
bm.allocN32Pixels(100, 100);
SkCanvas canvas(bm);
canvas.clear(0);
SkPaint paint;
paint.setAntiAlias(true);
canvas.drawCircle(50, 50, 50, paint);
return bm;
}
class EmbossGM : public skiagm::GM {
public:
EmbossGM() {
}
protected:
SkString onShortName() SK_OVERRIDE {
return SkString("emboss");
}
SkISize onISize() SK_OVERRIDE {
return SkISize::Make(600, 120);
}
void onDraw(SkCanvas* canvas) SK_OVERRIDE {
SkPaint paint;
SkBitmap bm = make_bm();
canvas->drawBitmap(bm, 10, 10, &paint);
const SkScalar dir[] = { 1, 1, 1 };
paint.setMaskFilter(SkBlurMaskFilter::CreateEmboss(3, dir, 0.3f, 0.1f))->unref();
canvas->translate(bm.width() + SkIntToScalar(10), 0);
canvas->drawBitmap(bm, 10, 10, &paint);
// this combination of emboss+colorfilter used to crash -- so we exercise it to
// confirm that we have a fix.
paint.setColorFilter(SkColorFilter::CreateModeFilter(0xFFFF0000, SkXfermode::kSrcATop_Mode))->unref();
canvas->translate(bm.width() + SkIntToScalar(10), 0);
canvas->drawBitmap(bm, 10, 10, &paint);
}
private:
typedef skiagm::GM INHERITED;
};
DEF_GM( return SkNEW(EmbossGM); )