diff options
author | reed <reed@google.com> | 2014-09-10 10:20:24 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-10 10:20:24 -0700 |
commit | cc0e3110bde60201882a2c512a5cdd73c838f351 (patch) | |
tree | 88b3a026fb8d6a38da6b63c853e2ae8a4f4db0df /gm/emboss.cpp | |
parent | d0af38793e4c4598eac7b4fd2e1db39692dcbfb1 (diff) |
make set3DMask virtual, so we can safely notify the shadercontext
also boost preallocated storage to account for this combo of bitmapshader + emboss + colorfilter
BUG=skia:
R=djsollen@google.com
Author: reed@google.com
Review URL: https://codereview.chromium.org/563563002
Diffstat (limited to 'gm/emboss.cpp')
-rw-r--r-- | gm/emboss.cpp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/gm/emboss.cpp b/gm/emboss.cpp new file mode 100644 index 0000000000..c2ee49723f --- /dev/null +++ b/gm/emboss.cpp @@ -0,0 +1,61 @@ +/* + * 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: + virtual SkString onShortName() SK_OVERRIDE { + return SkString("emboss"); + } + + virtual SkISize onISize() SK_OVERRIDE { + return SkISize::Make(600, 120); + } + + virtual 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); ) |