27dddae313
This reverts commit32a4910e57
. Reason for revert: SkMatrix::toString use has been removed from flutter and has been picked up in fuchsia Additionally some bookmaker changes take into account recent additions of typedef comments and the generated header comment. Original change's description: > Revert "remove toString" > > This reverts commit5191880cbf
. > > Reason for revert: broke flutter > > Original change's description: > > remove toString > > > > toString may have been used by obsolete debugger only > > find out if that is so > > > > R=​brianosman@google.com,bsalomon@google.com > > > > Docs-Preview: https://skia.org/?cl=119894 > > Bug:830651 > > Change-Id: I737f19b7d3fbc869bea2f443fa3b5ed7c1393ffd > > Reviewed-on: https://skia-review.googlesource.com/119894 > > Commit-Queue: Cary Clark <caryclark@google.com> > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > TBR=bsalomon@google.com,brianosman@google.com,caryclark@google.com,caryclark@skia.org > > Change-Id: I9f81de6c3615ee0608bcea9081b77239b4b8816c TBR=bsalomon@google.com,brianosman@google.com # Not skipping CQ checks because original CL landed > 1 day ago. Reviewed-on: https://skia-review.googlesource.com/129623 Reviewed-by: Cary Clark <caryclark@skia.org> Commit-Queue: Cary Clark <caryclark@google.com> Docs-Preview: https://skia.org/?cl=133583 Bug: 830651 Change-Id: If8499e796be63580ad419e150e94d43e8b89de1b Reviewed-on: https://skia-review.googlesource.com/133583 Commit-Queue: Cary Clark <caryclark@skia.org> Auto-Submit: Cary Clark <caryclark@skia.org>
129 lines
4.6 KiB
C++
129 lines
4.6 KiB
C++
|
|
/*
|
|
* Copyright 2011 The Android Open Source Project
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
|
|
#ifndef SkDrawLooper_DEFINED
|
|
#define SkDrawLooper_DEFINED
|
|
|
|
#include "SkBlurTypes.h"
|
|
#include "SkFlattenable.h"
|
|
#include "SkPoint.h"
|
|
#include "SkColor.h"
|
|
|
|
class SkArenaAlloc;
|
|
class SkCanvas;
|
|
class SkColorSpaceXformer;
|
|
class SkPaint;
|
|
struct SkRect;
|
|
class SkString;
|
|
|
|
/** \class SkDrawLooper
|
|
Subclasses of SkDrawLooper can be attached to a SkPaint. Where they are,
|
|
and something is drawn to a canvas with that paint, the looper subclass will
|
|
be called, allowing it to modify the canvas and/or paint for that draw call.
|
|
More than that, via the next() method, the looper can modify the draw to be
|
|
invoked multiple times (hence the name loop-er), allow it to perform effects
|
|
like shadows or frame/fills, that require more than one pass.
|
|
*/
|
|
class SK_API SkDrawLooper : public SkFlattenable {
|
|
public:
|
|
/**
|
|
* Holds state during a draw. Users call next() until it returns false.
|
|
*
|
|
* Subclasses of SkDrawLooper should create a subclass of this object to
|
|
* hold state specific to their subclass.
|
|
*/
|
|
class SK_API Context : ::SkNoncopyable {
|
|
public:
|
|
Context() {}
|
|
virtual ~Context() {}
|
|
|
|
/**
|
|
* Called in a loop on objects returned by SkDrawLooper::createContext().
|
|
* Each time true is returned, the object is drawn (possibly with a modified
|
|
* canvas and/or paint). When false is finally returned, drawing for the object
|
|
* stops.
|
|
*
|
|
* On each call, the paint will be in its original state, but the
|
|
* canvas will be as it was following the previous call to next() or
|
|
* createContext().
|
|
*
|
|
* The implementation must ensure that, when next() finally returns
|
|
* false, the canvas has been restored to the state it was
|
|
* initially, before createContext() was first called.
|
|
*/
|
|
virtual bool next(SkCanvas* canvas, SkPaint* paint) = 0;
|
|
};
|
|
|
|
/**
|
|
* Called right before something is being drawn. Returns a Context
|
|
* whose next() method should be called until it returns false.
|
|
*/
|
|
virtual Context* makeContext(SkCanvas*, SkArenaAlloc*) const = 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.
|
|
*/
|
|
bool canComputeFastBounds(const SkPaint& paint) const;
|
|
void computeFastBounds(const SkPaint& paint, const SkRect& src, SkRect* dst) const;
|
|
|
|
struct BlurShadowRec {
|
|
SkScalar fSigma;
|
|
SkVector fOffset;
|
|
SkColor fColor;
|
|
SkBlurStyle fStyle;
|
|
};
|
|
/**
|
|
* If this looper can be interpreted as having two layers, such that
|
|
* 1. The first layer (bottom most) just has a blur and translate
|
|
* 2. The second layer has no modifications to either paint or canvas
|
|
* 3. No other layers.
|
|
* then return true, and if not null, fill out the BlurShadowRec).
|
|
*
|
|
* If any of the above are not met, return false and ignore the BlurShadowRec parameter.
|
|
*/
|
|
virtual bool asABlurShadow(BlurShadowRec*) const;
|
|
|
|
static SkFlattenable::Type GetFlattenableType() {
|
|
return kSkDrawLooper_Type;
|
|
}
|
|
|
|
SkFlattenable::Type getFlattenableType() const override {
|
|
return kSkDrawLooper_Type;
|
|
}
|
|
|
|
static sk_sp<SkDrawLooper> Deserialize(const void* data, size_t size,
|
|
const SkDeserialProcs* procs = nullptr) {
|
|
return sk_sp<SkDrawLooper>(static_cast<SkDrawLooper*>(
|
|
SkFlattenable::Deserialize(
|
|
kSkDrawLooper_Type, data, size, procs).release()));
|
|
}
|
|
|
|
protected:
|
|
sk_sp<SkDrawLooper> makeColorSpace(SkColorSpaceXformer* xformer) const {
|
|
return this->onMakeColorSpace(xformer);
|
|
}
|
|
virtual sk_sp<SkDrawLooper> onMakeColorSpace(SkColorSpaceXformer*) const = 0;
|
|
|
|
SkDrawLooper() {}
|
|
|
|
private:
|
|
friend class SkColorSpaceXformer;
|
|
|
|
typedef SkFlattenable INHERITED;
|
|
};
|
|
|
|
#endif
|