diff options
author | Derek Sollenberger <djsollen@google.com> | 2011-11-30 09:06:42 -0500 |
---|---|---|
committer | Derek Sollenberger <djsollen@google.com> | 2011-11-30 14:31:48 -0500 |
commit | 717c009190af219a2f9e248d6fa13ad71cfdb0b1 (patch) | |
tree | 9e6f4da4d41acd4bd44e1fdfc26d5342ac2dbcc6 /include | |
parent | 9f673923c0f587590b722b94bf078312921411ac (diff) | |
download | external_skia-717c009190af219a2f9e248d6fa13ad71cfdb0b1.zip external_skia-717c009190af219a2f9e248d6fa13ad71cfdb0b1.tar.gz external_skia-717c009190af219a2f9e248d6fa13ad71cfdb0b1.tar.bz2 |
Fix rendering bug in pages with shadowed text.
Shadowed text currently does not get subjected to culling until
immediately prior to rendering each glyph. This is problematic
for any page with an axis greater than 32k as we can't covert
the glyph coordinates to fixed point. Additionally, this is a
large perf hit as we look at every shadowed glyph on the page
for every draw call regardless of the canvas' clip.
This fix enables shadowed text to be quickly rejected based on
the canvas' clip when the draw text command is executed.
Finally, a mirror image of this CL is currently under review for
inclusion in the open-source Skia project.
bug: 5571685
Change-Id: I5df94eccecbd7d77a08004b5cbcca02120e390f7
Diffstat (limited to 'include')
-rw-r--r-- | include/core/SkDrawLooper.h | 14 | ||||
-rw-r--r-- | include/core/SkMaskFilter.h | 13 | ||||
-rw-r--r-- | include/core/SkPaint.h | 21 |
3 files changed, 39 insertions, 9 deletions
diff --git a/include/core/SkDrawLooper.h b/include/core/SkDrawLooper.h index 270abc2..3830b4a 100644 --- a/include/core/SkDrawLooper.h +++ b/include/core/SkDrawLooper.h @@ -52,6 +52,20 @@ public: */ virtual bool next(SkCanvas*, SkPaint* paint) = 0; + /** + * The fast bounds functions are used to enable the paint to be culled early + * in the drawing pipeline. If a subclass can support this feature it must + * return true for the canComputeFastBounds() function. If that function + * returns false then computeFastBounds behavior is undefined otherwise it + * is expected to have the following behavior. Given the parent paint and + * the parent's bounding rect the subclass must fill in and return the + * storage rect, where the storage rect is with the union of the src rect + * and the looper's bounding rect. + */ + virtual bool canComputeFastBounds(const SkPaint& paint); + virtual void computeFastBounds(const SkPaint& paint, + const SkRect& src, SkRect* dst); + protected: SkDrawLooper() {} SkDrawLooper(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {} diff --git a/include/core/SkMaskFilter.h b/include/core/SkMaskFilter.h index 641ad83..60dade9 100644 --- a/include/core/SkMaskFilter.h +++ b/include/core/SkMaskFilter.h @@ -72,6 +72,19 @@ public: virtual void flatten(SkFlattenableWriteBuffer& ) {} + /** + * The fast bounds function is used to enable the paint to be culled early + * in the drawing pipeline. This function accepts the current bounds of the + * paint as its src param and the filter adjust those bounds using its + * current mask and returns the result using the dest param. Callers are + * allowed to provide the same struct for both src and dest so each + * implementation must accomodate that behavior. + * + * The default impl calls filterMask with the src mask having no image, + * but subclasses may override this if they can compute the rect faster. + */ + virtual void computeFastBounds(const SkRect& src, SkRect* dest); + protected: // empty for now, but lets get our subclass to remember to init us for the future SkMaskFilter(SkFlattenableReadBuffer&) {} diff --git a/include/core/SkPaint.h b/include/core/SkPaint.h index f336f5b..9b547a4 100644 --- a/include/core/SkPaint.h +++ b/include/core/SkPaint.h @@ -18,7 +18,7 @@ #define SkPaint_DEFINED #include "SkColor.h" -#include "SkMath.h" +#include "SkDrawLooper.h" #include "SkXfermode.h" class SkAutoGlyphCache; @@ -35,7 +35,6 @@ class SkPath; class SkPathEffect; class SkRasterizer; class SkShader; -class SkDrawLooper; class SkTypeface; typedef const SkGlyph& (*SkDrawCacheProc)(SkGlyphCache*, const char**, @@ -425,10 +424,11 @@ public: the bounds computation expensive. */ bool canComputeFastBounds() const { + if (this->getLooper()) { + return this->getLooper()->canComputeFastBounds(*this); + } // use bit-or since no need for early exit - return (reinterpret_cast<uintptr_t>(this->getMaskFilter()) | - reinterpret_cast<uintptr_t>(this->getLooper()) | - reinterpret_cast<uintptr_t>(this->getRasterizer()) | + return (reinterpret_cast<uintptr_t>(this->getRasterizer()) | reinterpret_cast<uintptr_t>(this->getPathEffect())) == 0; } @@ -454,8 +454,12 @@ public: } */ const SkRect& computeFastBounds(const SkRect& orig, SkRect* storage) const { - return this->getStyle() == kFill_Style ? orig : - this->computeStrokeFastBounds(orig, storage); + if (this->getStyle() == kFill_Style && + !this->getLooper() && !this->getMaskFilter()) { + return orig; + } + + return this->doComputeFastBounds(orig, storage); } /** Get the paint's shader object. @@ -864,8 +868,7 @@ private: void (*proc)(const SkDescriptor*, void*), void* context, bool ignoreGamma = false) const; - const SkRect& computeStrokeFastBounds(const SkRect& orig, - SkRect* storage) const; + const SkRect& doComputeFastBounds(const SkRect& orig, SkRect* storage) const; enum { kCanonicalTextSizeForPaths = 64 |