Reland "Remove layer-coverage-tracking experiment"
This is a reland of 688cb15faa
Original change's description:
> Remove layer-coverage-tracking experiment
>
> This effectively reverts reviews.skia.org/122000
>
> Bug: skia:10987
> Change-Id: I989241110f17c0e3c2a896aea4bc2bc4cc8c910f
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/472801
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Brian Osman <brianosman@google.com>
Bug: skia:10987
Change-Id: I16493df8bd7942261d14c01747d0fdc91bbe5467
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/473143
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
f3726c61d2
commit
45bc991e5d
@ -60,44 +60,6 @@ DEF_SIMPLE_GM(savelayer_initfromprev, canvas, 256, 256) {
|
||||
canvas->restore();
|
||||
};
|
||||
|
||||
DEF_SIMPLE_GM(savelayer_coverage, canvas, 500, 500) {
|
||||
canvas->saveLayer(nullptr, nullptr);
|
||||
|
||||
SkRect r = { 0, 0, 200, 200 };
|
||||
SkPaint layerPaint;
|
||||
layerPaint.setBlendMode(SkBlendMode::kModulate);
|
||||
|
||||
auto image = GetResourceAsImage("images/mandrill_128.png");
|
||||
|
||||
auto proc = [layerPaint](SkCanvas* canvas, SkCanvas::SaveLayerRec& rec) {
|
||||
SkPaint paint;
|
||||
paint.setColor(SK_ColorRED);
|
||||
|
||||
canvas->saveLayer(rec);
|
||||
canvas->drawCircle(100, 100, 50, paint);
|
||||
paint.setColor(0x8800FF00);
|
||||
canvas->drawRect({10, 90, 190, 110}, paint);
|
||||
canvas->restore();
|
||||
};
|
||||
|
||||
const int yflags[] = { 0, SkCanvas::kInitWithPrevious_SaveLayerFlag };
|
||||
for (int y = 0; y <= 1; ++y) {
|
||||
const int xflags[] = { 0, SkCanvas::kMaskAgainstCoverage_EXPERIMENTAL_DONT_USE_SaveLayerFlag };
|
||||
for (int x = 0; x <= 1; ++x) {
|
||||
canvas->save();
|
||||
canvas->translate(x * 200.f, y * 200.f);
|
||||
|
||||
SkCanvas::SaveLayerRec rec(&r, &layerPaint, yflags[y] | xflags[x]);
|
||||
canvas->drawImageRect(image, r, SkSamplingOptions(), nullptr);
|
||||
proc(canvas, rec);
|
||||
|
||||
canvas->restore();
|
||||
}
|
||||
}
|
||||
|
||||
canvas->restore();
|
||||
}
|
||||
|
||||
static void draw_cell(SkCanvas* canvas, sk_sp<SkTextBlob> blob, SkColor c, SkScalar w, SkScalar h,
|
||||
bool useDrawBehind) {
|
||||
SkRect r = SkRect::MakeWH(w, h);
|
||||
|
@ -638,8 +638,6 @@ public:
|
||||
enum SaveLayerFlagsSet {
|
||||
kPreserveLCDText_SaveLayerFlag = 1 << 1,
|
||||
kInitWithPrevious_SaveLayerFlag = 1 << 2, //!< initializes with previous contents
|
||||
kMaskAgainstCoverage_EXPERIMENTAL_DONT_USE_SaveLayerFlag =
|
||||
1 << 3, //!< experimental: do not use
|
||||
// instead of matching previous layer's colortype, use F16
|
||||
kF16ColorType = 1 << 4,
|
||||
};
|
||||
|
@ -37,14 +37,6 @@ public:
|
||||
}
|
||||
fBlitter = SkBlitter::Choose(draw.fDst, *matrixProvider, paint, &fAlloc, drawCoverage,
|
||||
draw.fRC->clipShader());
|
||||
|
||||
if (draw.fCoverage) {
|
||||
// hmm, why can't choose ignore the paint if drawCoverage is true?
|
||||
SkBlitter* coverageBlitter =
|
||||
SkBlitter::Choose(*draw.fCoverage, *matrixProvider, SkPaint(), &fAlloc, true,
|
||||
draw.fRC->clipShader());
|
||||
fBlitter = fAlloc.make<SkPairBlitter>(fBlitter, coverageBlitter);
|
||||
}
|
||||
return fBlitter;
|
||||
}
|
||||
|
||||
|
@ -117,8 +117,6 @@ public:
|
||||
fDraw.fMatrixProvider = dev;
|
||||
fDraw.fRC = &dev->fRCStack.rc();
|
||||
fOrigin.set(0, 0);
|
||||
|
||||
fDraw.fCoverage = dev->accessCoverage();
|
||||
}
|
||||
}
|
||||
|
||||
@ -196,7 +194,6 @@ public:
|
||||
}
|
||||
fMatrixProvider = dev;
|
||||
fRC = &dev->fRCStack.rc();
|
||||
fCoverage = dev->accessCoverage();
|
||||
}
|
||||
};
|
||||
|
||||
@ -230,7 +227,7 @@ SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& info) {
|
||||
}
|
||||
|
||||
SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap, const SkSurfaceProps& surfaceProps,
|
||||
SkRasterHandleAllocator::Handle hndl, const SkBitmap* coverage)
|
||||
SkRasterHandleAllocator::Handle hndl)
|
||||
: INHERITED(bitmap.info(), surfaceProps)
|
||||
, fBitmap(bitmap)
|
||||
, fRasterHandle(hndl)
|
||||
@ -240,17 +237,10 @@ SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap, const SkSurfaceProps& sur
|
||||
bitmap.colorSpace(),
|
||||
SkStrikeCache::GlobalStrikeCache()) {
|
||||
SkASSERT(valid_for_bitmap_device(bitmap.info(), nullptr));
|
||||
|
||||
if (coverage) {
|
||||
SkASSERT(coverage->width() == bitmap.width());
|
||||
SkASSERT(coverage->height() == bitmap.height());
|
||||
fCoverage = std::make_unique<SkBitmap>(*coverage);
|
||||
}
|
||||
}
|
||||
|
||||
SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& origInfo,
|
||||
const SkSurfaceProps& surfaceProps,
|
||||
bool trackCoverage,
|
||||
SkRasterHandleAllocator* allocator) {
|
||||
SkAlphaType newAT = origInfo.alphaType();
|
||||
if (!valid_for_bitmap_device(origInfo, &newAT)) {
|
||||
@ -284,16 +274,7 @@ SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& origInfo,
|
||||
}
|
||||
}
|
||||
|
||||
SkBitmap coverage;
|
||||
if (trackCoverage) {
|
||||
SkImageInfo ci =
|
||||
SkImageInfo::Make(info.dimensions(), kAlpha_8_SkColorType, kPremul_SkAlphaType);
|
||||
if (!coverage.tryAllocPixelsFlags(ci, SkBitmap::kZeroPixels_AllocFlag)) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return new SkBitmapDevice(bitmap, surfaceProps, hndl, trackCoverage ? &coverage : nullptr);
|
||||
return new SkBitmapDevice(bitmap, surfaceProps, hndl);
|
||||
}
|
||||
|
||||
void SkBitmapDevice::replaceBitmapBackendForRasterSurface(const SkBitmap& bm) {
|
||||
@ -315,7 +296,7 @@ SkBaseDevice* SkBitmapDevice::onCreateDevice(const CreateInfo& cinfo, const SkPa
|
||||
info = info.makeColorType(kN32_SkColorType);
|
||||
}
|
||||
|
||||
return SkBitmapDevice::Create(info, surfaceProps, cinfo.fTrackCoverage, cinfo.fAllocator);
|
||||
return SkBitmapDevice::Create(info, surfaceProps, cinfo.fAllocator);
|
||||
}
|
||||
|
||||
bool SkBitmapDevice::onAccessPixels(SkPixmap* pmap) {
|
||||
@ -572,22 +553,7 @@ void SkBitmapDevice::drawDevice(SkBaseDevice* device, const SkSamplingOptions& s
|
||||
SkASSERT(!paint.getImageFilter());
|
||||
SkASSERT(!paint.getMaskFilter());
|
||||
|
||||
// hack to test coverage
|
||||
SkBitmapDevice* src = static_cast<SkBitmapDevice*>(device);
|
||||
if (src->fCoverage) {
|
||||
SkDraw draw;
|
||||
SkSimpleMatrixProvider matrixProvider(device->getRelativeTransform(*this));
|
||||
draw.fDst = fBitmap.pixmap();
|
||||
draw.fMatrixProvider = &matrixProvider;
|
||||
draw.fRC = &fRCStack.rc();
|
||||
|
||||
SkPaint deviceAsShader = paint;
|
||||
SkSamplingOptions nearest; // nearest-neighbor, since we in sprite mode
|
||||
deviceAsShader.setShader(src->fBitmap.makeShader(nearest));
|
||||
draw.drawBitmap(*src->fCoverage, SkMatrix::I(), nullptr, sampling, deviceAsShader);
|
||||
} else {
|
||||
this->INHERITED::drawDevice(device, sampling, paint);
|
||||
}
|
||||
this->INHERITED::drawDevice(device, sampling, paint);
|
||||
}
|
||||
|
||||
void SkBitmapDevice::drawSpecial(SkSpecialImage* src,
|
||||
|
@ -54,19 +54,10 @@ public:
|
||||
* any drawing to this device will have no effect.
|
||||
*/
|
||||
SkBitmapDevice(const SkBitmap& bitmap, const SkSurfaceProps& surfaceProps,
|
||||
void* externalHandle, const SkBitmap* coverage);
|
||||
void* externalHandle = nullptr);
|
||||
|
||||
static SkBitmapDevice* Create(const SkImageInfo&, const SkSurfaceProps&,
|
||||
bool trackCoverage,
|
||||
SkRasterHandleAllocator*);
|
||||
|
||||
static SkBitmapDevice* Create(const SkImageInfo& info, const SkSurfaceProps& props) {
|
||||
return Create(info, props, false, nullptr);
|
||||
}
|
||||
|
||||
const SkPixmap* accessCoverage() const {
|
||||
return fCoverage ? &fCoverage->pixmap() : nullptr;
|
||||
}
|
||||
SkRasterHandleAllocator* = nullptr);
|
||||
|
||||
protected:
|
||||
void* getRasterHandle() const override { return fRasterHandle; }
|
||||
@ -157,7 +148,6 @@ private:
|
||||
SkBitmap fBitmap;
|
||||
void* fRasterHandle = nullptr;
|
||||
SkRasterClipStack fRCStack;
|
||||
std::unique_ptr<SkBitmap> fCoverage; // if non-null, will have the same dimensions as fBitmap
|
||||
SkGlyphRunListPainter fGlyphPainter;
|
||||
|
||||
|
||||
|
@ -290,33 +290,4 @@ private:
|
||||
SkRgnClipBlitter fRgnBlitter;
|
||||
};
|
||||
|
||||
#define SHARD(code) fA->code; fB->code;
|
||||
|
||||
class SkPairBlitter : public SkBlitter {
|
||||
SkBlitter* fA = nullptr;
|
||||
SkBlitter* fB = nullptr;
|
||||
public:
|
||||
SkPairBlitter(SkBlitter* a, SkBlitter* b) : fA(a), fB(b) {}
|
||||
|
||||
void blitH(int x, int y, int width) override { SHARD(blitH(x, y, width)) }
|
||||
void blitAntiH(int x, int y, const SkAlpha alphas[], const int16_t runs[]) override {
|
||||
SHARD(blitAntiH(x, y, alphas, runs))
|
||||
}
|
||||
void blitV(int x, int y, int height, SkAlpha alpha) override {
|
||||
SHARD(blitV(x, y, height, alpha))
|
||||
}
|
||||
void blitRect(int x, int y, int width, int height) override {
|
||||
SHARD(blitRect(x, y, width, height))
|
||||
}
|
||||
void blitAntiRect(int x, int y, int width, int height,
|
||||
SkAlpha leftAlpha, SkAlpha rightAlpha) override {
|
||||
SHARD(blitAntiRect(x, y, width, height, leftAlpha, rightAlpha))
|
||||
}
|
||||
void blitMask(const SkMask& mask, const SkIRect& clip) override { SHARD(blitMask(mask, clip)) }
|
||||
const SkPixmap* justAnOpaqueColor(uint32_t* value) override { return nullptr; }
|
||||
void blitAntiH2(int x, int y, U8CPU a0, U8CPU a1) override { SHARD(blitAntiH2(x, y, a0, a1)) }
|
||||
void blitAntiV2(int x, int y, U8CPU a0, U8CPU a1) override { SHARD(blitAntiV2(x, y, a0, a1)) }
|
||||
};
|
||||
#undef SHARD
|
||||
|
||||
#endif
|
||||
|
@ -447,7 +447,7 @@ SkCanvas::SkCanvas(const SkBitmap& bitmap, const SkSurfaceProps& props)
|
||||
: fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)), fProps(props) {
|
||||
inc_canvas();
|
||||
|
||||
sk_sp<SkBaseDevice> device(new SkBitmapDevice(bitmap, fProps, nullptr, nullptr));
|
||||
sk_sp<SkBaseDevice> device(new SkBitmapDevice(bitmap, fProps));
|
||||
this->init(device);
|
||||
}
|
||||
|
||||
@ -458,7 +458,7 @@ SkCanvas::SkCanvas(const SkBitmap& bitmap,
|
||||
, fAllocator(std::move(alloc)) {
|
||||
inc_canvas();
|
||||
|
||||
sk_sp<SkBaseDevice> device(new SkBitmapDevice(bitmap, fProps, hndl, nullptr));
|
||||
sk_sp<SkBaseDevice> device(new SkBitmapDevice(bitmap, fProps, hndl));
|
||||
this->init(device);
|
||||
}
|
||||
|
||||
@ -471,7 +471,7 @@ SkCanvas::SkCanvas(const SkBitmap& bitmap, ColorBehavior)
|
||||
|
||||
SkBitmap tmp(bitmap);
|
||||
*const_cast<SkImageInfo*>(&tmp.info()) = tmp.info().makeColorSpace(nullptr);
|
||||
sk_sp<SkBaseDevice> device(new SkBitmapDevice(tmp, fProps, nullptr, nullptr));
|
||||
sk_sp<SkBaseDevice> device(new SkBitmapDevice(tmp, fProps));
|
||||
this->init(device);
|
||||
}
|
||||
#endif
|
||||
@ -917,7 +917,7 @@ void SkCanvas::internalDrawDeviceWithFilter(SkBaseDevice* src,
|
||||
requiredInput.height(), false),
|
||||
SkPixelGeometry::kUnknown_SkPixelGeometry,
|
||||
SkBaseDevice::TileUsage::kNever_TileUsage,
|
||||
false, fAllocator.get());
|
||||
fAllocator.get());
|
||||
sk_sp<SkBaseDevice> intermediateDevice(src->onCreateDevice(info, &paint));
|
||||
if (!intermediateDevice) {
|
||||
return;
|
||||
@ -1077,10 +1077,8 @@ void SkCanvas::internalSaveLayer(const SaveLayerRec& rec, SaveLayerStrategy stra
|
||||
SkPixelGeometry geo = rec.fSaveLayerFlags & kPreserveLCDText_SaveLayerFlag
|
||||
? fProps.pixelGeometry()
|
||||
: kUnknown_SkPixelGeometry;
|
||||
const bool trackCoverage = SkToBool(
|
||||
rec.fSaveLayerFlags & kMaskAgainstCoverage_EXPERIMENTAL_DONT_USE_SaveLayerFlag);
|
||||
const auto createInfo = SkBaseDevice::CreateInfo(info, geo, SkBaseDevice::kNever_TileUsage,
|
||||
trackCoverage, fAllocator.get());
|
||||
fAllocator.get());
|
||||
// Use the original paint as a hint so that it includes the image filter
|
||||
newDevice.reset(priorDevice->onCreateDevice(createInfo, rec.fPaint));
|
||||
}
|
||||
|
@ -371,19 +371,16 @@ protected:
|
||||
CreateInfo(const SkImageInfo& info,
|
||||
SkPixelGeometry geo,
|
||||
TileUsage tileUsage,
|
||||
bool trackCoverage,
|
||||
SkRasterHandleAllocator* allocator)
|
||||
: fInfo(info)
|
||||
, fTileUsage(tileUsage)
|
||||
, fPixelGeometry(geo)
|
||||
, fTrackCoverage(trackCoverage)
|
||||
, fAllocator(allocator)
|
||||
{}
|
||||
|
||||
const SkImageInfo fInfo;
|
||||
const TileUsage fTileUsage;
|
||||
const SkPixelGeometry fPixelGeometry;
|
||||
const bool fTrackCoverage = false;
|
||||
SkRasterHandleAllocator* fAllocator = nullptr;
|
||||
};
|
||||
|
||||
|
@ -158,9 +158,6 @@ public:
|
||||
const SkMatrixProvider* fMatrixProvider{nullptr}; // required
|
||||
const SkRasterClip* fRC{nullptr}; // required
|
||||
|
||||
// optional, will be same dimensions as fDst if present
|
||||
const SkPixmap* fCoverage{nullptr};
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
void validate() const;
|
||||
#else
|
||||
|
@ -41,12 +41,6 @@ void SkDraw::paintMasks(SkDrawableGlyphBuffer* drawables, const SkPaint& paint)
|
||||
SkSTArenaAlloc<3308> alloc;
|
||||
SkBlitter* blitter =
|
||||
SkBlitter::Choose(fDst, *fMatrixProvider, paint, &alloc, false, fRC->clipShader());
|
||||
if (fCoverage) {
|
||||
blitter = alloc.make<SkPairBlitter>(
|
||||
blitter,
|
||||
SkBlitter::Choose(
|
||||
*fCoverage, *fMatrixProvider, SkPaint(), &alloc, true, fRC->clipShader()));
|
||||
}
|
||||
|
||||
SkAAClipBlitterWrapper wrapper{*fRC, blitter};
|
||||
blitter = wrapper.getBlitter();
|
||||
|
Loading…
Reference in New Issue
Block a user