c245574ba3
This reverts commit Ib4a154cdd5f5d1dcac921ef50d53b79a2d6a1be8.
Reason for revert: new assert from 100K bot
Original change's description:
> Revert[6] "replace SkXfermode obj with SkBlendMode enum in paints"
>
> - perform version check in CreateProc for XfermodeImageFilter and ArithmeticImageFilter
> This reverts commit 3ed485f424
.
>
> BUG=skia:
>
> GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2992
>
> Change-Id: Ib4a154cdd5f5d1dcac921ef50d53b79a2d6a1be8
> Reviewed-on: https://skia-review.googlesource.com/2992
> Reviewed-by: Mike Reed <reed@google.com>
> Commit-Queue: Mike Reed <reed@google.com>
>
TBR=reed@google.com,reviews@skia.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Change-Id: I848e5a69c5cd67f2c14889f4f0a346652578c4ff
Reviewed-on: https://skia-review.googlesource.com/3023
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Mike Reed <reed@google.com>
75 lines
2.1 KiB
C++
75 lines
2.1 KiB
C++
/*
|
|
* Copyright 2011 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "SampleCode.h"
|
|
#include "SkCanvas.h"
|
|
#include "SkPaint.h"
|
|
#include "SkPath.h"
|
|
#include "SkView.h"
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
class LayerMaskView : public SampleView {
|
|
public:
|
|
LayerMaskView() {
|
|
this->setBGColor(0xFFDDDDDD);
|
|
}
|
|
|
|
protected:
|
|
// overrides from SkEventSink
|
|
virtual bool onQuery(SkEvent* evt) {
|
|
if (SampleCode::TitleQ(*evt)) {
|
|
SampleCode::TitleR(evt, "LayerMask");
|
|
return true;
|
|
}
|
|
return this->INHERITED::onQuery(evt);
|
|
}
|
|
|
|
void drawMask(SkCanvas* canvas, const SkRect& r) {
|
|
SkPaint paint;
|
|
paint.setAntiAlias(true);
|
|
|
|
if (true) {
|
|
SkBitmap mask;
|
|
int w = SkScalarRoundToInt(r.width());
|
|
int h = SkScalarRoundToInt(r.height());
|
|
mask.allocN32Pixels(w, h);
|
|
mask.eraseColor(SK_ColorTRANSPARENT);
|
|
SkCanvas c(mask);
|
|
SkRect bounds = r;
|
|
bounds.offset(-bounds.fLeft, -bounds.fTop);
|
|
c.drawOval(bounds, paint);
|
|
|
|
paint.setXfermodeMode(SkXfermode::kDstIn_Mode);
|
|
canvas->drawBitmap(mask, r.fLeft, r.fTop, &paint);
|
|
} else {
|
|
SkPath p;
|
|
p.addOval(r);
|
|
p.setFillType(SkPath::kInverseWinding_FillType);
|
|
paint.setXfermodeMode(SkXfermode::kDstOut_Mode);
|
|
canvas->drawPath(p, paint);
|
|
}
|
|
}
|
|
|
|
virtual void onDrawContent(SkCanvas* canvas) {
|
|
SkRect r;
|
|
r.set(SkIntToScalar(20), SkIntToScalar(20), SkIntToScalar(120), SkIntToScalar(120));
|
|
canvas->saveLayer(&r, nullptr);
|
|
canvas->drawColor(SK_ColorRED);
|
|
drawMask(canvas, r);
|
|
canvas->restore();
|
|
}
|
|
|
|
private:
|
|
typedef SampleView INHERITED;
|
|
};
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
static SkView* MyFactory() { return new LayerMaskView; }
|
|
static SkViewRegister reg(MyFactory);
|