skia2/gm/emboss.cpp
Ben Wagner 3ae1a307f6 Revert "Alloc glyph image correctly for SkMask::k3D_Format."
This reverts commit 6b26deb8d6.

Reason for revert: GPU bots failing

Original change's description:
> Alloc glyph image correctly for SkMask::k3D_Format.
> 
> This removes the no longer used outside Skia
> SK_SUPPORT_LEGACY_EMBOSSMASKFILTER define, and either deletes the code
> it guards or updates it to use the new emboss mask filter factory. This
> re-enables the code to test the emboss mask filter. Also added is a test
> to ensure that embossed text is drawn correctly, as before this glyphs
> did not allocate the proper amount of memory for the k3D_Format which
> this mask filter produces. This also fixes SkEmbossMask::Emboss to write
> the whole of the mul and add planes to avoid pixel differences and
> MemorySanitizer errors.
> 
> Change-Id: Ib492c72a19d6a27d140e3cd48179a3ca9ce313f5
> Reviewed-on: https://skia-review.googlesource.com/70260
> Commit-Queue: Ben Wagner <bungeman@google.com>
> Reviewed-by: Herb Derby <herb@google.com>

TBR=djsollen@google.com,bungeman@google.com,herb@google.com,reed@google.com

Change-Id: I8a9db6c00e0cb84bdd4833474a9ffffa6ecc606c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/70920
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
2017-11-13 20:43:06 +00:00

63 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"
#ifdef SK_SUPPORT_LEGACY_EMBOSSMASKFILTER
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() override {
return SkString("emboss");
}
SkISize onISize() override {
return SkISize::Make(600, 120);
}
void onDraw(SkCanvas* canvas) override {
SkPaint paint;
SkBitmap bm = make_bm();
canvas->drawBitmap(bm, 10, 10, &paint);
const SkScalar dir[] = { 1, 1, 1 };
paint.setMaskFilter(SkBlurMaskFilter::MakeEmboss(3, dir, 0.3f, 0.1f));
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::MakeModeFilter(0xFFFF0000, SkBlendMode::kSrcATop));
canvas->translate(bm.width() + SkIntToScalar(10), 0);
canvas->drawBitmap(bm, 10, 10, &paint);
}
private:
typedef skiagm::GM INHERITED;
};
DEF_GM(return new EmbossGM;)
#endif