Add API to get canvas wrapped by SkPaintFilterCanvas
Implement SkAndroidFrameworkUtil::getBaseWrappedCanvas, which gets the real canvas behind SkPaintFilterCanvas. This is useful, because SkCanvas::drawDrawable works differently on a GPU backed canvas. Test: Built and ran with Android Bug: b/128792554 Change-Id: I5b75d42256d7a4efca987d55be2ce064c10fb4e7 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/204442 Commit-Queue: Stan Iliev <stani@google.com> Reviewed-by: Florin Malita <fmalita@chromium.org>
This commit is contained in:
parent
6aca398ea3
commit
b0a8684e61
@ -40,6 +40,15 @@ public:
|
|||||||
static sk_sp<SkSurface> getSurfaceFromCanvas(SkCanvas* canvas);
|
static sk_sp<SkSurface> getSurfaceFromCanvas(SkCanvas* canvas);
|
||||||
|
|
||||||
static int SaveBehind(SkCanvas* canvas, const SkRect* subset);
|
static int SaveBehind(SkCanvas* canvas, const SkRect* subset);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unrolls a chain of nested SkPaintFilterCanvas to return the base wrapped canvas.
|
||||||
|
*
|
||||||
|
* @param canvas A SkPaintFilterCanvas or any other SkCanvas subclass.
|
||||||
|
*
|
||||||
|
* @return SkCanvas that was found in the innermost SkPaintFilterCanvas.
|
||||||
|
*/
|
||||||
|
static SkCanvas* getBaseWrappedCanvas(SkCanvas* canvas);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SK_BUILD_FOR_ANDROID_ANDROID
|
#endif // SK_BUILD_FOR_ANDROID_ANDROID
|
||||||
|
@ -31,6 +31,7 @@ class SkFont;
|
|||||||
class SkGlyphRunBuilder;
|
class SkGlyphRunBuilder;
|
||||||
class SkImage;
|
class SkImage;
|
||||||
class SkImageFilter;
|
class SkImageFilter;
|
||||||
|
class SkPaintFilterCanvas;
|
||||||
class SkPath;
|
class SkPath;
|
||||||
class SkPicture;
|
class SkPicture;
|
||||||
class SkPixmap;
|
class SkPixmap;
|
||||||
@ -2668,6 +2669,8 @@ private:
|
|||||||
*/
|
*/
|
||||||
bool androidFramework_isClipAA() const;
|
bool androidFramework_isClipAA() const;
|
||||||
|
|
||||||
|
virtual SkPaintFilterCanvas* internal_private_asPaintFilterCanvas() const { return nullptr; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keep track of the device clip bounds and if the matrix is scale-translate. This allows
|
* Keep track of the device clip bounds and if the matrix is scale-translate. This allows
|
||||||
* us to do a fast quick reject in the common case.
|
* us to do a fast quick reject in the common case.
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
#include "SkNWayCanvas.h"
|
#include "SkNWayCanvas.h"
|
||||||
#include "SkTLazy.h"
|
#include "SkTLazy.h"
|
||||||
|
|
||||||
|
class SkAndroidFrameworkUtils;
|
||||||
|
|
||||||
/** \class SkPaintFilterCanvas
|
/** \class SkPaintFilterCanvas
|
||||||
|
|
||||||
A utility proxy base class for implementing draw/paint filters.
|
A utility proxy base class for implementing draw/paint filters.
|
||||||
@ -119,6 +121,12 @@ private:
|
|||||||
class AutoPaintFilter;
|
class AutoPaintFilter;
|
||||||
|
|
||||||
SkCanvas* proxy() const { SkASSERT(fList.count() == 1); return fList[0]; }
|
SkCanvas* proxy() const { SkASSERT(fList.count() == 1); return fList[0]; }
|
||||||
|
|
||||||
|
SkPaintFilterCanvas* internal_private_asPaintFilterCanvas() const override {
|
||||||
|
return const_cast<SkPaintFilterCanvas*>(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
friend class SkAndroidFrameworkUtils;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "SkAndroidFrameworkUtils.h"
|
#include "SkAndroidFrameworkUtils.h"
|
||||||
#include "SkCanvas.h"
|
#include "SkCanvas.h"
|
||||||
#include "SkDevice.h"
|
#include "SkDevice.h"
|
||||||
|
#include "SkPaintFilterCanvas.h"
|
||||||
#include "SkSurface_Base.h"
|
#include "SkSurface_Base.h"
|
||||||
|
|
||||||
#if SK_SUPPORT_GPU
|
#if SK_SUPPORT_GPU
|
||||||
@ -67,5 +68,15 @@ sk_sp<SkSurface> SkAndroidFrameworkUtils::getSurfaceFromCanvas(SkCanvas* canvas)
|
|||||||
int SkAndroidFrameworkUtils::SaveBehind(SkCanvas* canvas, const SkRect* subset) {
|
int SkAndroidFrameworkUtils::SaveBehind(SkCanvas* canvas, const SkRect* subset) {
|
||||||
return canvas->only_axis_aligned_saveBehind(subset);
|
return canvas->only_axis_aligned_saveBehind(subset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SkCanvas* SkAndroidFrameworkUtils::getBaseWrappedCanvas(SkCanvas* canvas) {
|
||||||
|
auto pfc = canvas->internal_private_asPaintFilterCanvas();
|
||||||
|
auto result = canvas;
|
||||||
|
while (pfc) {
|
||||||
|
result = pfc->proxy();
|
||||||
|
pfc = result->internal_private_asPaintFilterCanvas();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
#endif // SK_BUILD_FOR_ANDROID_FRAMEWORK
|
#endif // SK_BUILD_FOR_ANDROID_FRAMEWORK
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user