Move AlphaFilterCanvas to new API.
The AlphaFilterCanvas is only used when it will make a copy of the paint anyway. Remove the need to keep track of copy on write semantics when they are never used. Test: refactoring CL. Existing unit tests still pass. Change-Id: I20c0d618db7d1a76756bd4c16fe686ce7fb44f38
This commit is contained in:
@@ -187,17 +187,13 @@ public:
|
||||
AlphaFilterCanvas(SkCanvas* canvas, float alpha) : SkPaintFilterCanvas(canvas), mAlpha(alpha) {}
|
||||
|
||||
protected:
|
||||
bool onFilter(SkTCopyOnFirstWrite<SkPaint>* paint, Type t) const override {
|
||||
std::optional<SkPaint> defaultPaint;
|
||||
if (!*paint) {
|
||||
paint->init(defaultPaint.emplace());
|
||||
}
|
||||
paint->writable()->setAlpha((uint8_t)(*paint)->getAlpha() * mAlpha);
|
||||
bool onFilter(SkPaint& paint) const override {
|
||||
paint.setAlpha((uint8_t)paint.getAlpha() * mAlpha);
|
||||
return true;
|
||||
}
|
||||
void onDrawDrawable(SkDrawable* drawable, const SkMatrix* matrix) override {
|
||||
// We unroll the drawable using "this" canvas, so that draw calls contained inside will
|
||||
// get their alpha applied. THe default SkPaintFilterCanvas::onDrawDrawable does not unroll.
|
||||
// get their alpha applied. The default SkPaintFilterCanvas::onDrawDrawable does not unroll.
|
||||
drawable->draw(this, matrix);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user