remove code now that loopers are dead (w.r.t. canvas and paint)
We can't remove the loopers themselves, as they are still used by android and chrome (they just don't ever pass them to skia). Eventually each of those clients will resolve this, but for now we just keep the classes (and tests) in skia. Bug: skia:4783 Change-Id: I5f507e6bb82280f2bc7c0b21eebe59c287aa9265 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/230579 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
parent
105c9d5070
commit
9dc0b9e2f8
@ -7,3 +7,6 @@ This file includes a list of high level updates for each milestone release.
|
||||
Milestone 78
|
||||
|
||||
* Added RELEASE_NOTES.txt file
|
||||
|
||||
SkDrawLooper is no longer supported in SkPaint or SkCanvas.
|
||||
|
||||
|
@ -1,91 +0,0 @@
|
||||
/*
|
||||
* 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 "bench/Benchmark.h"
|
||||
#include "include/core/SkCanvas.h"
|
||||
#include "include/core/SkColorFilter.h"
|
||||
#include "include/core/SkMaskFilter.h"
|
||||
#include "include/core/SkPaint.h"
|
||||
#include "include/core/SkPath.h"
|
||||
#include "include/core/SkPoint.h"
|
||||
#include "include/core/SkRRect.h"
|
||||
#include "include/core/SkRect.h"
|
||||
#include "include/core/SkString.h"
|
||||
#include "include/effects/SkLayerDrawLooper.h"
|
||||
#include "src/core/SkBlurMask.h"
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
|
||||
// Large blurred RR appear frequently on web pages. This benchmark measures our
|
||||
// performance in this case.
|
||||
class BlurRoundRectBench : public Benchmark {
|
||||
public:
|
||||
BlurRoundRectBench(int width, int height, int cornerRadius)
|
||||
: fName("blurroundrect") {
|
||||
fName.appendf("_WH_%ix%i_cr_%i", width, height, cornerRadius);
|
||||
SkRect r = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
|
||||
fRRect.setRectXY(r, SkIntToScalar(cornerRadius), SkIntToScalar(cornerRadius));
|
||||
}
|
||||
|
||||
const char* onGetName() override {
|
||||
return fName.c_str();
|
||||
}
|
||||
|
||||
SkIPoint onGetSize() override {
|
||||
return SkIPoint::Make(SkScalarCeilToInt(fRRect.rect().width()),
|
||||
SkScalarCeilToInt(fRRect.rect().height()));
|
||||
}
|
||||
|
||||
void onDraw(int loops, SkCanvas* canvas) override {
|
||||
SkLayerDrawLooper::Builder looperBuilder;
|
||||
{
|
||||
SkLayerDrawLooper::LayerInfo info;
|
||||
info.fPaintBits = SkLayerDrawLooper::kMaskFilter_Bit
|
||||
| SkLayerDrawLooper::kColorFilter_Bit;
|
||||
info.fColorMode = SkBlendMode::kSrc;
|
||||
info.fOffset = SkPoint::Make(SkIntToScalar(-1), SkIntToScalar(0));
|
||||
info.fPostTranslate = false;
|
||||
SkPaint* paint = looperBuilder.addLayerOnTop(info);
|
||||
paint->setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle,
|
||||
SkBlurMask::ConvertRadiusToSigma(0.5)));
|
||||
paint->setColorFilter(SkColorFilters::Blend(SK_ColorLTGRAY, SkBlendMode::kSrcIn));
|
||||
paint->setColor(SK_ColorGRAY);
|
||||
}
|
||||
{
|
||||
SkLayerDrawLooper::LayerInfo info;
|
||||
looperBuilder.addLayerOnTop(info);
|
||||
}
|
||||
SkPaint dullPaint;
|
||||
dullPaint.setAntiAlias(true);
|
||||
|
||||
SkPaint loopedPaint;
|
||||
loopedPaint.setLooper(looperBuilder.detach());
|
||||
loopedPaint.setAntiAlias(true);
|
||||
loopedPaint.setColor(SK_ColorCYAN);
|
||||
|
||||
for (int i = 0; i < loops; i++) {
|
||||
canvas->drawRect(fRRect.rect(), dullPaint);
|
||||
canvas->drawRRect(fRRect, loopedPaint);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
SkString fName;
|
||||
SkRRect fRRect;
|
||||
|
||||
typedef Benchmark INHERITED;
|
||||
};
|
||||
|
||||
// Create one with dimensions/rounded corners based on the skp
|
||||
DEF_BENCH(return new BlurRoundRectBench(600, 5514, 6);)
|
||||
// Same radii, much smaller rectangle
|
||||
DEF_BENCH(return new BlurRoundRectBench(100, 100, 6);)
|
||||
// Other radii options
|
||||
DEF_BENCH(return new BlurRoundRectBench(100, 100, 30);)
|
||||
DEF_BENCH(return new BlurRoundRectBench(100, 100, 90);)
|
||||
|
||||
#endif
|
@ -1,106 +0,0 @@
|
||||
/*
|
||||
* 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 "bench/Benchmark.h"
|
||||
#include "include/core/SkCanvas.h"
|
||||
#include "include/core/SkMaskFilter.h"
|
||||
#include "include/core/SkPaint.h"
|
||||
#include "include/core/SkPath.h"
|
||||
#include "include/effects/SkLayerDrawLooper.h"
|
||||
#include "include/utils/SkRandom.h"
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
|
||||
// This bench replicates a problematic use case of a draw looper used
|
||||
// to create an inner blurred rect
|
||||
class RectoriBench : public Benchmark {
|
||||
public:
|
||||
RectoriBench() {}
|
||||
|
||||
protected:
|
||||
|
||||
const char* onGetName() override {
|
||||
return "rectori";
|
||||
}
|
||||
|
||||
void onDraw(int loops, SkCanvas* canvas) override {
|
||||
SkRandom Random;
|
||||
|
||||
for (int i = 0; i < loops; i++) {
|
||||
SkScalar blurSigma = Random.nextRangeScalar(1.5f, 25.0f);
|
||||
SkScalar size = Random.nextRangeScalar(20*blurSigma, 50*blurSigma);
|
||||
|
||||
SkScalar x = Random.nextRangeScalar(0.0f, W - size);
|
||||
SkScalar y = Random.nextRangeScalar(0.0f, H - size);
|
||||
|
||||
SkRect inner = { x, y, x + size, y + size };
|
||||
|
||||
SkRect outer(inner);
|
||||
// outer is always outset either 2x or 4x the blur radius (we go with 2x)
|
||||
outer.outset(2*blurSigma, 2*blurSigma);
|
||||
|
||||
SkPath p;
|
||||
|
||||
p.addRect(outer);
|
||||
p.addRect(inner);
|
||||
p.setFillType(SkPath::kEvenOdd_FillType);
|
||||
|
||||
// This will be used to translate the normal draw outside the
|
||||
// clip rect and translate the blurred version back inside
|
||||
SkScalar translate = 2.0f * size;
|
||||
|
||||
SkPaint paint;
|
||||
paint.setLooper(this->createLooper(-translate, blurSigma));
|
||||
paint.setColor(0xff000000 | Random.nextU());
|
||||
paint.setAntiAlias(true);
|
||||
|
||||
canvas->save();
|
||||
// clip always equals inner rect so we get the inside blur
|
||||
canvas->clipRect(inner);
|
||||
canvas->translate(translate, 0);
|
||||
canvas->drawPath(p, paint);
|
||||
canvas->restore();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
enum {
|
||||
W = 640,
|
||||
H = 480,
|
||||
};
|
||||
|
||||
sk_sp<SkDrawLooper> createLooper(SkScalar xOff, SkScalar sigma) {
|
||||
SkLayerDrawLooper::Builder looperBuilder;
|
||||
|
||||
//-----------------------------------------------
|
||||
SkLayerDrawLooper::LayerInfo info;
|
||||
|
||||
// TODO: add a color filter to better match what is seen in the wild
|
||||
info.fPaintBits = /* SkLayerDrawLooper::kColorFilter_Bit |*/
|
||||
SkLayerDrawLooper::kMaskFilter_Bit;
|
||||
info.fColorMode = SkBlendMode::kDst;
|
||||
info.fOffset.set(xOff, 0);
|
||||
info.fPostTranslate = false;
|
||||
|
||||
SkPaint* paint = looperBuilder.addLayer(info);
|
||||
|
||||
paint->setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, sigma));
|
||||
|
||||
//-----------------------------------------------
|
||||
info.fPaintBits = 0;
|
||||
info.fOffset.set(0, 0);
|
||||
|
||||
paint = looperBuilder.addLayer(info);
|
||||
return looperBuilder.detach();
|
||||
}
|
||||
|
||||
typedef Benchmark INHERITED;
|
||||
};
|
||||
|
||||
DEF_BENCH(return new RectoriBench();)
|
||||
|
||||
#endif
|
@ -11,7 +11,6 @@
|
||||
#include "include/core/SkCanvas.h"
|
||||
#include "include/core/SkColor.h"
|
||||
#include "include/core/SkColorFilter.h"
|
||||
#include "include/core/SkDrawLooper.h"
|
||||
#include "include/core/SkMaskFilter.h"
|
||||
#include "include/core/SkMatrix.h"
|
||||
#include "include/core/SkPaint.h"
|
||||
@ -26,70 +25,8 @@
|
||||
#include "include/core/SkTileMode.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/effects/SkGradientShader.h"
|
||||
#include "include/effects/SkLayerDrawLooper.h"
|
||||
#include "src/core/SkBlurMask.h"
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
// This GM mimics a blurred RR seen in the wild.
|
||||
class BlurRoundRectGM : public skiagm::GM {
|
||||
public:
|
||||
BlurRoundRectGM(int w, int h) : fWidth(w), fHeight(h) {}
|
||||
|
||||
private:
|
||||
SkString onShortName() override {
|
||||
return SkStringPrintf("blurroundrect-WH-%ix%i-unevenCorners", fWidth, fHeight);
|
||||
}
|
||||
|
||||
SkISize onISize() override { return {fWidth, fHeight}; }
|
||||
|
||||
void onOnceBeforeDraw() override {
|
||||
SkVector radii[4];
|
||||
radii[0].set(SkIntToScalar(30), SkIntToScalar(30));
|
||||
radii[1].set(SkIntToScalar(10), SkIntToScalar(10));
|
||||
radii[2].set(SkIntToScalar(30), SkIntToScalar(30));
|
||||
radii[3].set(SkIntToScalar(10), SkIntToScalar(10));
|
||||
SkRect r = SkRect::MakeWH(SkIntToScalar(fWidth), SkIntToScalar(fHeight));
|
||||
fRRect.setRectRadii(r, radii);
|
||||
}
|
||||
|
||||
void onDraw(SkCanvas* canvas) override {
|
||||
SkLayerDrawLooper::Builder looperBuilder;
|
||||
{
|
||||
SkLayerDrawLooper::LayerInfo info;
|
||||
info.fPaintBits = SkLayerDrawLooper::kMaskFilter_Bit
|
||||
| SkLayerDrawLooper::kColorFilter_Bit;
|
||||
info.fColorMode = SkBlendMode::kSrc;
|
||||
info.fOffset = SkPoint::Make(SkIntToScalar(-1), SkIntToScalar(0));
|
||||
info.fPostTranslate = false;
|
||||
SkPaint* paint = looperBuilder.addLayerOnTop(info);
|
||||
paint->setMaskFilter(SkMaskFilter::MakeBlur(
|
||||
kNormal_SkBlurStyle,
|
||||
SkBlurMask::ConvertRadiusToSigma(SK_ScalarHalf)));
|
||||
paint->setColorFilter(SkColorFilters::Blend(SK_ColorLTGRAY, SkBlendMode::kSrcIn));
|
||||
paint->setColor(SK_ColorGRAY);
|
||||
}
|
||||
{
|
||||
SkLayerDrawLooper::LayerInfo info;
|
||||
looperBuilder.addLayerOnTop(info);
|
||||
}
|
||||
SkPaint paint;
|
||||
canvas->drawRect(fRRect.rect(), paint);
|
||||
|
||||
paint.setLooper(looperBuilder.detach());
|
||||
paint.setColor(SK_ColorCYAN);
|
||||
paint.setAntiAlias(true);
|
||||
|
||||
canvas->drawRRect(fRRect, paint);
|
||||
}
|
||||
|
||||
SkRRect fRRect;
|
||||
int fWidth, fHeight;
|
||||
};
|
||||
// Rounded rect with two opposite corners with large radii, the other two
|
||||
// small.
|
||||
DEF_GM(return new BlurRoundRectGM(100, 100);)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Spits out a dummy gradient to test blur with shader on paint
|
||||
*/
|
||||
|
@ -86,17 +86,6 @@ protected:
|
||||
fPaints.push_back(p);
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
{
|
||||
// AA with blur
|
||||
SkPaint p;
|
||||
p.setAntiAlias(true);
|
||||
p.setLooper(SkBlurDrawLooper::Make(SK_ColorBLUE,
|
||||
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(10)),
|
||||
SkIntToScalar(5), SkIntToScalar(10)));
|
||||
fPaints.push_back(p);
|
||||
}
|
||||
#else
|
||||
fLooper = SkBlurDrawLooper::Make(SK_ColorBLUE, SkBlurMask::ConvertRadiusToSigma(10),5,10);
|
||||
{
|
||||
SkPaint p;
|
||||
@ -104,7 +93,6 @@ protected:
|
||||
p.setAntiAlias(true);
|
||||
fPaints.push_back(p);
|
||||
}
|
||||
#endif
|
||||
{
|
||||
// AA with stroke style
|
||||
SkPaint p;
|
||||
|
@ -1,108 +0,0 @@
|
||||
/*
|
||||
* 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 "gm/gm.h"
|
||||
#include "include/core/SkBlendMode.h"
|
||||
#include "include/core/SkBlurTypes.h"
|
||||
#include "include/core/SkCanvas.h"
|
||||
#include "include/core/SkColor.h"
|
||||
#include "include/core/SkDrawLooper.h"
|
||||
#include "include/core/SkFont.h"
|
||||
#include "include/core/SkMaskFilter.h"
|
||||
#include "include/core/SkPaint.h"
|
||||
#include "include/core/SkPoint.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkScalar.h"
|
||||
#include "include/core/SkSize.h"
|
||||
#include "include/core/SkString.h"
|
||||
#include "include/core/SkTypeface.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/effects/SkLayerDrawLooper.h"
|
||||
#include "src/core/SkBlurMask.h"
|
||||
#include "tools/ToolUtils.h"
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
|
||||
#define WIDTH 200
|
||||
#define HEIGHT 200
|
||||
|
||||
class DrawLooperGM : public skiagm::GM {
|
||||
public:
|
||||
DrawLooperGM() : fLooper(nullptr) {
|
||||
this->setBGColor(0xFFDDDDDD);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual SkISize onISize() override {
|
||||
return SkISize::Make(520, 160);
|
||||
}
|
||||
|
||||
SkString onShortName() override {
|
||||
return SkString("drawlooper");
|
||||
}
|
||||
|
||||
void onDraw(SkCanvas* canvas) override {
|
||||
this->init();
|
||||
|
||||
SkPaint paint;
|
||||
paint.setAntiAlias(true);
|
||||
paint.setLooper(fLooper);
|
||||
|
||||
SkFont font(ToolUtils::create_portable_typeface(), 72);
|
||||
|
||||
canvas->drawCircle(50, 50, 30, paint);
|
||||
canvas->drawRect({ 150, 50, 200, 100 }, paint);
|
||||
canvas->drawString("Looper", 230, 100, font, paint);
|
||||
}
|
||||
|
||||
private:
|
||||
sk_sp<SkDrawLooper> fLooper;
|
||||
|
||||
void init() {
|
||||
if (fLooper) return;
|
||||
|
||||
constexpr struct {
|
||||
SkColor fColor;
|
||||
SkPaint::Style fStyle;
|
||||
SkScalar fWidth;
|
||||
SkScalar fOffset;
|
||||
SkScalar fBlur;
|
||||
} gParams[] = {
|
||||
{ SK_ColorWHITE, SkPaint::kStroke_Style, SkIntToScalar(1)*3/4, 0, 0 },
|
||||
{ SK_ColorRED, SkPaint::kStroke_Style, SkIntToScalar(4), 0, 0 },
|
||||
{ SK_ColorBLUE, SkPaint::kFill_Style, 0, 0, 0 },
|
||||
{ 0x88000000, SkPaint::kFill_Style, 0, SkIntToScalar(10), SkIntToScalar(3) }
|
||||
};
|
||||
|
||||
SkLayerDrawLooper::Builder looperBuilder;
|
||||
|
||||
SkLayerDrawLooper::LayerInfo info;
|
||||
info.fPaintBits = SkLayerDrawLooper::kStyle_Bit | SkLayerDrawLooper::kMaskFilter_Bit;
|
||||
info.fColorMode = SkBlendMode::kSrc;
|
||||
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(gParams); i++) {
|
||||
info.fOffset.set(gParams[i].fOffset, gParams[i].fOffset);
|
||||
SkPaint* paint = looperBuilder.addLayer(info);
|
||||
paint->setColor(gParams[i].fColor);
|
||||
paint->setStyle(gParams[i].fStyle);
|
||||
paint->setStrokeWidth(gParams[i].fWidth);
|
||||
if (gParams[i].fBlur > 0) {
|
||||
paint->setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle,
|
||||
SkBlurMask::ConvertRadiusToSigma(gParams[i].fBlur)));
|
||||
}
|
||||
}
|
||||
fLooper = looperBuilder.detach();
|
||||
}
|
||||
|
||||
typedef GM INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
DEF_GM( return new DrawLooperGM; )
|
||||
|
||||
#endif
|
@ -1,261 +0,0 @@
|
||||
/*
|
||||
* 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/SkBlendMode.h"
|
||||
#include "include/core/SkBlurTypes.h"
|
||||
#include "include/core/SkCanvas.h"
|
||||
#include "include/core/SkColor.h"
|
||||
#include "include/core/SkColorFilter.h"
|
||||
#include "include/core/SkDrawLooper.h"
|
||||
#include "include/core/SkMaskFilter.h"
|
||||
#include "include/core/SkPaint.h"
|
||||
#include "include/core/SkPoint.h"
|
||||
#include "include/core/SkRect.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkScalar.h"
|
||||
#include "include/core/SkSize.h"
|
||||
#include "include/core/SkString.h"
|
||||
#include "include/effects/SkLayerDrawLooper.h"
|
||||
#include "src/core/SkBlurMask.h"
|
||||
#include "src/core/SkClipOpPriv.h"
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
|
||||
namespace {
|
||||
|
||||
// This GM tests 3 different ways of drawing four shadows around a square:
|
||||
// just using 4 blurred rects
|
||||
// using 4 1-level draw loopers
|
||||
// using 1 4-level draw looper
|
||||
// They all produce exactly the same pixels
|
||||
class MegaLooperGM : public skiagm::GM {
|
||||
public:
|
||||
// The types define "<# of loopers> x <# of stages per looper>"
|
||||
enum Type {
|
||||
k0x0_Type, // draw without loopers at all
|
||||
k4x1_Type, // a looper for each shadow
|
||||
k1x4_Type, // all four shadows in one looper
|
||||
};
|
||||
|
||||
MegaLooperGM(Type type) : fType(type) {}
|
||||
|
||||
private:
|
||||
SkString onShortName() override {
|
||||
switch (fType) {
|
||||
case k0x0_Type:
|
||||
return SkString("megalooper_0x0");
|
||||
break;
|
||||
case k4x1_Type:
|
||||
return SkString("megalooper_4x1");
|
||||
break;
|
||||
case k1x4_Type: // fall through
|
||||
default:
|
||||
return SkString("megalooper_1x4");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SkISize onISize() override {
|
||||
return {kWidth, kHeight};
|
||||
}
|
||||
|
||||
void onDraw(SkCanvas* canvas) override {
|
||||
for (int y = 100; y < kHeight; y += 200) {
|
||||
for (int x = 100; x < kWidth; x += 200) {
|
||||
switch (fType) {
|
||||
case k0x0_Type:
|
||||
draw0x0(canvas, SkIntToScalar(x), SkIntToScalar(y));
|
||||
break;
|
||||
case k4x1_Type:
|
||||
draw4x1(canvas, SkIntToScalar(x), SkIntToScalar(y));
|
||||
break;
|
||||
case k1x4_Type: // fall through
|
||||
default:
|
||||
draw1x4(canvas, SkIntToScalar(x), SkIntToScalar(y));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static constexpr int kWidth = 800;
|
||||
static constexpr int kHeight = 800;
|
||||
static constexpr int kHalfOuterClipSize = 100;
|
||||
static constexpr int kHalfSquareSize = 50;
|
||||
static constexpr int kOffsetToOutsideClip = kHalfSquareSize + kHalfOuterClipSize + 1;
|
||||
|
||||
static const SkPoint gBlurOffsets[4];
|
||||
static const SkColor gColors[4];
|
||||
Type fType;
|
||||
|
||||
// Just draw a blurred rect at each of the four corners of a square (centered at x,y).
|
||||
// Use two clips to define a rectori where we want pixels to appear.
|
||||
void draw0x0(SkCanvas* canvas, SkScalar x, SkScalar y) {
|
||||
SkRect innerClip = { -kHalfSquareSize, -kHalfSquareSize, kHalfSquareSize, kHalfSquareSize };
|
||||
innerClip.offset(x, y);
|
||||
|
||||
SkRect outerClip = {
|
||||
-kHalfOuterClipSize-kHalfSquareSize, -kHalfOuterClipSize-kHalfSquareSize,
|
||||
kHalfOuterClipSize+kHalfSquareSize, kHalfOuterClipSize+kHalfSquareSize
|
||||
};
|
||||
outerClip.offset(x, y);
|
||||
|
||||
canvas->save();
|
||||
canvas->clipRect(outerClip, kIntersect_SkClipOp);
|
||||
canvas->clipRect(innerClip, kDifference_SkClipOp);
|
||||
|
||||
SkPaint paint;
|
||||
paint.setAntiAlias(true);
|
||||
paint.setMaskFilter(MakeBlur());
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
paint.setColor(gColors[i]);
|
||||
|
||||
SkRect rect = { -kHalfSquareSize, -kHalfSquareSize, kHalfSquareSize, kHalfSquareSize };
|
||||
rect.offset(gBlurOffsets[i]);
|
||||
rect.offset(x, y);
|
||||
canvas->drawRect(rect, paint);
|
||||
}
|
||||
|
||||
canvas->restore();
|
||||
}
|
||||
|
||||
static sk_sp<SkMaskFilter> MakeBlur() {
|
||||
const SkScalar kBlurSigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(25));
|
||||
|
||||
return SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, kBlurSigma);
|
||||
}
|
||||
|
||||
// This draws 4 blurred shadows around a single square (centered at x, y).
|
||||
// Each blur is offset +/- half the square's side in x & y from the original
|
||||
// (so each blurred rect is centered at one of the corners of the original).
|
||||
// For each blur a large outer clip is centered around the blurred rect
|
||||
// while a difference clip stays at the location of the original rect.
|
||||
// Each blurred rect is drawn with a draw looper where the original (non-
|
||||
// blurred rect) is offset to reside outside of the large outer clip (so
|
||||
// it never appears) but the offset in the draw looper is used to translate
|
||||
// the blurred version back into the clip.
|
||||
void draw4x1(SkCanvas* canvas, SkScalar x, SkScalar y) {
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
SkPaint loopPaint;
|
||||
|
||||
loopPaint.setLooper(create1Looper(-kOffsetToOutsideClip, 0, gColors[i]));
|
||||
loopPaint.setAntiAlias(true);
|
||||
|
||||
SkRect outerClip = {
|
||||
-kHalfOuterClipSize, -kHalfOuterClipSize,
|
||||
kHalfOuterClipSize, kHalfOuterClipSize
|
||||
};
|
||||
outerClip.offset(x, y);
|
||||
// center it on the blurred rect
|
||||
outerClip.offset(gBlurOffsets[i]);
|
||||
|
||||
SkRect rect = { -kHalfSquareSize, -kHalfSquareSize, kHalfSquareSize, kHalfSquareSize };
|
||||
rect.offset(x, y);
|
||||
|
||||
canvas->save();
|
||||
canvas->clipRect(outerClip, kIntersect_SkClipOp);
|
||||
canvas->clipRect(rect, kDifference_SkClipOp);
|
||||
|
||||
// move the rect to where we want the blur to appear
|
||||
rect.offset(gBlurOffsets[i]);
|
||||
// then move it outside the clip (the blur stage of the draw
|
||||
// looper will undo this translation)
|
||||
rect.offset(SkIntToScalar(kOffsetToOutsideClip), 0);
|
||||
|
||||
canvas->drawRect(rect, loopPaint);
|
||||
canvas->restore();
|
||||
}
|
||||
}
|
||||
|
||||
// Create a 1-tier drawlooper
|
||||
sk_sp<SkDrawLooper> create1Looper(SkScalar xOff, SkScalar yOff, SkColor color) {
|
||||
SkLayerDrawLooper::Builder looperBuilder;
|
||||
SkLayerDrawLooper::LayerInfo info;
|
||||
|
||||
info.fPaintBits = SkLayerDrawLooper::kColorFilter_Bit |
|
||||
SkLayerDrawLooper::kMaskFilter_Bit;
|
||||
info.fColorMode = SkBlendMode::kSrc;
|
||||
info.fOffset.set(xOff, yOff);
|
||||
info.fPostTranslate = false;
|
||||
|
||||
SkPaint* paint = looperBuilder.addLayer(info);
|
||||
|
||||
paint->setMaskFilter(MakeBlur());
|
||||
|
||||
paint->setColorFilter(SkColorFilters::Blend(color, SkBlendMode::kSrcIn));
|
||||
|
||||
return looperBuilder.detach();
|
||||
}
|
||||
|
||||
void draw1x4(SkCanvas* canvas, SkScalar x, SkScalar y) {
|
||||
SkRect rect = { -kHalfSquareSize, -kHalfSquareSize, kHalfSquareSize, kHalfSquareSize };
|
||||
rect.offset(x, y);
|
||||
|
||||
SkRect outerClip = {
|
||||
-kHalfOuterClipSize-kHalfSquareSize, -kHalfOuterClipSize-kHalfSquareSize,
|
||||
kHalfOuterClipSize+kHalfSquareSize, kHalfOuterClipSize+kHalfSquareSize
|
||||
};
|
||||
outerClip.offset(x, y);
|
||||
|
||||
SkPaint paint;
|
||||
paint.setAntiAlias(true);
|
||||
paint.setLooper(create4Looper(-kOffsetToOutsideClip-kHalfSquareSize, 0));
|
||||
|
||||
canvas->save();
|
||||
canvas->clipRect(outerClip, kIntersect_SkClipOp);
|
||||
canvas->clipRect(rect, kDifference_SkClipOp);
|
||||
|
||||
rect.offset(SkIntToScalar(kOffsetToOutsideClip+kHalfSquareSize), 0);
|
||||
canvas->drawRect(rect, paint);
|
||||
canvas->restore();
|
||||
}
|
||||
|
||||
// Create a 4-tier draw looper
|
||||
sk_sp<SkDrawLooper> create4Looper(SkScalar xOff, SkScalar yOff) {
|
||||
SkLayerDrawLooper::Builder looperBuilder;
|
||||
SkLayerDrawLooper::LayerInfo info;
|
||||
|
||||
info.fPaintBits = SkLayerDrawLooper::kColorFilter_Bit |
|
||||
SkLayerDrawLooper::kMaskFilter_Bit;
|
||||
info.fColorMode = SkBlendMode::kSrc;
|
||||
info.fPostTranslate = false;
|
||||
|
||||
SkPaint* paint;
|
||||
|
||||
for (int i = 3; i >= 0; --i) {
|
||||
info.fOffset.set(xOff+gBlurOffsets[i].fX, yOff+gBlurOffsets[i].fY);
|
||||
paint = looperBuilder.addLayer(info);
|
||||
|
||||
paint->setMaskFilter(MakeBlur());
|
||||
|
||||
paint->setColorFilter(SkColorFilters::Blend(gColors[i], SkBlendMode::kSrcIn));
|
||||
}
|
||||
|
||||
return looperBuilder.detach();
|
||||
}
|
||||
};
|
||||
|
||||
const SkPoint MegaLooperGM::gBlurOffsets[4] = {
|
||||
{ kHalfSquareSize, kHalfSquareSize },
|
||||
{ -kHalfSquareSize, kHalfSquareSize },
|
||||
{ kHalfSquareSize, -kHalfSquareSize },
|
||||
{ -kHalfSquareSize, -kHalfSquareSize }
|
||||
};
|
||||
|
||||
const SkColor MegaLooperGM::gColors[4] = {
|
||||
SK_ColorGREEN, SK_ColorYELLOW, SK_ColorBLUE, SK_ColorRED
|
||||
};
|
||||
} // namespace
|
||||
|
||||
DEF_GM( return new MegaLooperGM(MegaLooperGM::k0x0_Type); )
|
||||
DEF_GM( return new MegaLooperGM(MegaLooperGM::k4x1_Type); )
|
||||
DEF_GM( return new MegaLooperGM(MegaLooperGM::k1x4_Type); )
|
||||
|
||||
#endif
|
13
gm/rects.cpp
13
gm/rects.cpp
@ -101,18 +101,6 @@ protected:
|
||||
fPaints.push_back(p);
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
{
|
||||
// AA with blur
|
||||
SkPaint p;
|
||||
p.setColor(SK_ColorWHITE);
|
||||
p.setAntiAlias(true);
|
||||
p.setLooper(SkBlurDrawLooper::Make(SK_ColorWHITE,
|
||||
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(10)),
|
||||
SkIntToScalar(5), SkIntToScalar(10)));
|
||||
fPaints.push_back(p);
|
||||
}
|
||||
#else
|
||||
fLooper = SkBlurDrawLooper::Make(SK_ColorWHITE, SkBlurMask::ConvertRadiusToSigma(10),5,10);
|
||||
{
|
||||
SkPaint p;
|
||||
@ -120,7 +108,6 @@ protected:
|
||||
p.setAntiAlias(true);
|
||||
fPaints.push_back(p);
|
||||
}
|
||||
#endif
|
||||
{
|
||||
// AA with stroke style
|
||||
SkPaint p;
|
||||
|
144
gm/shadows.cpp
144
gm/shadows.cpp
@ -1,144 +0,0 @@
|
||||
/*
|
||||
* 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 "gm/gm.h"
|
||||
#include "include/core/SkBitmap.h"
|
||||
#include "include/core/SkCanvas.h"
|
||||
#include "include/core/SkColor.h"
|
||||
#include "include/core/SkDrawLooper.h"
|
||||
#include "include/core/SkImageInfo.h"
|
||||
#include "include/core/SkPaint.h"
|
||||
#include "include/core/SkPath.h"
|
||||
#include "include/core/SkRect.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkScalar.h"
|
||||
#include "include/core/SkShader.h"
|
||||
#include "include/core/SkSize.h"
|
||||
#include "include/core/SkString.h"
|
||||
#include "include/core/SkTileMode.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/effects/SkBlurDrawLooper.h"
|
||||
#include "src/core/SkBlurMask.h"
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
|
||||
namespace skiagm {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void setup(SkPaint* paint, SkColor c, SkScalar strokeWidth) {
|
||||
paint->setColor(c);
|
||||
if (strokeWidth < 0) {
|
||||
paint->setStyle(SkPaint::kFill_Style);
|
||||
} else {
|
||||
paint->setStyle(SkPaint::kStroke_Style);
|
||||
paint->setStrokeWidth(strokeWidth);
|
||||
}
|
||||
}
|
||||
|
||||
class ShadowsGM : public GM {
|
||||
public:
|
||||
SkPath fCirclePath;
|
||||
SkRect fRect;
|
||||
SkBitmap fBitmap;
|
||||
|
||||
protected:
|
||||
void onOnceBeforeDraw() override {
|
||||
this->setBGColor(0xFFDDDDDD);
|
||||
fCirclePath.addCircle(SkIntToScalar(20), SkIntToScalar(20), SkIntToScalar(10) );
|
||||
fRect.set(SkIntToScalar(10), SkIntToScalar(10),
|
||||
SkIntToScalar(30), SkIntToScalar(30));
|
||||
fBitmap.allocPixels(SkImageInfo::Make(20, 20, SkColorType::kAlpha_8_SkColorType,
|
||||
kPremul_SkAlphaType));
|
||||
SkCanvas canvas(fBitmap);
|
||||
canvas.clear(0x0);
|
||||
SkPaint p;
|
||||
canvas.drawRect(SkRect::MakeXYWH(10, 0, 10, 10), p);
|
||||
canvas.drawRect(SkRect::MakeXYWH(0, 10, 10, 10), p);
|
||||
}
|
||||
|
||||
SkString onShortName() override {
|
||||
return SkString("shadows");
|
||||
}
|
||||
|
||||
SkISize onISize() override {
|
||||
return SkISize::Make(200, 200);
|
||||
}
|
||||
|
||||
void onDraw(SkCanvas* canvas) override {
|
||||
sk_sp<SkDrawLooper> shadowLoopers[] = {
|
||||
SkBlurDrawLooper::Make(SK_ColorBLUE,
|
||||
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(10)),
|
||||
SkIntToScalar(5), SkIntToScalar(10)),
|
||||
SkBlurDrawLooper::Make(SK_ColorBLUE,
|
||||
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(10)),
|
||||
SkIntToScalar(5), SkIntToScalar(10)),
|
||||
SkBlurDrawLooper::Make(SK_ColorBLACK,
|
||||
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)),
|
||||
SkIntToScalar(5),
|
||||
SkIntToScalar(10)),
|
||||
SkBlurDrawLooper::Make(0x7FFF0000,
|
||||
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)),
|
||||
SkIntToScalar(-5), SkIntToScalar(-10)),
|
||||
SkBlurDrawLooper::Make(SK_ColorBLACK, SkIntToScalar(0),
|
||||
SkIntToScalar(5), SkIntToScalar(5)),
|
||||
};
|
||||
|
||||
constexpr struct {
|
||||
SkColor fColor;
|
||||
SkScalar fStrokeWidth;
|
||||
} gRec[] = {
|
||||
{ SK_ColorRED, -SK_Scalar1 },
|
||||
{ SK_ColorGREEN, SkIntToScalar(4) },
|
||||
{ SK_ColorBLUE, SkIntToScalar(0)},
|
||||
};
|
||||
|
||||
SkPaint paint;
|
||||
paint.setAntiAlias(true);
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(shadowLoopers); ++i) {
|
||||
SkAutoCanvasRestore acr(canvas, true);
|
||||
|
||||
paint.setLooper(shadowLoopers[i]);
|
||||
|
||||
canvas->translate(SkIntToScalar((unsigned int)i*40), SkIntToScalar(0));
|
||||
setup(&paint, gRec[0].fColor, gRec[0].fStrokeWidth);
|
||||
canvas->drawRect(fRect, paint);
|
||||
|
||||
canvas->translate(SkIntToScalar(0), SkIntToScalar(40));
|
||||
setup(&paint, gRec[1].fColor, gRec[1].fStrokeWidth);
|
||||
canvas->drawPath(fCirclePath, paint);
|
||||
|
||||
canvas->translate(SkIntToScalar(0), SkIntToScalar(40));
|
||||
setup(&paint, gRec[2].fColor, gRec[2].fStrokeWidth);
|
||||
canvas->drawPath(fCirclePath, paint);
|
||||
|
||||
// see bug.skia.org/562 (reference, draws correct)
|
||||
canvas->translate(0, 40);
|
||||
paint.setColor(SK_ColorBLACK);
|
||||
canvas->drawBitmap(fBitmap, 10, 10, &paint);
|
||||
|
||||
canvas->translate(0, 40);
|
||||
paint.setShader(fBitmap.makeShader(SkTileMode::kRepeat, SkTileMode::kRepeat));
|
||||
|
||||
// see bug.skia.org/562 (shows bug as reported)
|
||||
paint.setStyle(SkPaint::kFill_Style);
|
||||
canvas->drawRect(SkRect::MakeXYWH(10, 10, 20, 20), paint);
|
||||
paint.setShader(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
typedef GM INHERITED;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
DEF_GM( return new ShadowsGM; )
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -41,8 +41,6 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
|
||||
namespace skiagm {
|
||||
|
||||
constexpr int kWidth = 1250;
|
||||
@ -276,5 +274,3 @@ private:
|
||||
|
||||
DEF_GM(return new TextBlobLooperGM;)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -22,7 +22,6 @@ bench_sources = [
|
||||
"$_bench/BlurImageFilterBench.cpp",
|
||||
"$_bench/BlurRectBench.cpp",
|
||||
"$_bench/BlurRectsBench.cpp",
|
||||
"$_bench/BlurRoundRectBench.cpp",
|
||||
"$_bench/ChartBench.cpp",
|
||||
"$_bench/ChecksumBench.cpp",
|
||||
"$_bench/ChromeBench.cpp",
|
||||
@ -94,7 +93,6 @@ bench_sources = [
|
||||
"$_bench/RecordingBench.cpp",
|
||||
"$_bench/RectanizerBench.cpp",
|
||||
"$_bench/RectBench.cpp",
|
||||
"$_bench/RectoriBench.cpp",
|
||||
"$_bench/RefCntBench.cpp",
|
||||
"$_bench/RegionBench.cpp",
|
||||
"$_bench/RegionContainBench.cpp",
|
||||
|
@ -134,7 +134,6 @@ gm_sources = [
|
||||
"$_gm/drawatlascolor.cpp",
|
||||
"$_gm/drawbitmaprect.cpp",
|
||||
"$_gm/drawimageset.cpp",
|
||||
"$_gm/drawlooper.cpp",
|
||||
"$_gm/drawminibitmaprect.cpp",
|
||||
"$_gm/drawquadset.cpp",
|
||||
"$_gm/drawregion.cpp",
|
||||
@ -237,7 +236,6 @@ gm_sources = [
|
||||
"$_gm/manypaths.cpp",
|
||||
"$_gm/matrixconvolution.cpp",
|
||||
"$_gm/matriximagefilter.cpp",
|
||||
"$_gm/megalooper.cpp",
|
||||
"$_gm/mipmap.cpp",
|
||||
"$_gm/mixedtextblobs.cpp",
|
||||
"$_gm/mixercolorfilter.cpp",
|
||||
@ -307,7 +305,6 @@ gm_sources = [
|
||||
"$_gm/scaledstrokes.cpp",
|
||||
"$_gm/shadermaskfilter.cpp",
|
||||
"$_gm/shadertext3.cpp",
|
||||
"$_gm/shadows.cpp",
|
||||
"$_gm/shadowutils.cpp",
|
||||
"$_gm/shallowgradient.cpp",
|
||||
"$_gm/shapes.cpp",
|
||||
|
@ -86,7 +86,6 @@ samples_sources = [
|
||||
"$_samplecode/SampleTextEffects.cpp",
|
||||
"$_samplecode/SampleTextureDomain.cpp",
|
||||
"$_samplecode/SampleThinAA.cpp",
|
||||
"$_samplecode/SampleTiling.cpp",
|
||||
"$_samplecode/SampleUnpremul.cpp",
|
||||
"$_samplecode/SampleVertices.cpp",
|
||||
"$_samplecode/SampleWritePixels.cpp",
|
||||
|
@ -16,7 +16,6 @@
|
||||
|
||||
class SkColorFilter;
|
||||
class SkColorSpace;
|
||||
class SkDrawLooper;
|
||||
struct SkRect;
|
||||
class SkImageFilter;
|
||||
class SkMaskFilter;
|
||||
@ -57,12 +56,12 @@ public:
|
||||
explicit SkPaint(const SkColor4f& color, SkColorSpace* colorSpace = nullptr);
|
||||
|
||||
/** Makes a shallow copy of SkPaint. SkPathEffect, SkShader,
|
||||
SkMaskFilter, SkColorFilter, SkDrawLooper, and SkImageFilter are shared
|
||||
SkMaskFilter, SkColorFilter, and SkImageFilter are shared
|
||||
between the original paint and the copy. Objects containing SkRefCnt increment
|
||||
their references by one.
|
||||
|
||||
The referenced objects SkPathEffect, SkShader, SkMaskFilter, SkColorFilter,
|
||||
SkDrawLooper, and SkImageFilter cannot be modified after they are created.
|
||||
and SkImageFilter cannot be modified after they are created.
|
||||
This prevents objects with SkRefCnt from being modified once SkPaint refers to them.
|
||||
|
||||
@param paint original to copy
|
||||
@ -81,13 +80,13 @@ public:
|
||||
SkPaint(SkPaint&& paint);
|
||||
|
||||
/** Decreases SkPaint SkRefCnt of owned objects: SkPathEffect, SkShader,
|
||||
SkMaskFilter, SkColorFilter, SkDrawLooper, and SkImageFilter. If the
|
||||
SkMaskFilter, SkColorFilter, and SkImageFilter. If the
|
||||
objects containing SkRefCnt go to zero, they are deleted.
|
||||
*/
|
||||
~SkPaint();
|
||||
|
||||
/** Makes a shallow copy of SkPaint. SkPathEffect, SkShader,
|
||||
SkMaskFilter, SkColorFilter, SkDrawLooper, and SkImageFilter are shared
|
||||
SkMaskFilter, SkColorFilter, and SkImageFilter are shared
|
||||
between the original paint and the copy. Objects containing SkRefCnt in the
|
||||
prior destination are decreased by one, and the referenced objects are deleted if the
|
||||
resulting count is zero. Objects containing SkRefCnt in the parameter paint
|
||||
@ -112,7 +111,7 @@ public:
|
||||
|
||||
/** Compares a and b, and returns true if a and b are equivalent. May return false
|
||||
if SkPathEffect, SkShader, SkMaskFilter, SkColorFilter,
|
||||
SkDrawLooper, or SkImageFilter have identical contents but different pointers.
|
||||
or SkImageFilter have identical contents but different pointers.
|
||||
|
||||
@param a SkPaint to compare
|
||||
@param b SkPaint to compare
|
||||
@ -122,7 +121,7 @@ public:
|
||||
|
||||
/** Compares a and b, and returns true if a and b are not equivalent. May return true
|
||||
if SkPathEffect, SkShader, SkMaskFilter, SkColorFilter,
|
||||
SkDrawLooper, or SkImageFilter have identical contents but different pointers.
|
||||
or SkImageFilter have identical contents but different pointers.
|
||||
|
||||
@param a SkPaint to compare
|
||||
@param b SkPaint to compare
|
||||
@ -556,42 +555,6 @@ public:
|
||||
*/
|
||||
void setImageFilter(sk_sp<SkImageFilter> imageFilter);
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
/** Returns SkDrawLooper if set, or nullptr.
|
||||
Does not alter SkDrawLooper SkRefCnt.
|
||||
|
||||
@return SkDrawLooper if previously set, nullptr otherwise
|
||||
*/
|
||||
SkDrawLooper* getDrawLooper() const { return fDrawLooper.get(); }
|
||||
|
||||
/** Returns SkDrawLooper if set, or nullptr.
|
||||
Increases SkDrawLooper SkRefCnt by one.
|
||||
|
||||
@return SkDrawLooper if previously set, nullptr otherwise
|
||||
*/
|
||||
sk_sp<SkDrawLooper> refDrawLooper() const;
|
||||
|
||||
/** Deprecated.
|
||||
(see skbug.com/6259)
|
||||
*/
|
||||
SkDrawLooper* getLooper() const { return fDrawLooper.get(); }
|
||||
|
||||
/** Sets SkDrawLooper to drawLooper, decreasing SkRefCnt of the previous
|
||||
drawLooper. Pass nullptr to clear SkDrawLooper and leave SkDrawLooper effect on
|
||||
drawing unaltered.
|
||||
|
||||
Increments drawLooper SkRefCnt by one.
|
||||
|
||||
@param drawLooper iterates through drawing one or more time, altering SkPaint
|
||||
*/
|
||||
void setDrawLooper(sk_sp<SkDrawLooper> drawLooper);
|
||||
|
||||
/** Deprecated.
|
||||
(see skbug.com/6259)
|
||||
*/
|
||||
void setLooper(sk_sp<SkDrawLooper> drawLooper);
|
||||
#endif
|
||||
|
||||
/** Returns true if SkPaint prevents all drawing;
|
||||
otherwise, the SkPaint may or may not allow drawing.
|
||||
|
||||
@ -642,9 +605,6 @@ public:
|
||||
// ultra fast-case: filling with no effects that affect geometry
|
||||
if (kFill_Style == style) {
|
||||
uintptr_t effects = 0;
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
effects |= reinterpret_cast<uintptr_t>(this->getLooper());
|
||||
#endif
|
||||
effects |= reinterpret_cast<uintptr_t>(this->getMaskFilter());
|
||||
effects |= reinterpret_cast<uintptr_t>(this->getPathEffect());
|
||||
effects |= reinterpret_cast<uintptr_t>(this->getImageFilter());
|
||||
@ -685,7 +645,6 @@ private:
|
||||
sk_sp<SkShader> fShader;
|
||||
sk_sp<SkMaskFilter> fMaskFilter;
|
||||
sk_sp<SkColorFilter> fColorFilter;
|
||||
sk_sp<SkDrawLooper> fDrawLooper;
|
||||
sk_sp<SkImageFilter> fImageFilter;
|
||||
|
||||
SkColor4f fColor4f;
|
||||
|
@ -1,164 +0,0 @@
|
||||
/*
|
||||
* 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 "include/core/SkBitmap.h"
|
||||
#include "include/core/SkCanvas.h"
|
||||
#include "include/core/SkColorFilter.h"
|
||||
#include "include/core/SkColorPriv.h"
|
||||
#include "include/core/SkPaint.h"
|
||||
#include "include/core/SkPath.h"
|
||||
#include "include/core/SkPicture.h"
|
||||
#include "include/core/SkPictureRecorder.h"
|
||||
#include "include/core/SkRegion.h"
|
||||
#include "include/core/SkShader.h"
|
||||
#include "include/core/SkTypeface.h"
|
||||
#include "include/utils/SkTextUtils.h"
|
||||
#include "samplecode/Sample.h"
|
||||
#include "src/utils/SkUTF.h"
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
|
||||
// effects
|
||||
#include "include/effects/SkBlurDrawLooper.h"
|
||||
#include "include/effects/SkGradientShader.h"
|
||||
#include "src/core/SkBlurMask.h"
|
||||
|
||||
static void makebm(SkBitmap* bm, SkColorType ct, int w, int h) {
|
||||
bm->allocPixels(SkImageInfo::Make(w, h, ct, kPremul_SkAlphaType));
|
||||
bm->eraseColor(SK_ColorTRANSPARENT);
|
||||
|
||||
SkCanvas canvas(*bm);
|
||||
SkPoint pts[] = { { 0, 0 }, { SkIntToScalar(w), SkIntToScalar(h) } };
|
||||
SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE };
|
||||
SkScalar pos[] = { 0, SK_Scalar1/2, SK_Scalar1 };
|
||||
SkPaint paint;
|
||||
|
||||
paint.setDither(true);
|
||||
paint.setShader(SkGradientShader::MakeLinear(pts, colors, pos,
|
||||
SK_ARRAY_COUNT(colors), SkTileMode::kClamp));
|
||||
canvas.drawPaint(paint);
|
||||
}
|
||||
|
||||
static void setup(SkPaint* paint, const SkBitmap& bm, bool filter, SkTileMode tmx, SkTileMode tmy) {
|
||||
paint->setShader(bm.makeShader(tmx, tmy));
|
||||
paint->setFilterQuality(filter ? kLow_SkFilterQuality : kNone_SkFilterQuality);
|
||||
}
|
||||
|
||||
static const SkColorType gColorTypes[] = {
|
||||
kN32_SkColorType,
|
||||
kRGB_565_SkColorType,
|
||||
};
|
||||
static const int gWidth = 32;
|
||||
static const int gHeight = 32;
|
||||
|
||||
class TilingView : public Sample {
|
||||
sk_sp<SkPicture> fTextPicture;
|
||||
sk_sp<SkDrawLooper> fLooper;
|
||||
public:
|
||||
TilingView()
|
||||
: fLooper(SkBlurDrawLooper::Make(0x88000000,
|
||||
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(1)),
|
||||
SkIntToScalar(2), SkIntToScalar(2))) {
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(gColorTypes); i++) {
|
||||
makebm(&fTexture[i], gColorTypes[i], gWidth, gHeight);
|
||||
}
|
||||
}
|
||||
|
||||
virtual ~TilingView() {
|
||||
}
|
||||
|
||||
SkBitmap fTexture[SK_ARRAY_COUNT(gColorTypes)];
|
||||
|
||||
protected:
|
||||
virtual SkString name() { return SkString("Tiling"); }
|
||||
|
||||
virtual void onDrawContent(SkCanvas* canvas) {
|
||||
SkRect r = { 0, 0, SkIntToScalar(gWidth*2), SkIntToScalar(gHeight*2) };
|
||||
|
||||
static const char* gConfigNames[] = { "8888", "565", "4444" };
|
||||
|
||||
static const bool gFilters[] = { false, true };
|
||||
static const char* gFilterNames[] = { "point", "bilinear" };
|
||||
|
||||
static const SkTileMode gModes[] = { SkTileMode::kClamp, SkTileMode::kRepeat, SkTileMode::kMirror };
|
||||
static const char* gModeNames[] = { "C", "R", "M" };
|
||||
|
||||
SkScalar y = SkIntToScalar(24);
|
||||
SkScalar x = SkIntToScalar(10);
|
||||
|
||||
SkPictureRecorder recorder;
|
||||
SkCanvas* textCanvas = nullptr;
|
||||
if (nullptr == fTextPicture) {
|
||||
textCanvas = recorder.beginRecording(1000, 1000, nullptr, 0);
|
||||
}
|
||||
|
||||
if (textCanvas) {
|
||||
for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) {
|
||||
for (size_t ky = 0; ky < SK_ARRAY_COUNT(gModes); ky++) {
|
||||
SkPaint p;
|
||||
SkString str;
|
||||
p.setDither(true);
|
||||
p.setLooper(fLooper);
|
||||
str.printf("[%s,%s]", gModeNames[kx], gModeNames[ky]);
|
||||
|
||||
SkTextUtils::DrawString(textCanvas, str.c_str(), x + r.width()/2, y, SkFont(), p,
|
||||
SkTextUtils::kCenter_Align);
|
||||
|
||||
x += r.width() * 4 / 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
y += SkIntToScalar(16);
|
||||
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(gColorTypes); i++) {
|
||||
for (size_t j = 0; j < SK_ARRAY_COUNT(gFilters); j++) {
|
||||
x = SkIntToScalar(10);
|
||||
for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) {
|
||||
for (size_t ky = 0; ky < SK_ARRAY_COUNT(gModes); ky++) {
|
||||
SkPaint paint;
|
||||
setup(&paint, fTexture[i], gFilters[j], gModes[kx], gModes[ky]);
|
||||
paint.setDither(true);
|
||||
|
||||
canvas->save();
|
||||
canvas->translate(x, y);
|
||||
canvas->drawRect(r, paint);
|
||||
canvas->restore();
|
||||
|
||||
x += r.width() * 4 / 3;
|
||||
}
|
||||
}
|
||||
if (textCanvas) {
|
||||
SkPaint p;
|
||||
p.setLooper(fLooper);
|
||||
textCanvas->drawString(
|
||||
SkStringPrintf("%s, %s", gConfigNames[i], gFilterNames[j]),
|
||||
x, y + r.height() * 2 / 3, SkFont(), p);
|
||||
}
|
||||
|
||||
y += r.height() * 4 / 3;
|
||||
}
|
||||
}
|
||||
|
||||
if (textCanvas) {
|
||||
SkASSERT(nullptr == fTextPicture);
|
||||
fTextPicture = recorder.finishRecordingAsPicture();
|
||||
}
|
||||
|
||||
SkASSERT(fTextPicture);
|
||||
canvas->drawPicture(fTextPicture.get());
|
||||
}
|
||||
|
||||
private:
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
DEF_SAMPLE( return new TilingView(); )
|
||||
|
||||
#endif
|
@ -10,7 +10,6 @@
|
||||
#include "include/core/SkStream.h"
|
||||
#include "include/core/SkString.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/effects/SkBlurDrawLooper.h"
|
||||
#include "samplecode/DecodeFile.h"
|
||||
#include "samplecode/Sample.h"
|
||||
#include "src/core/SkBlurMask.h"
|
||||
@ -20,8 +19,6 @@
|
||||
#include "tools/Resources.h"
|
||||
#include "tools/ToolUtils.h"
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
|
||||
/**
|
||||
* Interprets c as an unpremultiplied color, and returns the
|
||||
* premultiplied equivalent.
|
||||
@ -75,10 +72,6 @@ protected:
|
||||
|
||||
SkFont font;
|
||||
font.setSize(24);
|
||||
auto looper(
|
||||
SkBlurDrawLooper::Make(SK_ColorBLUE, SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(2)),
|
||||
0, 0));
|
||||
paint.setLooper(looper);
|
||||
SkScalar height = font.getMetrics(nullptr);
|
||||
if (!fDecodeSucceeded) {
|
||||
SkString failure;
|
||||
@ -171,5 +164,3 @@ private:
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
DEF_SAMPLE( return new UnpremulView(GetResourcePath("images")); )
|
||||
|
||||
#endif
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "include/core/SkCanvas.h"
|
||||
|
||||
#include "include/core/SkColorFilter.h"
|
||||
#include "include/core/SkDrawLooper.h"
|
||||
#include "include/core/SkImage.h"
|
||||
#include "include/core/SkImageFilter.h"
|
||||
#include "include/core/SkPathEffect.h"
|
||||
@ -110,11 +109,7 @@ bool SkCanvas::wouldOverwriteEntireSurface(const SkRect* rect, const SkPaint* pa
|
||||
paintStyle == SkPaint::kStrokeAndFill_Style)) {
|
||||
return false;
|
||||
}
|
||||
if (paint->getMaskFilter()
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
|| paint->getLooper()
|
||||
#endif
|
||||
|| paint->getPathEffect() || paint->getImageFilter()) {
|
||||
if (paint->getMaskFilter() || paint->getPathEffect() || paint->getImageFilter()) {
|
||||
return false; // conservative
|
||||
}
|
||||
}
|
||||
@ -419,16 +414,7 @@ public:
|
||||
// we remove the imagefilter/xfermode inside doNext()
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
if (SkDrawLooper* looper = paint.getLooper()) {
|
||||
fLooperContext = looper->makeContext(&fAlloc);
|
||||
fCanvas->save();
|
||||
fIsSimple = false;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
fLooperContext = nullptr;
|
||||
// can we be marked as simple?
|
||||
fIsSimple = !fTempLayerForImageFilter;
|
||||
}
|
||||
}
|
||||
@ -442,9 +428,6 @@ public:
|
||||
|
||||
const SkPaint& paint() const {
|
||||
SkASSERT(fPaint);
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
SkASSERT(fPaint->getDrawLooper() == nullptr); // we should have cleared this
|
||||
#endif
|
||||
return *fPaint;
|
||||
}
|
||||
|
||||
@ -469,8 +452,6 @@ private:
|
||||
bool fTempLayerForImageFilter;
|
||||
bool fDone;
|
||||
bool fIsSimple;
|
||||
SkDrawLooper::Context* fLooperContext;
|
||||
SkSTArenaAlloc<48> fAlloc;
|
||||
|
||||
bool doNext();
|
||||
};
|
||||
@ -478,36 +459,20 @@ private:
|
||||
bool AutoDrawLooper::doNext() {
|
||||
fPaint = nullptr;
|
||||
SkASSERT(!fIsSimple);
|
||||
SkASSERT(fLooperContext || fTempLayerForImageFilter);
|
||||
SkASSERT(fTempLayerForImageFilter);
|
||||
|
||||
SkPaint* paint = fLazyPaintPerLooper.set(fLazyPaintInit.isValid() ?
|
||||
*fLazyPaintInit.get() : fOrigPaint);
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
// never want our downstream clients (i.e. devices) to see loopers
|
||||
paint->setDrawLooper(nullptr);
|
||||
#endif
|
||||
|
||||
if (fTempLayerForImageFilter) {
|
||||
paint->setImageFilter(nullptr);
|
||||
paint->setBlendMode(SkBlendMode::kSrcOver);
|
||||
}
|
||||
|
||||
if (fLooperContext) {
|
||||
fCanvas->restore();
|
||||
SkDrawLooper::Context::Info info;
|
||||
if (!fLooperContext->next(&info, paint)) {
|
||||
fDone = true;
|
||||
return false;
|
||||
}
|
||||
fCanvas->save();
|
||||
info.applyToCanvas(fCanvas);
|
||||
}
|
||||
fPaint = paint;
|
||||
|
||||
// if we only came in here for the imagefilter, mark us as done
|
||||
if (!fLooperContext) {
|
||||
fDone = true;
|
||||
}
|
||||
fDone = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2132,11 +2097,7 @@ void SkCanvas::onDrawPoints(PointMode mode, size_t count, const SkPoint pts[],
|
||||
}
|
||||
|
||||
static bool needs_autodrawlooper(SkCanvas* canvas, const SkPaint& paint) {
|
||||
return ((intptr_t)paint.getImageFilter()
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
| (intptr_t)paint.getLooper()
|
||||
#endif
|
||||
) != 0;
|
||||
return paint.getImageFilter() != nullptr;
|
||||
}
|
||||
|
||||
void SkCanvas::onDrawRect(const SkRect& r, const SkPaint& paint) {
|
||||
|
@ -38,9 +38,6 @@ bool SkDrawLooper::canComputeFastBounds(const SkPaint& paint) const {
|
||||
SkPaint p(paint);
|
||||
SkDrawLooper::Context::Info info;
|
||||
if (context->next(&info, &p)) {
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
p.setLooper(nullptr);
|
||||
#endif
|
||||
if (!p.canComputeFastBounds()) {
|
||||
return false;
|
||||
}
|
||||
@ -67,9 +64,6 @@ void SkDrawLooper::computeFastBounds(const SkPaint& paint, const SkRect& s,
|
||||
if (context->next(&info, &p)) {
|
||||
SkRect r(src);
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
p.setLooper(nullptr);
|
||||
#endif
|
||||
p.computeFastBounds(r, &r);
|
||||
r.offset(info.fTranslate.fX, info.fTranslate.fY);
|
||||
|
||||
|
@ -76,7 +76,6 @@ bool operator==(const SkPaint& a, const SkPaint& b) {
|
||||
&& EQUAL(fShader)
|
||||
&& EQUAL(fMaskFilter)
|
||||
&& EQUAL(fColorFilter)
|
||||
&& EQUAL(fDrawLooper)
|
||||
&& EQUAL(fImageFilter)
|
||||
&& EQUAL(fColor4f)
|
||||
&& EQUAL(fWidth)
|
||||
@ -88,9 +87,6 @@ bool operator==(const SkPaint& a, const SkPaint& b) {
|
||||
|
||||
#define DEFINE_REF_FOO(type) sk_sp<Sk##type> SkPaint::ref##type() const { return f##type; }
|
||||
DEFINE_REF_FOO(ColorFilter)
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
DEFINE_REF_FOO(DrawLooper)
|
||||
#endif
|
||||
DEFINE_REF_FOO(ImageFilter)
|
||||
DEFINE_REF_FOO(MaskFilter)
|
||||
DEFINE_REF_FOO(PathEffect)
|
||||
@ -183,15 +179,8 @@ MOVE_FIELD(Shader)
|
||||
MOVE_FIELD(ColorFilter)
|
||||
MOVE_FIELD(PathEffect)
|
||||
MOVE_FIELD(MaskFilter)
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
MOVE_FIELD(DrawLooper)
|
||||
#endif
|
||||
#undef MOVE_FIELD
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
void SkPaint::setLooper(sk_sp<SkDrawLooper> looper) { fDrawLooper = std::move(looper); }
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "include/core/SkStream.h"
|
||||
@ -327,9 +316,6 @@ void SkPaintPriv::Flatten(const SkPaint& paint, SkWriteBuffer& buffer) {
|
||||
paint.getShader() ||
|
||||
paint.getMaskFilter() ||
|
||||
paint.getColorFilter() ||
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
paint.getLooper() ||
|
||||
#endif
|
||||
paint.getImageFilter()) {
|
||||
flatFlags |= kHasEffects_FlatFlag;
|
||||
}
|
||||
@ -345,11 +331,7 @@ void SkPaintPriv::Flatten(const SkPaint& paint, SkWriteBuffer& buffer) {
|
||||
buffer.writeFlattenable(paint.getShader());
|
||||
buffer.writeFlattenable(paint.getMaskFilter());
|
||||
buffer.writeFlattenable(paint.getColorFilter());
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
buffer.writeFlattenable(paint.getLooper());
|
||||
#else
|
||||
buffer.write32(0);
|
||||
#endif
|
||||
buffer.write32(0); // legacy, was drawlooper
|
||||
buffer.writeFlattenable(paint.getImageFilter());
|
||||
}
|
||||
}
|
||||
@ -400,20 +382,13 @@ SkReadPaintResult SkPaintPriv::Unflatten_PreV68(SkPaint* paint, SkReadBuffer& bu
|
||||
paint->setMaskFilter(buffer.readMaskFilter());
|
||||
paint->setColorFilter(buffer.readColorFilter());
|
||||
(void)buffer.read32(); // use to be SkRasterizer
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
paint->setLooper(buffer.readDrawLooper());
|
||||
#else
|
||||
(void)buffer.read32(); // used to be drawlooper
|
||||
#endif
|
||||
paint->setImageFilter(buffer.readImageFilter());
|
||||
} else {
|
||||
paint->setPathEffect(nullptr);
|
||||
paint->setShader(nullptr);
|
||||
paint->setMaskFilter(nullptr);
|
||||
paint->setColorFilter(nullptr);
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
paint->setLooper(nullptr);
|
||||
#endif
|
||||
paint->setImageFilter(nullptr);
|
||||
}
|
||||
|
||||
@ -446,20 +421,13 @@ SkReadPaintResult SkPaintPriv::Unflatten(SkPaint* paint, SkReadBuffer& buffer, S
|
||||
paint->setShader(buffer.readShader());
|
||||
paint->setMaskFilter(buffer.readMaskFilter());
|
||||
paint->setColorFilter(buffer.readColorFilter());
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
paint->setLooper(buffer.readDrawLooper());
|
||||
#else
|
||||
(void)buffer.readDrawLooper();
|
||||
#endif
|
||||
paint->setImageFilter(buffer.readImageFilter());
|
||||
} else {
|
||||
paint->setPathEffect(nullptr);
|
||||
paint->setShader(nullptr);
|
||||
paint->setMaskFilter(nullptr);
|
||||
paint->setColorFilter(nullptr);
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
paint->setLooper(nullptr);
|
||||
#endif
|
||||
paint->setImageFilter(nullptr);
|
||||
}
|
||||
|
||||
@ -508,11 +476,6 @@ bool SkPaint::getFillPath(const SkPath& src, SkPath* dst, const SkRect* cullRect
|
||||
}
|
||||
|
||||
bool SkPaint::canComputeFastBounds() const {
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
if (this->getLooper()) {
|
||||
return this->getLooper()->canComputeFastBounds(*this);
|
||||
}
|
||||
#endif
|
||||
if (this->getImageFilter() && !this->getImageFilter()->canComputeFastBounds()) {
|
||||
return false;
|
||||
}
|
||||
@ -526,14 +489,6 @@ const SkRect& SkPaint::doComputeFastBounds(const SkRect& origSrc,
|
||||
|
||||
const SkRect* src = &origSrc;
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
if (this->getLooper()) {
|
||||
SkASSERT(this->getLooper()->canComputeFastBounds(*this));
|
||||
this->getLooper()->computeFastBounds(*this, *src, storage);
|
||||
return *storage;
|
||||
}
|
||||
#endif
|
||||
|
||||
SkRect tmpSrc;
|
||||
if (this->getPathEffect()) {
|
||||
this->getPathEffect()->computeFastBounds(&tmpSrc, origSrc);
|
||||
@ -569,9 +524,6 @@ static bool affects_alpha(const SkImageFilter* imf) {
|
||||
}
|
||||
|
||||
bool SkPaint::nothingToDraw() const {
|
||||
if (fDrawLooper) {
|
||||
return false;
|
||||
}
|
||||
switch (this->getBlendMode()) {
|
||||
case SkBlendMode::kSrcOver:
|
||||
case SkBlendMode::kSrcATop:
|
||||
@ -591,9 +543,9 @@ bool SkPaint::nothingToDraw() const {
|
||||
}
|
||||
|
||||
uint32_t SkPaint::getHash() const {
|
||||
// We're going to hash 6 pointers and 6 floats, finishing up with fBitfields,
|
||||
// so fBitfields should be 6 pointers and 6 floats from the start.
|
||||
static_assert(offsetof(SkPaint, fBitfieldsUInt) == 6 * sizeof(void*) + 6 * sizeof(float),
|
||||
// We're going to hash 5 pointers and 6 floats, finishing up with fBitfields,
|
||||
// so fBitfields should be 5 pointers and 6 floats from the start.
|
||||
static_assert(offsetof(SkPaint, fBitfieldsUInt) == 5 * sizeof(void*) + 6 * sizeof(float),
|
||||
"SkPaint_notPackedTightly");
|
||||
return SkOpts::hash(reinterpret_cast<const uint32_t*>(this),
|
||||
offsetof(SkPaint, fBitfieldsUInt) + sizeof(fBitfieldsUInt));
|
||||
|
@ -6,7 +6,6 @@
|
||||
*/
|
||||
|
||||
#include "include/core/SkColorFilter.h"
|
||||
#include "include/core/SkDrawLooper.h"
|
||||
#include "include/core/SkMaskFilter.h"
|
||||
#include "include/core/SkShader.h"
|
||||
#include "include/core/SkTypeface.h"
|
||||
|
@ -94,15 +94,9 @@ static bool fold_opacity_layer_color_to_paint(const SkPaint* layerPaint,
|
||||
// true, we assume paint is too.
|
||||
|
||||
// The alpha folding can proceed if the filter layer paint does not have properties which cause
|
||||
// the resulting filter layer to be "blended" in complex ways to the parent layer. For example,
|
||||
// looper drawing unmodulated filter layer twice and then modulating the result produces
|
||||
// different image to drawing modulated filter layer twice.
|
||||
// TODO: most likely the looper and only some xfer modes are the hard constraints
|
||||
if (!paint->isSrcOver()
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
|| paint->getLooper()
|
||||
#endif
|
||||
) {
|
||||
// the resulting filter layer to be "blended" in complex ways to the parent layer.
|
||||
// TODO: most likely only some xfer modes are the hard constraints
|
||||
if (!paint->isSrcOver()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -138,9 +132,6 @@ static bool fold_opacity_layer_color_to_paint(const SkPaint* layerPaint,
|
||||
!layerPaint->isSrcOver() ||
|
||||
layerPaint->getMaskFilter() ||
|
||||
layerPaint->getColorFilter() ||
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
layerPaint->getLooper() ||
|
||||
#endif
|
||||
layerPaint->getImageFilter()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include <vector>
|
||||
|
||||
#include "include/core/SkData.h"
|
||||
#include "include/core/SkDrawLooper.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkSerialProcs.h"
|
||||
#include "include/core/SkTypeface.h"
|
||||
|
@ -9,7 +9,6 @@
|
||||
#define SkTextBlobPriv_DEFINED
|
||||
|
||||
#include "include/core/SkColorFilter.h"
|
||||
#include "include/core/SkDrawLooper.h"
|
||||
#include "include/core/SkFont.h"
|
||||
#include "include/core/SkImageFilter.h"
|
||||
#include "include/core/SkMaskFilter.h"
|
||||
|
@ -814,9 +814,6 @@ static int lpaint_getEffects(lua_State* L) {
|
||||
const SkPaint* paint = get_obj<SkPaint>(L, 1);
|
||||
|
||||
lua_newtable(L);
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
setfield_bool_if(L, "looper", !!paint->getLooper());
|
||||
#endif
|
||||
setfield_bool_if(L, "pathEffect", !!paint->getPathEffect());
|
||||
setfield_bool_if(L, "maskFilter", !!paint->getMaskFilter());
|
||||
setfield_bool_if(L, "shader", !!paint->getShader());
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "include/core/SkMaskFilter.h"
|
||||
#include "include/core/SkPath.h"
|
||||
#include "include/core/SkTypeface.h"
|
||||
#include "include/effects/SkLayerDrawLooper.h"
|
||||
#include "include/private/SkTo.h"
|
||||
#include "include/utils/SkRandom.h"
|
||||
#include "src/core/SkAutoMalloc.h"
|
||||
@ -50,10 +49,6 @@ DEF_TEST(Paint_copy, reporter) {
|
||||
paint.setStyle(SkPaint::kStrokeAndFill_Style);
|
||||
paint.setStrokeWidth(SkIntToScalar(2));
|
||||
// set a few pointers
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
SkLayerDrawLooper::Builder looperBuilder;
|
||||
paint.setLooper(looperBuilder.detach());
|
||||
#endif
|
||||
paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle,
|
||||
SkBlurMask::ConvertRadiusToSigma(1)));
|
||||
|
||||
@ -181,9 +176,6 @@ DEF_TEST(Paint_MoreFlattening, r) {
|
||||
SkPaint paint;
|
||||
paint.setColor(0x00AABBCC);
|
||||
paint.setBlendMode(SkBlendMode::kModulate);
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
paint.setLooper(nullptr); // Default value, ignored.
|
||||
#endif
|
||||
|
||||
SkBinaryWriteBuffer writer;
|
||||
SkPaintPriv::Flatten(paint, writer);
|
||||
@ -198,9 +190,6 @@ DEF_TEST(Paint_MoreFlattening, r) {
|
||||
|
||||
// No matter the encoding, these must always hold.
|
||||
ASSERT(other.getColor() == paint.getColor());
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
ASSERT(other.getLooper() == paint.getLooper());
|
||||
#endif
|
||||
ASSERT(other.getBlendMode() == paint.getBlendMode());
|
||||
}
|
||||
|
||||
|
@ -7,48 +7,12 @@
|
||||
|
||||
#include "include/core/SkBitmap.h"
|
||||
#include "include/core/SkCanvas.h"
|
||||
#include "include/core/SkDrawLooper.h"
|
||||
#include "include/core/SkPoint3.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/effects/SkLightingImageFilter.h"
|
||||
#include "src/core/SkArenaAlloc.h"
|
||||
#include "tests/Test.h"
|
||||
|
||||
/*
|
||||
* Subclass of looper that just draws once, with an offset in X.
|
||||
*/
|
||||
class TestLooper : public SkDrawLooper {
|
||||
public:
|
||||
|
||||
SkDrawLooper::Context* makeContext(SkArenaAlloc* alloc) const override {
|
||||
return alloc->make<TestDrawLooperContext>();
|
||||
}
|
||||
|
||||
private:
|
||||
SK_FLATTENABLE_HOOKS(TestLooper)
|
||||
|
||||
class TestDrawLooperContext : public SkDrawLooper::Context {
|
||||
public:
|
||||
TestDrawLooperContext() : fOnce(true) {}
|
||||
~TestDrawLooperContext() override {}
|
||||
|
||||
bool next(Info* info, SkPaint*) override {
|
||||
if (fOnce) {
|
||||
fOnce = false;
|
||||
info->fTranslate = {10, 0};
|
||||
info->fApplyPostCTM = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
bool fOnce;
|
||||
};
|
||||
};
|
||||
|
||||
sk_sp<SkFlattenable> TestLooper::CreateProc(SkReadBuffer&) { return sk_make_sp<TestLooper>(); }
|
||||
|
||||
static void test_drawBitmap(skiatest::Reporter* reporter) {
|
||||
SkBitmap src;
|
||||
src.allocN32Pixels(10, 10);
|
||||
@ -75,16 +39,6 @@ static void test_drawBitmap(skiatest::Reporter* reporter) {
|
||||
// if the bitmap is clipped out, we don't draw it
|
||||
canvas.drawBitmap(src, SkIntToScalar(-10), 0, &paint);
|
||||
REPORTER_ASSERT(reporter, 0 == *dst.getAddr32(5, 5));
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
// now install our looper, which will draw, since it internally translates
|
||||
// to the left. The test is to ensure that canvas' quickReject machinary
|
||||
// allows us through, even though sans-looper we would look like we should
|
||||
// be clipped out.
|
||||
paint.setLooper(sk_make_sp<TestLooper>());
|
||||
canvas.drawBitmap(src, SkIntToScalar(-10), 0, &paint);
|
||||
REPORTER_ASSERT(reporter, 0xFFFFFFFF == *dst.getAddr32(5, 5));
|
||||
#endif
|
||||
}
|
||||
|
||||
static void test_layers(skiatest::Reporter* reporter) {
|
||||
@ -168,31 +122,3 @@ DEF_TEST(QuickReject_MatrixState, reporter) {
|
||||
// quickReject() will assert if the matrix is out of sync.
|
||||
canvas.quickReject(SkRect::MakeWH(100.0f, 100.0f));
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
#include "include/core/SkSurface.h"
|
||||
#include "include/effects/SkLayerDrawLooper.h"
|
||||
DEF_TEST(looper_nothingtodraw, reporter) {
|
||||
auto surf = SkSurface::MakeRasterN32Premul(20, 20);
|
||||
|
||||
SkPaint paint;
|
||||
paint.setColor(0);
|
||||
REPORTER_ASSERT(reporter, paint.nothingToDraw());
|
||||
|
||||
SkLayerDrawLooper::Builder builder;
|
||||
builder.addLayer();
|
||||
paint.setDrawLooper(builder.detach());
|
||||
// the presence of the looper fools this predicate, so we think it might draw
|
||||
REPORTER_ASSERT(reporter, !paint.nothingToDraw());
|
||||
|
||||
// Before fixing, this would assert in ~AutoDrawLooper() in SkCanvas.cpp as it checked for
|
||||
// a balance in the save/restore count after handling the looper. Before the fix, this
|
||||
// code would call nothingToDraw() and since it now clears the looper, that predicate will
|
||||
// return true, aborting the sequence prematurely, and not finishing the iterator on the looper
|
||||
// which handles the final "restore". This was a bug -- we *must* call the looper's iterator
|
||||
// until it returns done to keep the canvas balanced. The fix was to remove this early-exit
|
||||
// in the autodrawlooper. Now this call won't assert.
|
||||
// See https://skia-review.googlesource.com/c/skia/+/121220
|
||||
surf->getCanvas()->drawRect({1, 1, 10, 10}, paint);
|
||||
}
|
||||
#endif
|
||||
|
@ -84,7 +84,6 @@
|
||||
#define DEBUGCANVAS_ATTRIBUTE_PATHEFFECT "pathEffect"
|
||||
#define DEBUGCANVAS_ATTRIBUTE_MASKFILTER "maskFilter"
|
||||
#define DEBUGCANVAS_ATTRIBUTE_XFERMODE "xfermode"
|
||||
#define DEBUGCANVAS_ATTRIBUTE_LOOPER "looper"
|
||||
#define DEBUGCANVAS_ATTRIBUTE_BACKDROP "backdrop"
|
||||
#define DEBUGCANVAS_ATTRIBUTE_COLORFILTER "colorfilter"
|
||||
#define DEBUGCANVAS_ATTRIBUTE_IMAGEFILTER "imagefilter"
|
||||
@ -948,9 +947,6 @@ void DrawCommand::MakeJsonPaint(SkJSONWriter& writer,
|
||||
apply_paint_patheffect(paint, writer, urlDataManager);
|
||||
apply_paint_maskfilter(paint, writer, urlDataManager);
|
||||
apply_flattenable(DEBUGCANVAS_ATTRIBUTE_SHADER, paint.getShader(), writer, urlDataManager);
|
||||
#ifdef SK_SUPPORT_LEGACY_DRAWLOOPER
|
||||
apply_flattenable(DEBUGCANVAS_ATTRIBUTE_LOOPER, paint.getLooper(), writer, urlDataManager);
|
||||
#endif
|
||||
apply_flattenable(
|
||||
DEBUGCANVAS_ATTRIBUTE_IMAGEFILTER, paint.getImageFilter(), writer, urlDataManager);
|
||||
apply_flattenable(
|
||||
|
Loading…
Reference in New Issue
Block a user