Revert "remove toString"

This reverts commit 5191880cbf.

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
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 830651
Reviewed-on: https://skia-review.googlesource.com/129340
Reviewed-by: Cary Clark <caryclark@google.com>
Commit-Queue: Cary Clark <caryclark@google.com>
This commit is contained in:
Cary Clark 2018-05-20 23:15:43 +00:00 committed by Skia Commit-Bot
parent 5191880cbf
commit 32a4910e57
130 changed files with 1341 additions and 10 deletions

View File

@ -3438,6 +3438,38 @@ SK_DEBUG is defined at compile time.
# ------------------------------------------------------------------------------
#Method void toString(SkString* str) const;
#In Utility
#Line # converts Bitmap to machine readable form ##
Creates string representation of Bitmap. The representation is read by
internal debugging tools.
#Param str storage for string representation ##
#Example
SkBitmap bitmap;
int width = 6;
int height = 11;
bitmap.allocPixels(SkImageInfo::MakeN32Premul(width, height));
SkString string;
bitmap.toString(&string);
SkString match;
match.printf("(%d, %d)", width, height);
int start = string.find(match.c_str());
if (start >= 0) {
SkString whStr(&string.c_str()[start], match.size());
SkDebugf("bitmap dimensions %s\n", whStr.c_str());
}
#StdOut
bitmap dimensions (6, 11)
##
##
#SeeAlso SkPaint::toString
##
#Class SkBitmap ##
#Topic Bitmap ##

View File

@ -1749,6 +1749,39 @@ Returns nullptr if Image contents are not encoded.
#Line # rarely called management functions ##
##
#Method const char* toString(SkString* string) const
#In Utility
#Line # converts Image to machine readable form ##
Appends Image description to string, including unique ID, width, height, and
whether the image is opaque.
#Param string storage for description; existing content is preserved ##
#Return string appended with Image description ##
#Example
#Image 4
struct {
const char* name;
sk_sp<SkImage> image;
} tests[] = { { "image", image }, { "bitmap", SkImage::MakeFromBitmap(source) },
{ "texture", SkImage::MakeFromTexture(canvas->getGrContext(), backEndTexture,
kTopLeft_GrSurfaceOrigin, kN32_SkColorType, kOpaque_SkAlphaType,
nullptr) } };
SkString string;
SkPaint paint;
for (const auto& test : tests ) {
string.printf("%s: ", test.name);
test.image ? (void) test.image->toString(&string) : string.append("no image");
canvas->drawString(string, 10, 20, paint);
canvas->translate(0, 20);
}
##
#SeeAlso SkPaint::toString
#Method ##
# ------------------------------------------------------------------------------
#Method sk_sp<SkImage> makeSubset(const SkIRect& subset) const

View File

@ -4103,7 +4103,40 @@ matrix != nearlyEqual
##
##
#SeeAlso SkPath::dump
#SeeAlso toString
##
# ------------------------------------------------------------------------------
#Method void toString(SkString* str) const
#In Utility
#Line # converts Matrix to machine readable form ##
Creates string representation of Matrix. Floating point values
are written with limited precision; it may not be possible to reconstruct
original Matrix from output.
#Param str storage for string representation of Matrix ##
#Example
SkMatrix matrix;
matrix.setRotate(45);
SkString mStr, neStr;
matrix.toString(&mStr);
SkMatrix nearlyEqual;
nearlyEqual.setAll(0.7071f, -0.7071f, 0, 0.7071f, 0.7071f, 0, 0, 0, 1);
nearlyEqual.toString(&neStr);
SkDebugf("mStr %s\n", mStr.c_str());
SkDebugf("neStr %s\n", neStr.c_str());
SkDebugf("matrix %c= nearlyEqual\n", matrix == nearlyEqual ? '=' : '!');
#StdOut
mStr [ 0.7071 -0.7071 0.0000][ 0.7071 0.7071 0.0000][ 0.0000 0.0000 1.0000]
neStr [ 0.7071 -0.7071 0.0000][ 0.7071 0.7071 0.0000][ 0.0000 0.0000 1.0000]
matrix != nearlyEqual
##
##
#SeeAlso dump
##

View File

@ -5106,6 +5106,36 @@ Paint may draw to.
#Line # rarely called management functions ##
##
#Method void toString(SkString* str) const
#In Utility
#Line # converts Paint to machine readable form ##
Creates string representation of Paint. The representation is read by
internal debugging tools.
#Param str storage for string representation of Paint ##
#Example
SkPaint paint;
SkString str;
paint.toString(&str);
const char textSize[] = "TextSize:";
const int trailerSize = strlen("</dd><dt>");
int textSizeLoc = str.find(textSize) + strlen(textSize) + trailerSize;
const char* sizeStart = &str.c_str()[textSizeLoc];
int textSizeEnd = SkStrFind(sizeStart, "</dd>");
SkDebugf("text size = %.*s\n", textSizeEnd, sizeStart);
#StdOut
text size = 12
##
##
#SeeAlso SkPathEffect::toString SkMaskFilter::toString SkColorFilter::toString SkImageFilter::toString
##
# ------------------------------------------------------------------------------
#Class SkPaint ##

View File

@ -95,6 +95,8 @@ FT_Load_Glyph
#Topic Color_Filter
#Class SkColorFilter
#Method void toString(SkString* str) const
##
#Class ##
##
@ -287,6 +289,8 @@ FT_Load_Glyph
#Topic Image_Filter
#Class SkImageFilter
#Method void toString(SkString* str) const
##
#Class ##
#Topic ##
@ -325,6 +329,8 @@ FT_Load_Glyph
#Topic Mask_Filter
#Class SkMaskFilter
#Method void toString(SkString* str) const
##
#Class ##
#Topic ##
@ -434,6 +440,8 @@ FT_Load_Glyph
#Topic Path_Effect
#Class SkPathEffect
#Method void toString(SkString* str) const
##
#Class ##
#Topic ##

View File

@ -32,6 +32,7 @@ public:
return sk_sp<SkImageFilter>(new FailImageFilter);
}
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(FailImageFilter)
protected:
@ -56,6 +57,11 @@ sk_sp<SkFlattenable> FailImageFilter::CreateProc(SkReadBuffer& buffer) {
return FailImageFilter::Make();
}
void FailImageFilter::toString(SkString* str) const {
str->appendf("FailImageFilter: (");
str->append(")");
}
class IdentityImageFilter : public SkImageFilter {
public:
class Registrar {
@ -70,6 +76,7 @@ public:
return sk_sp<SkImageFilter>(new IdentityImageFilter(std::move(input)));
}
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(IdentityImageFilter)
protected:
@ -95,6 +102,11 @@ sk_sp<SkFlattenable> IdentityImageFilter::CreateProc(SkReadBuffer& buffer) {
return IdentityImageFilter::Make(common.getInput(0));
}
void IdentityImageFilter::toString(SkString* str) const {
str->appendf("IdentityImageFilter: (");
str->append(")");
}
///////////////////////////////////////////////////////////////////////////////
static void draw_paint(SkCanvas* canvas, const SkRect& r, sk_sp<SkImageFilter> imf) {

View File

@ -1246,6 +1246,13 @@ public:
bool allocPixelRef(SkBitmap* bitmap) override;
};
/** Creates string representation of SkBitmap. The representation is read by
internal debugging tools.
@param str storage for string representation
*/
void toString(SkString* str) const;
private:
enum Flags {
kImageIsVolatile_Flag = 0x02,

View File

@ -138,6 +138,8 @@ public:
return this->filterColor(SK_ColorTRANSPARENT) != SK_ColorTRANSPARENT;
}
virtual void toString(SkString* str) const = 0;
SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
SK_DEFINE_FLATTENABLE_TYPE(SkColorFilter)

View File

@ -96,6 +96,7 @@ public:
*/
virtual bool asABlurShadow(BlurShadowRec*) const;
virtual void toString(SkString* str) const = 0;
SK_DEFINE_FLATTENABLE_TYPE(SkDrawLooper)
protected:

View File

@ -727,6 +727,14 @@ public:
*/
sk_sp<SkData> refEncodedData() const;
/** Appends SkImage description to string, including unique ID, width, height, and
whether the image is opaque.
@param string storage for description; existing content is preserved
@return string appended with SkImage description
*/
const char* toString(SkString* string) const;
/** Returns subset of SkImage. subset must be fully contained by SkImage dimensions().
The implementation may share pixels, or may copy them.

View File

@ -97,6 +97,7 @@ public:
: fRect(rect), fFlags(flags) {}
uint32_t flags() const { return fFlags; }
const SkRect& rect() const { return fRect; }
void toString(SkString* str) const;
/**
* Apply this cropRect to the imageBounds. If a given edge of the cropRect is not
@ -248,8 +249,7 @@ public:
SkFilterQuality quality,
sk_sp<SkImageFilter> input);
// Deprecated; used only by chrome
virtual void toString(SkString* ) const {}
virtual void toString(SkString* str) const = 0;
SK_DEFINE_FLATTENABLE_TYPE(SkImageFilter)
SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()

View File

@ -59,6 +59,7 @@ public:
*/
sk_sp<SkMaskFilter> makeWithMatrix(const SkMatrix&) const;
virtual void toString(SkString* str) const = 0;
SK_DEFINE_FLATTENABLE_TYPE(SkMaskFilter)
private:

View File

@ -1575,6 +1575,14 @@ public:
*/
void dump() const;
/** Creates string representation of SkMatrix. Floating point values
are written with limited precision; it may not be possible to reconstruct
original SkMatrix from output.
@param str storage for string representation of SkMatrix
*/
void toString(SkString* str) const;
/** Returns the minimum scaling factor of SkMatrix by decomposing the scaling and
skewing elements.
Returns -1 if scale factor overflows or SkMatrix contains perspective.

View File

@ -1598,6 +1598,13 @@ public:
const SkRect& doComputeFastBounds(const SkRect& orig, SkRect* storage,
Style style) const;
/** Creates string representation of SkPaint. The representation is read by
internal debugging tools.
@param str storage for string representation of SkPaint
*/
void toString(SkString* str) const;
private:
typedef const SkGlyph& (*GlyphCacheProc)(SkGlyphCache*, const char**);

View File

@ -145,6 +145,7 @@ public:
virtual DashType asADash(DashInfo* info) const;
virtual void toString(SkString* str) const = 0;
SK_DEFINE_FLATTENABLE_TYPE(SkPathEffect)
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK

View File

@ -61,6 +61,7 @@ public:
virtual bool filterPath(SkPath*, const SkPath&,
SkStrokeRec*, const SkRect*) const override;
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath1DPathEffect)
protected:

View File

@ -39,6 +39,8 @@ protected:
explicit Sk2DPathEffect(const SkMatrix& mat);
void flatten(SkWriteBuffer&) const override;
void toString(SkString* str) const override;
private:
SkMatrix fMatrix, fInverse;
bool fMatrixIsInvertible;
@ -63,6 +65,7 @@ public:
virtual bool filterPath(SkPath* dst, const SkPath& src,
SkStrokeRec*, const SkRect*) const override;
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLine2DPathEffect)
protected:
@ -90,6 +93,7 @@ public:
return sk_sp<SkPathEffect>(new SkPath2DPathEffect(matrix, path));
}
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath2DPathEffect)
protected:

View File

@ -18,6 +18,7 @@ public:
sk_sp<SkImageFilter> input,
const CropRect* cropRect = nullptr);
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorFilterImageFilter)
protected:

View File

@ -16,6 +16,7 @@ public:
SkRect computeFastBounds(const SkRect& src) const override;
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeImageFilter)
protected:

View File

@ -27,6 +27,7 @@ public:
virtual bool filterPath(SkPath* dst, const SkPath& src,
SkStrokeRec*, const SkRect*) const override;
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkCornerPathEffect)
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK

View File

@ -34,6 +34,7 @@ public:
virtual bool filterPath(SkPath* dst, const SkPath& src,
SkStrokeRec*, const SkRect*) const override;
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDiscretePathEffect)
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK

View File

@ -41,6 +41,8 @@ public:
SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix& ctm,
MapDirection, const SkIRect* inputRect) const override;
void toString(SkString* str) const override;
protected:
sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
SkIPoint* offset) const override;

View File

@ -29,6 +29,7 @@ public:
const CropRect* cropRect = nullptr);
SkRect computeFastBounds(const SkRect&) const override;
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDropShadowImageFilter)
protected:

View File

@ -21,6 +21,7 @@ public:
SkRect computeFastBounds(const SkRect& src) const override;
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkImageSource)
protected:

View File

@ -75,6 +75,8 @@ public:
bool asABlurShadow(BlurShadowRec* rec) const override;
void toString(SkString* str) const override;
Factory getFactory() const override { return CreateProc; }
static sk_sp<SkFlattenable> CreateProc(SkReadBuffer& buffer);

View File

@ -33,6 +33,7 @@ public:
GrContext*, const GrColorSpaceInfo&) const override;
#endif
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLumaColorFilter)
protected:

View File

@ -18,6 +18,7 @@ public:
sk_sp<SkImageFilter> input,
const CropRect* cropRect = nullptr);
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMagnifierImageFilter)
protected:

View File

@ -67,6 +67,7 @@ public:
sk_sp<SkImageFilter> input,
const CropRect* cropRect = nullptr);
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMatrixConvolutionImageFilter)
protected:

View File

@ -24,6 +24,7 @@ public:
return Make(array, 2, cropRect);
}
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMergeImageFilter)
protected:

View File

@ -61,6 +61,7 @@ public:
sk_sp<SkImageFilter> input,
const CropRect* cropRect = nullptr);
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDilateImageFilter)
protected:
@ -82,6 +83,7 @@ public:
sk_sp<SkImageFilter> input,
const CropRect* cropRect = nullptr);
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkErodeImageFilter)
protected:

View File

@ -19,6 +19,7 @@ public:
SkRect computeFastBounds(const SkRect& src) const override;
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkOffsetImageFilter)
protected:

View File

@ -32,6 +32,8 @@ public:
GrContext*, const GrColorSpaceInfo&) const override;
#endif
void toString(SkString* str) const override;
static sk_sp<SkFlattenable> CreateProc(SkReadBuffer& buffer);
Factory getFactory() const override { return CreateProc; }
SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()

View File

@ -26,6 +26,7 @@ public:
bool affectsTransparentBlack() const override;
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPaintImageFilter)
protected:

View File

@ -24,6 +24,7 @@ public:
*/
static sk_sp<SkImageFilter> Make(sk_sp<SkPicture> picture, const SkRect& cropRect);
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureImageFilter)
protected:

View File

@ -27,6 +27,7 @@ public:
MapDirection, const SkIRect* inputRect) const override;
SkRect computeFastBounds(const SkRect& src) const override;
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTileImageFilter)
protected:

View File

@ -26,6 +26,7 @@ public:
GrContext*, const GrColorSpaceInfo&) const override;
#endif
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkToSRGBColorFilter)
private:

View File

@ -85,6 +85,10 @@ public:
return true;
}
void toString(SkString* str) const override {
str->appendf("InverseFillPE: ()");
}
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(InverseFillPE)
private:

View File

@ -633,6 +633,33 @@ void SkBitmap::validate() const {
}
#endif
#include "SkString.h"
void SkBitmap::toString(SkString* str) const {
static const char* gColorTypeNames[kLastEnum_SkColorType + 1] = {
"UNKNOWN", "A8", "565", "4444", "RGBA", "BGRA", "INDEX8",
};
str->appendf("bitmap: ((%d, %d) %s", this->width(), this->height(),
gColorTypeNames[this->colorType()]);
str->append(" (");
if (this->isOpaque()) {
str->append("opaque");
} else {
str->append("transparent");
}
if (this->isImmutable()) {
str->append(", immutable");
} else {
str->append(", not-immutable");
}
str->append(")");
str->appendf(" pixelref:%p", this->pixelRef());
str->append(")");
}
///////////////////////////////////////////////////////////////////////////////
bool SkBitmap::peekPixels(SkPixmap* pmap) const {

View File

@ -861,6 +861,19 @@ public:
typedef Context INHERITED;
};
void toString(SkString* str) const override {
str->append("Sk3DShader: (");
if (fProxy) {
str->append("Proxy: ");
as_SB(fProxy)->toString(str);
}
this->INHERITED::toString(str);
str->append(")");
}
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Sk3DShader)
protected:

View File

@ -41,6 +41,7 @@ public:
SkRect computeFastBounds(const SkRect&) const override;
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurImageFilterImpl)
protected:
@ -696,3 +697,15 @@ SkIRect SkBlurImageFilterImpl::onFilterNodeBounds(const SkIRect& src, const SkMa
SkVector sigma = map_sigma(fSigma, ctm);
return src.makeOutset(SkScalarCeilToInt(sigma.x() * 3), SkScalarCeilToInt(sigma.y() * 3));
}
void SkBlurImageFilterImpl::toString(SkString* str) const {
str->appendf("SkBlurImageFilterImpl: (");
str->appendf("sigma: (%f, %f) tileMode: %d input (", fSigma.fWidth, fSigma.fHeight,
static_cast<int>(fTileMode));
if (this->getInput(0)) {
this->getInput(0)->toString(str);
}
str->append("))");
}

View File

@ -77,6 +77,7 @@ public:
void computeFastBounds(const SkRect&, SkRect*) const override;
bool asABlur(BlurRec*) const override;
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurMaskFilterImpl)
protected:
@ -991,6 +992,23 @@ sk_sp<GrTextureProxy> SkBlurMaskFilterImpl::filterMaskGPU(GrContext* context,
#endif // SK_SUPPORT_GPU
void SkBlurMaskFilterImpl::toString(SkString* str) const {
str->append("SkBlurMaskFilterImpl: (");
str->append("sigma: ");
str->appendScalar(fSigma);
str->append(" ");
static const char* gStyleName[kLastEnum_SkBlurStyle + 1] = {
"normal", "solid", "outer", "inner"
};
str->appendf("style: %s ", gStyleName[fBlurStyle]);
str->appendf("respectCTM: %s ", fRespectCTM ? "true" : "false");
str->append(")");
}
void sk_register_blur_maskfilter_createproc() {
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl)
}

View File

@ -98,6 +98,15 @@ public:
return fOuter->getFlags() & fInner->getFlags();
}
void toString(SkString* str) const override {
SkString outerS, innerS;
fOuter->toString(&outerS);
fInner->toString(&innerS);
// These strings can be long. SkString::appendf has limitations.
str->append(SkStringPrintf("SkComposeColorFilter: outer(%s) inner(%s)", outerS.c_str(),
innerS.c_str()));
}
void onAppendStages(SkRasterPipeline* p, SkColorSpace* dst, SkArenaAlloc* scratch,
bool shaderIsOpaque) const override {
bool innerIsOpaque = shaderIsOpaque;
@ -216,6 +225,8 @@ public:
}
#endif
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSRGBGammaColorFilter)
void onAppendStages(SkRasterPipeline* p, SkColorSpace*, SkArenaAlloc* alloc,
@ -256,6 +267,10 @@ sk_sp<SkFlattenable> SkSRGBGammaColorFilter::CreateProc(SkReadBuffer& buffer) {
return sk_sp<SkFlattenable>(new SkSRGBGammaColorFilter(static_cast<Direction>(dir)));
}
void SkSRGBGammaColorFilter::toString(SkString* str) const {
str->append("srgbgamma");
}
template <SkSRGBGammaColorFilter::Direction dir>
sk_sp<SkColorFilter> MakeSRGBGammaCF() {
static SkColorFilter* gSingleton = new SkSRGBGammaColorFilter(dir);

View File

@ -299,6 +299,19 @@ std::unique_ptr<GrFragmentProcessor> SkColorMatrixFilterRowMajor255::asFragmentP
#endif
void SkColorMatrixFilterRowMajor255::toString(SkString* str) const {
str->append("SkColorMatrixFilterRowMajor255: ");
str->append("matrix: (");
for (int i = 0; i < 20; ++i) {
str->appendScalar(fMatrix[i]);
if (i < 19) {
str->append(", ");
}
}
str->append(")");
}
///////////////////////////////////////////////////////////////////////////////
sk_sp<SkColorFilter> SkColorFilter::MakeMatrixFilterRowMajor255(const SkScalar array[20]) {

View File

@ -27,6 +27,8 @@ public:
GrContext*, const GrColorSpaceInfo&) const override;
#endif
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorMatrixFilter)
protected:

View File

@ -77,6 +77,8 @@ public:
bool isOpaque() const override { return fIsOpaque; }
void toString(SkString* str) const override;
// For serialization. This will never be called.
Factory getFactory() const override { SK_ABORT("not reached"); return nullptr; }
@ -97,6 +99,14 @@ private:
typedef SkShaderBase INHERITED;
};
void SkTriColorShader::toString(SkString* str) const {
str->append("SkTriColorShader: (");
this->INHERITED::toString(str);
str->append(")");
}
static bool SK_WARN_UNUSED_RESULT
update_tricolor_matrix(const SkMatrix& ctmInv, const SkPoint pts[], const SkPM4f colors[],
int index0, int index1, int index2, Matrix43* result) {

View File

@ -28,6 +28,35 @@
#include "SkGr.h"
#endif
void SkImageFilter::CropRect::toString(SkString* str) const {
if (!fFlags) {
return;
}
str->appendf("cropRect (");
if (fFlags & CropRect::kHasLeft_CropEdge) {
str->appendf("%.2f, ", fRect.fLeft);
} else {
str->appendf("X, ");
}
if (fFlags & CropRect::kHasTop_CropEdge) {
str->appendf("%.2f, ", fRect.fTop);
} else {
str->appendf("X, ");
}
if (fFlags & CropRect::kHasWidth_CropEdge) {
str->appendf("%.2f, ", fRect.width());
} else {
str->appendf("X, ");
}
if (fFlags & CropRect::kHasHeight_CropEdge) {
str->appendf("%.2f", fRect.height());
} else {
str->appendf("X");
}
str->appendf(") ");
}
void SkImageFilter::CropRect::applyTo(const SkIRect& imageBounds,
const SkMatrix& ctm,
bool embiggen,

View File

@ -67,3 +67,8 @@ const {
}
return this->refMe();
}
void SkLocalMatrixImageFilter::toString(SkString* str) const {
str->append("SkLocalMatrixImageFilter: (");
str->append(")");
}

View File

@ -18,6 +18,7 @@ class SkLocalMatrixImageFilter : public SkImageFilter {
public:
static sk_sp<SkImageFilter> Make(const SkMatrix& localM, sk_sp<SkImageFilter> input);
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLocalMatrixImageFilter)
protected:

View File

@ -405,6 +405,7 @@ public:
}
SkMask::Format getFormat() const override { return SkMask::kA8_Format; }
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeMF)
protected:
@ -469,6 +470,10 @@ sk_sp<SkFlattenable> SkComposeMF::CreateProc(SkReadBuffer& buffer) {
return SkMaskFilter::MakeCompose(std::move(outer), std::move(inner));
}
void SkComposeMF::toString(SkString* str) const {
str->set("SkComposeMF:");
}
///////////////////////////////////////////////////////////////////////////////////////////////////
class SkCombineMF : public SkMaskFilterBase {
@ -493,6 +498,7 @@ public:
SkMask::Format getFormat() const override { return SkMask::kA8_Format; }
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkCombineMF)
protected:
@ -619,6 +625,10 @@ sk_sp<SkFlattenable> SkCombineMF::CreateProc(SkReadBuffer& buffer) {
return SkMaskFilter::MakeCombine(std::move(dst), std::move(src), mode);
}
void SkCombineMF::toString(SkString* str) const {
str->set("SkCombineMF:");
}
///////////////////////////////////////////////////////////////////////////////////////////////////
class SkMatrixMF : public SkMaskFilterBase {
@ -642,6 +652,10 @@ public:
SkMask::Format getFormat() const override { return as_MFB(fFilter)->getFormat(); }
void toString(SkString* str) const override {
str->set("SkMatrixMF:");
}
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLocalMatrixMF)
protected:

View File

@ -1659,10 +1659,14 @@ size_t SkMatrix::readFromMemory(const void* buffer, size_t length) {
void SkMatrix::dump() const {
SkString str;
str.appendf("[%8.4f %8.4f %8.4f][%8.4f %8.4f %8.4f][%8.4f %8.4f %8.4f]",
this->toString(&str);
SkDebugf("%s\n", str.c_str());
}
void SkMatrix::toString(SkString* str) const {
str->appendf("[%8.4f %8.4f %8.4f][%8.4f %8.4f %8.4f][%8.4f %8.4f %8.4f]",
fMat[0], fMat[1], fMat[2], fMat[3], fMat[4], fMat[5],
fMat[6], fMat[7], fMat[8]);
SkDebugf("%s\n", str.c_str());
}
///////////////////////////////////////////////////////////////////////////////

View File

@ -143,3 +143,25 @@ SkIRect SkMatrixImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatr
return result;
}
void SkMatrixImageFilter::toString(SkString* str) const {
str->appendf("SkMatrixImageFilter: (");
str->appendf("transform: (%f %f %f %f %f %f %f %f %f)",
fTransform[SkMatrix::kMScaleX],
fTransform[SkMatrix::kMSkewX],
fTransform[SkMatrix::kMTransX],
fTransform[SkMatrix::kMSkewY],
fTransform[SkMatrix::kMScaleY],
fTransform[SkMatrix::kMTransY],
fTransform[SkMatrix::kMPersp0],
fTransform[SkMatrix::kMPersp1],
fTransform[SkMatrix::kMPersp2]);
str->append("<dt>FilterLevel:</dt><dd>");
static const char* gFilterLevelStrings[] = { "None", "Low", "Medium", "High" };
str->append(gFilterLevelStrings[fFilterQuality]);
str->append("</dd>");
str->appendf(")");
}

View File

@ -31,6 +31,7 @@ public:
SkRect computeFastBounds(const SkRect&) const override;
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMatrixImageFilter)
protected:

View File

@ -31,6 +31,13 @@ SkModeColorFilter::SkModeColorFilter(SkColor color, SkBlendMode mode) {
fPMColor = SkPreMultiplyColor(fColor);
}
void SkModeColorFilter::toString(SkString* str) const {
str->append("SkModeColorFilter: color: 0x");
str->appendHex(fColor);
str->append(" mode: ");
str->append(SkBlendMode_Name(fMode));
}
bool SkModeColorFilter::asColorMode(SkColor* color, SkBlendMode* mode) const {
if (color) {
*color = fColor;

View File

@ -22,6 +22,8 @@ public:
bool asColorMode(SkColor*, SkBlendMode*) const override;
uint32_t getFlags() const override;
void toString(SkString* str) const override;
#if SK_SUPPORT_GPU
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(
GrContext*, const GrColorSpaceInfo&) const override;

View File

@ -1384,6 +1384,155 @@ const SkRect& SkPaint::doComputeFastBounds(const SkRect& origSrc,
return *storage;
}
void SkPaint::toString(SkString* str) const {
str->append("<dl><dt>SkPaint:</dt><dd><dl>");
SkTypeface* typeface = this->getTypeface();
if (typeface) {
SkDynamicMemoryWStream ostream;
typeface->serialize(&ostream);
std::unique_ptr<SkStreamAsset> istream(ostream.detachAsStream());
SkFontDescriptor descriptor;
if (!SkFontDescriptor::Deserialize(istream.get(), &descriptor)) {
str->append("<dt>FontDescriptor deserialization failed</dt>");
} else {
str->append("<dt>Font Family Name:</dt><dd>");
str->append(descriptor.getFamilyName());
str->append("</dd><dt>Font Full Name:</dt><dd>");
str->append(descriptor.getFullName());
str->append("</dd><dt>Font PS Name:</dt><dd>");
str->append(descriptor.getPostscriptName());
str->append("</dd>");
}
}
str->append("<dt>TextSize:</dt><dd>");
str->appendScalar(this->getTextSize());
str->append("</dd>");
str->append("<dt>TextScaleX:</dt><dd>");
str->appendScalar(this->getTextScaleX());
str->append("</dd>");
str->append("<dt>TextSkewX:</dt><dd>");
str->appendScalar(this->getTextSkewX());
str->append("</dd>");
SkPathEffect* pathEffect = this->getPathEffect();
if (pathEffect) {
str->append("<dt>PathEffect:</dt><dd>");
pathEffect->toString(str);
str->append("</dd>");
}
if (const auto* shader = as_SB(this->getShader())) {
str->append("<dt>Shader:</dt><dd>");
shader->toString(str);
str->append("</dd>");
}
if (!this->isSrcOver()) {
str->appendf("<dt>Xfermode:</dt><dd>%d</dd>", fBlendMode);
}
SkMaskFilter* maskFilter = this->getMaskFilter();
if (maskFilter) {
str->append("<dt>MaskFilter:</dt><dd>");
as_MFB(maskFilter)->toString(str);
str->append("</dd>");
}
SkColorFilter* colorFilter = this->getColorFilter();
if (colorFilter) {
str->append("<dt>ColorFilter:</dt><dd>");
colorFilter->toString(str);
str->append("</dd>");
}
SkDrawLooper* looper = this->getLooper();
if (looper) {
str->append("<dt>DrawLooper:</dt><dd>");
looper->toString(str);
str->append("</dd>");
}
SkImageFilter* imageFilter = this->getImageFilter();
if (imageFilter) {
str->append("<dt>ImageFilter:</dt><dd>");
imageFilter->toString(str);
str->append("</dd>");
}
str->append("<dt>Color:</dt><dd>0x");
SkColor color = this->getColor();
str->appendHex(color);
str->append("</dd>");
str->append("<dt>Stroke Width:</dt><dd>");
str->appendScalar(this->getStrokeWidth());
str->append("</dd>");
str->append("<dt>Stroke Miter:</dt><dd>");
str->appendScalar(this->getStrokeMiter());
str->append("</dd>");
str->append("<dt>Flags:</dt><dd>(");
if (this->getFlags()) {
bool needSeparator = false;
SkAddFlagToString(str, this->isAntiAlias(), "AntiAlias", &needSeparator);
SkAddFlagToString(str, this->isDither(), "Dither", &needSeparator);
SkAddFlagToString(str, this->isFakeBoldText(), "FakeBoldText", &needSeparator);
SkAddFlagToString(str, this->isLinearText(), "LinearText", &needSeparator);
SkAddFlagToString(str, this->isSubpixelText(), "SubpixelText", &needSeparator);
SkAddFlagToString(str, this->isLCDRenderText(), "LCDRenderText", &needSeparator);
SkAddFlagToString(str, this->isEmbeddedBitmapText(),
"EmbeddedBitmapText", &needSeparator);
SkAddFlagToString(str, this->isAutohinted(), "Autohinted", &needSeparator);
SkAddFlagToString(str, this->isVerticalText(), "VerticalText", &needSeparator);
} else {
str->append("None");
}
str->append(")</dd>");
str->append("<dt>FilterLevel:</dt><dd>");
static const char* gFilterQualityStrings[] = { "None", "Low", "Medium", "High" };
str->append(gFilterQualityStrings[this->getFilterQuality()]);
str->append("</dd>");
str->append("<dt>TextAlign:</dt><dd>");
static const char* gTextAlignStrings[SkPaint::kAlignCount] = { "Left", "Center", "Right" };
str->append(gTextAlignStrings[this->getTextAlign()]);
str->append("</dd>");
str->append("<dt>CapType:</dt><dd>");
static const char* gStrokeCapStrings[SkPaint::kCapCount] = { "Butt", "Round", "Square" };
str->append(gStrokeCapStrings[this->getStrokeCap()]);
str->append("</dd>");
str->append("<dt>JoinType:</dt><dd>");
static const char* gJoinStrings[SkPaint::kJoinCount] = { "Miter", "Round", "Bevel" };
str->append(gJoinStrings[this->getStrokeJoin()]);
str->append("</dd>");
str->append("<dt>Style:</dt><dd>");
static const char* gStyleStrings[SkPaint::kStyleCount] = { "Fill", "Stroke", "StrokeAndFill" };
str->append(gStyleStrings[this->getStyle()]);
str->append("</dd>");
str->append("<dt>TextEncoding:</dt><dd>");
static const char* gTextEncodingStrings[] = { "UTF8", "UTF16", "UTF32", "GlyphID" };
str->append(gTextEncodingStrings[this->getTextEncoding()]);
str->append("</dd>");
str->append("<dt>Hinting:</dt><dd>");
static const char* gHintingStrings[] = { "None", "Slight", "Normal", "Full" };
str->append(gHintingStrings[this->getHinting()]);
str->append("</dd>");
str->append("</dd></dl></dl>");
}
///////////////////////////////////////////////////////////////////////////////
static bool has_thick_frame(const SkPaint& paint) {

View File

@ -51,10 +51,23 @@ protected:
sk_sp<SkPathEffect> fPE0;
sk_sp<SkPathEffect> fPE1;
void toString(SkString* str) const override;
private:
typedef SkPathEffect INHERITED;
};
void SkPairPathEffect::toString(SkString* str) const {
str->appendf("first: ");
if (fPE0) {
fPE0->toString(str);
}
str->appendf(" second: ");
if (fPE1) {
fPE1->toString(str);
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////
/** \class SkComposePathEffect
@ -91,6 +104,7 @@ public:
}
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposePathEffect)
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
@ -116,6 +130,12 @@ sk_sp<SkFlattenable> SkComposePathEffect::CreateProc(SkReadBuffer& buffer) {
return SkComposePathEffect::Make(std::move(pe0), std::move(pe1));
}
void SkComposePathEffect::toString(SkString* str) const {
str->appendf("SkComposePathEffect: (");
this->INHERITED::toString(str);
str->appendf(")");
}
///////////////////////////////////////////////////////////////////////////////
/** \class SkSumPathEffect
@ -148,6 +168,7 @@ public:
}
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSumPathEffect)
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
@ -173,6 +194,12 @@ sk_sp<SkFlattenable> SkSumPathEffect::CreateProc(SkReadBuffer& buffer) {
return SkSumPathEffect::Make(pe0, pe1);
}
void SkSumPathEffect::toString(SkString* str) const {
str->appendf("SkSumPathEffect: (");
this->INHERITED::toString(str);
str->appendf(")");
}
///////////////////////////////////////////////////////////////////////////////////////////////////
sk_sp<SkPathEffect> SkPathEffect::MakeSum(sk_sp<SkPathEffect> first, sk_sp<SkPathEffect> second) {

View File

@ -9,6 +9,16 @@
#include "SkStringUtils.h"
#include "SkUtils.h"
void SkAddFlagToString(SkString* string, bool flag, const char* flagStr, bool* needSeparator) {
if (flag) {
if (*needSeparator) {
string->append("|");
}
string->append(flagStr);
*needSeparator = true;
}
}
void SkAppendScalar(SkString* str, SkScalar value, SkScalarAsStringType asType) {
switch (asType) {
case kHex_SkScalarAsStringType:

View File

@ -12,6 +12,16 @@
class SkString;
/**
* Add 'flagStr' to 'string' and set 'needSeparator' to true only if 'flag' is
* true. If 'needSeparator' is true append a '|' before 'flagStr'. This method
* is used to streamline the creation of ASCII flag strings within the toString
* methods.
*/
void SkAddFlagToString(SkString* string, bool flag,
const char* flagStr, bool* needSeparator);
enum SkScalarAsStringType {
kDec_SkScalarAsStringType,
kHex_SkScalarAsStringType,

View File

@ -194,6 +194,14 @@ SkScalar SkPath1DPathEffect::next(SkPath* dst, SkScalar distance,
return fAdvance;
}
void SkPath1DPathEffect::toString(SkString* str) const {
str->appendf("SkPath1DPathEffect: (");
// TODO: add path and style
str->appendf("advance: %.2f phase %.2f", fAdvance, fInitialOffset);
str->appendf(")");
}
///////////////////////////////////////////////////////////////////////////////////////////////////
sk_sp<SkPathEffect> SkPath1DPathEffect::Make(const SkPath& path, SkScalar advance, SkScalar phase,

View File

@ -74,6 +74,13 @@ void Sk2DPathEffect::flatten(SkWriteBuffer& buffer) const {
buffer.writeMatrix(fMatrix);
}
void Sk2DPathEffect::toString(SkString* str) const {
str->appendf("(matrix: %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f)",
fMatrix[SkMatrix::kMScaleX], fMatrix[SkMatrix::kMSkewX], fMatrix[SkMatrix::kMTransX],
fMatrix[SkMatrix::kMSkewY], fMatrix[SkMatrix::kMScaleY], fMatrix[SkMatrix::kMTransY],
fMatrix[SkMatrix::kMPersp0], fMatrix[SkMatrix::kMPersp1], fMatrix[SkMatrix::kMPersp2]);
}
///////////////////////////////////////////////////////////////////////////////
bool SkLine2DPathEffect::filterPath(SkPath* dst, const SkPath& src,
@ -110,6 +117,14 @@ void SkLine2DPathEffect::flatten(SkWriteBuffer &buffer) const {
buffer.writeScalar(fWidth);
}
void SkLine2DPathEffect::toString(SkString* str) const {
str->appendf("SkLine2DPathEffect: (");
this->INHERITED::toString(str);
str->appendf("width: %f", fWidth);
str->appendf(")");
}
///////////////////////////////////////////////////////////////////////////////
SkPath2DPathEffect::SkPath2DPathEffect(const SkMatrix& m, const SkPath& p)
@ -133,3 +148,11 @@ void SkPath2DPathEffect::next(const SkPoint& loc, int u, int v,
SkPath* dst) const {
dst->addPath(fPath, loc.fX, loc.fY);
}
void SkPath2DPathEffect::toString(SkString* str) const {
str->appendf("SkPath2DPathEffect: (");
this->INHERITED::toString(str);
// TODO: print out path information
str->appendf(")");
}

View File

@ -31,6 +31,7 @@ public:
SkScalar outerThreshold, sk_sp<SkImageFilter> input,
const CropRect* cropRect = nullptr);
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkAlphaThresholdFilterImpl)
friend void SkAlphaThresholdFilter::InitializeFlattenables();
@ -280,3 +281,10 @@ const {
}
return this->refMe();
}
void SkAlphaThresholdFilterImpl::toString(SkString* str) const {
str->appendf("SkAlphaThresholdImageFilter: (");
str->appendf("inner: %f outer: %f", fInnerThreshold, fOuterThreshold);
str->append(")");
}

View File

@ -37,6 +37,7 @@ public:
sk_sp<SkImageFilter> inputs[2], const CropRect* cropRect)
: INHERITED(inputs, 2, cropRect), fK{k1, k2, k3, k4}, fEnforcePMColor(enforcePMColor) {}
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(ArithmeticImageFilterImpl)
protected:
@ -431,6 +432,22 @@ const {
return this->refMe();
}
void ArithmeticImageFilterImpl::toString(SkString* str) const {
str->appendf("SkArithmeticImageFilter: (");
str->appendf("K[]: (%f %f %f %f)", fK[0], fK[1], fK[2], fK[3]);
if (this->getInput(0)) {
str->appendf("foreground: (");
this->getInput(0)->toString(str);
str->appendf(")");
}
if (this->getInput(1)) {
str->appendf("background: (");
this->getInput(1)->toString(str);
str->appendf(")");
}
str->append(")");
}
sk_sp<SkImageFilter> SkArithmeticImageFilter::Make(float k1, float k2, float k3, float k4,
bool enforcePMColor,
sk_sp<SkImageFilter> background,

View File

@ -144,3 +144,18 @@ bool SkColorFilterImageFilter::onIsColorFilterNode(SkColorFilter** filter) const
bool SkColorFilterImageFilter::affectsTransparentBlack() const {
return fColorFilter->affectsTransparentBlack();
}
void SkColorFilterImageFilter::toString(SkString* str) const {
str->appendf("SkColorFilterImageFilter: (");
str->appendf("input: (");
if (this->getInput(0)) {
this->getInput(0)->toString(str);
}
str->appendf(") color filter: ");
fColorFilter->toString(str);
str->append(")");
}

View File

@ -72,6 +72,8 @@ public:
}
#endif
void toString(SkString* str) const override { fMatrixFilter->toString(str); }
private:
SkColor fMul, fAdd;
sk_sp<SkColorFilter> fMatrixFilter;

View File

@ -88,3 +88,17 @@ sk_sp<SkFlattenable> SkComposeImageFilter::CreateProc(SkReadBuffer& buffer) {
return SkComposeImageFilter::Make(common.getInput(0), common.getInput(1));
}
void SkComposeImageFilter::toString(SkString* str) const {
SkImageFilter* outer = getInput(0);
SkImageFilter* inner = getInput(1);
str->appendf("SkComposeImageFilter: (");
str->appendf("outer: ");
outer->toString(str);
str->appendf("inner: ");
inner->toString(str);
str->appendf(")");
}

View File

@ -151,3 +151,9 @@ sk_sp<SkFlattenable> SkCornerPathEffect::CreateProc(SkReadBuffer& buffer) {
void SkCornerPathEffect::flatten(SkWriteBuffer& buffer) const {
buffer.writeScalar(fRadius);
}
void SkCornerPathEffect::toString(SkString* str) const {
str->appendf("SkCornerPathEffect: (");
str->appendf("radius: %.2f", fRadius);
str->appendf(")");
}

View File

@ -21,6 +21,7 @@ public:
DashType asADash(DashInfo* info) const override;
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDashImpl)
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK

View File

@ -380,6 +380,18 @@ sk_sp<SkFlattenable> SkDashImpl::CreateProc(SkReadBuffer& buffer) {
return nullptr;
}
void SkDashImpl::toString(SkString* str) const {
str->appendf("SkDashPathEffect: (");
str->appendf("count: %d phase %.2f intervals: (", fCount, fPhase);
for (int i = 0; i < fCount; ++i) {
str->appendf("%.2f", fIntervals[i]);
if (i < fCount-1) {
str->appendf(", ");
}
}
str->appendf("))");
}
//////////////////////////////////////////////////////////////////////////////////////////////////
sk_sp<SkPathEffect> SkDashPathEffect::Make(const SkScalar intervals[], int count, SkScalar phase) {

View File

@ -143,3 +143,9 @@ void SkDiscretePathEffect::flatten(SkWriteBuffer& buffer) const {
buffer.writeScalar(fPerterb);
buffer.writeUInt(fSeedAssist);
}
void SkDiscretePathEffect::toString(SkString* str) const {
str->appendf("SkDiscretePathEffect: (");
str->appendf("segLength: %.2f deviation: %.2f seed %d", fSegLength, fPerterb, fSeedAssist);
str->append(")");
}

View File

@ -404,6 +404,20 @@ SkIRect SkDisplacementMapEffect::onFilterBounds(const SkIRect& src, const SkMatr
return src;
}
void SkDisplacementMapEffect::toString(SkString* str) const {
str->appendf("SkDisplacementMapEffect: (");
str->appendf("scale: %f ", fScale);
str->appendf("displacement: (");
if (this->getDisplacementInput()) {
this->getDisplacementInput()->toString(str);
}
str->appendf(") color: (");
if (this->getColorInput()) {
this->getColorInput()->toString(str);
}
str->appendf("))");
}
///////////////////////////////////////////////////////////////////////////////
#if SK_SUPPORT_GPU

View File

@ -159,3 +159,24 @@ SkIRect SkDropShadowImageFilter::onFilterNodeBounds(const SkIRect& src, const Sk
return dst;
}
void SkDropShadowImageFilter::toString(SkString* str) const {
str->appendf("SkDropShadowImageFilter: (");
str->appendf("dX: %f ", fDx);
str->appendf("dY: %f ", fDy);
str->appendf("sigmaX: %f ", fSigmaX);
str->appendf("sigmaY: %f ", fSigmaY);
str->append("Color: ");
str->appendHex(fColor);
static const char* gModeStrings[] = {
"kDrawShadowAndForeground", "kDrawShadowOnly"
};
static_assert(kShadowModeCount == SK_ARRAY_COUNT(gModeStrings), "enum_mismatch");
str->appendf(" mode: %s", gModeStrings[fShadowMode]);
str->append(")");
}

View File

@ -140,3 +140,22 @@ void SkEmbossMaskFilter::flatten(SkWriteBuffer& buffer) const {
buffer.writeByteArray(&tmpLight, sizeof(tmpLight));
buffer.writeScalar(fBlurSigma);
}
void SkEmbossMaskFilter::toString(SkString* str) const {
str->append("SkEmbossMaskFilter: (");
str->append("direction: (");
str->appendScalar(fLight.fDirection[0]);
str->append(", ");
str->appendScalar(fLight.fDirection[1]);
str->append(", ");
str->appendScalar(fLight.fDirection[2]);
str->append(") ");
str->appendf("ambient: %d specular: %d ",
fLight.fAmbient, fLight.fSpecular);
str->append("blurSigma: ");
str->appendScalar(fBlurSigma);
str->append(")");
}

View File

@ -32,6 +32,7 @@ public:
bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&,
SkIPoint* margin) const override;
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkEmbossMaskFilter)
protected:

View File

@ -45,6 +45,8 @@ public:
SkArenaAlloc* scratch,
bool shaderIsOpaque) const override;
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkHighContrast_Filter)
protected:
@ -155,6 +157,10 @@ sk_sp<SkColorFilter> SkHighContrastFilter::Make(
return sk_make_sp<SkHighContrast_Filter>(config);
}
void SkHighContrast_Filter::toString(SkString* str) const {
str->append("SkHighContrastColorFilter ");
}
SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkHighContrastFilter)
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkHighContrast_Filter)
SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END

View File

@ -157,3 +157,12 @@ SkIRect SkImageSource::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ct
return dstRect.roundOut();
}
void SkImageSource::toString(SkString* str) const {
str->appendf("SkImageSource: (");
str->appendf("src: (%f,%f,%f,%f) dst: (%f,%f,%f,%f) ",
fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBottom,
fDstRect.fLeft, fDstRect.fTop, fDstRect.fRight, fDstRect.fBottom);
str->appendf("image: (%d,%d)",
fImage->width(), fImage->height());
str->append(")");
}

View File

@ -279,6 +279,62 @@ sk_sp<SkFlattenable> SkLayerDrawLooper::CreateProc(SkReadBuffer& buffer) {
return builder.detach();
}
void SkLayerDrawLooper::toString(SkString* str) const {
str->appendf("SkLayerDrawLooper (%d): ", fCount);
Rec* rec = fRecs;
for (int i = 0; i < fCount; i++) {
str->appendf("%d: paintBits: (", i);
if (0 == rec->fInfo.fPaintBits) {
str->append("None");
} else if (kEntirePaint_Bits == rec->fInfo.fPaintBits) {
str->append("EntirePaint");
} else {
bool needSeparator = false;
SkAddFlagToString(str, SkToBool(kStyle_Bit & rec->fInfo.fPaintBits), "Style",
&needSeparator);
SkAddFlagToString(str, SkToBool(kTextSkewX_Bit & rec->fInfo.fPaintBits), "TextSkewX",
&needSeparator);
SkAddFlagToString(str, SkToBool(kPathEffect_Bit & rec->fInfo.fPaintBits), "PathEffect",
&needSeparator);
SkAddFlagToString(str, SkToBool(kMaskFilter_Bit & rec->fInfo.fPaintBits), "MaskFilter",
&needSeparator);
SkAddFlagToString(str, SkToBool(kShader_Bit & rec->fInfo.fPaintBits), "Shader",
&needSeparator);
SkAddFlagToString(str, SkToBool(kColorFilter_Bit & rec->fInfo.fPaintBits), "ColorFilter",
&needSeparator);
SkAddFlagToString(str, SkToBool(kXfermode_Bit & rec->fInfo.fPaintBits), "Xfermode",
&needSeparator);
}
str->append(") ");
static const char* gModeStrings[(int)SkBlendMode::kLastMode+1] = {
"kClear", "kSrc", "kDst", "kSrcOver", "kDstOver", "kSrcIn", "kDstIn",
"kSrcOut", "kDstOut", "kSrcATop", "kDstATop", "kXor", "kPlus",
"kMultiply", "kScreen", "kOverlay", "kDarken", "kLighten", "kColorDodge",
"kColorBurn", "kHardLight", "kSoftLight", "kDifference", "kExclusion"
};
str->appendf("mode: %s ", gModeStrings[(int)rec->fInfo.fColorMode]);
str->append("offset: (");
str->appendScalar(rec->fInfo.fOffset.fX);
str->append(", ");
str->appendScalar(rec->fInfo.fOffset.fY);
str->append(") ");
str->append("postTranslate: ");
if (rec->fInfo.fPostTranslate) {
str->append("true ");
} else {
str->append("false ");
}
rec->fPaint.toString(str);
rec = rec->fNext;
}
}
SkLayerDrawLooper::Builder::Builder()
: fRecs(nullptr),
fTopRec(nullptr),

View File

@ -530,6 +530,7 @@ public:
sk_sp<SkImageFilter>,
const CropRect*);
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDiffuseLightingImageFilter)
SkScalar kd() const { return fKD; }
@ -564,6 +565,7 @@ public:
SkScalar ks, SkScalar shininess,
sk_sp<SkImageFilter>, const CropRect*);
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSpecularLightingImageFilter)
SkScalar ks() const { return fKS; }
@ -1369,6 +1371,12 @@ const {
return this->refMe();
}
void SkDiffuseLightingImageFilter::toString(SkString* str) const {
str->appendf("SkDiffuseLightingImageFilter: (");
str->appendf("kD: %f\n", fKD);
str->append(")");
}
#if SK_SUPPORT_GPU
std::unique_ptr<GrFragmentProcessor> SkDiffuseLightingImageFilter::makeFragmentProcessor(
sk_sp<GrTextureProxy> proxy,
@ -1518,6 +1526,12 @@ const {
return this->refMe();
}
void SkSpecularLightingImageFilter::toString(SkString* str) const {
str->appendf("SkSpecularLightingImageFilter: (");
str->appendf("kS: %f shininess: %f", fKS, fShininess);
str->append(")");
}
#if SK_SUPPORT_GPU
std::unique_ptr<GrFragmentProcessor> SkSpecularLightingImageFilter::makeFragmentProcessor(
sk_sp<GrTextureProxy> proxy,

View File

@ -37,6 +37,10 @@ sk_sp<SkFlattenable> SkLumaColorFilter::CreateProc(SkReadBuffer&) {
void SkLumaColorFilter::flatten(SkWriteBuffer&) const {}
void SkLumaColorFilter::toString(SkString* str) const {
str->append("SkLumaColorFilter ");
}
#if SK_SUPPORT_GPU
std::unique_ptr<GrFragmentProcessor> SkLumaColorFilter::asFragmentProcessor(
GrContext*, const GrColorSpaceInfo&) const {

View File

@ -200,3 +200,11 @@ sk_sp<SkImageFilter> SkMagnifierImageFilter::onMakeColorSpace(SkColorSpaceXforme
}
return this->refMe();
}
void SkMagnifierImageFilter::toString(SkString* str) const {
str->appendf("SkMagnifierImageFilter: (");
str->appendf("src: (%f,%f,%f,%f) ",
fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBottom);
str->appendf("inset: %f", fInset);
str->append(")");
}

View File

@ -479,3 +479,18 @@ bool SkMatrixConvolutionImageFilter::affectsTransparentBlack() const {
// pixels it will affect in object-space.
return kRepeat_TileMode != fTileMode;
}
void SkMatrixConvolutionImageFilter::toString(SkString* str) const {
str->appendf("SkMatrixConvolutionImageFilter: (");
str->appendf("size: (%d,%d) kernel: (", fKernelSize.width(), fKernelSize.height());
for (int y = 0; y < fKernelSize.height(); y++) {
for (int x = 0; x < fKernelSize.width(); x++) {
str->appendf("%f ", fKernel[y * fKernelSize.width() + x]);
}
}
str->appendf(")");
str->appendf("gain: %f bias: %f ", fGain, fBias);
str->appendf("offset: (%d, %d) ", fKernelOffset.fX, fKernelOffset.fY);
str->appendf("convolveAlpha: %s", fConvolveAlpha ? "true" : "false");
str->append(")");
}

View File

@ -121,3 +121,15 @@ void SkMergeImageFilter::flatten(SkWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
}
void SkMergeImageFilter::toString(SkString* str) const {
str->appendf("SkMergeImageFilter: (");
for (int i = 0; i < this->countInputs(); ++i) {
SkImageFilter* filter = this->getInput(i);
str->appendf("%d: (", i);
filter->toString(str);
str->appendf(")");
}
str->append(")");
}

View File

@ -113,6 +113,18 @@ sk_sp<SkFlattenable> SkDilateImageFilter::CreateProc(SkReadBuffer& buffer) {
return Make(width, height, common.getInput(0), &common.cropRect());
}
void SkErodeImageFilter::toString(SkString* str) const {
str->appendf("SkErodeImageFilter: (");
str->appendf("radius: (%d,%d)", this->radius().fWidth, this->radius().fHeight);
str->append(")");
}
void SkDilateImageFilter::toString(SkString* str) const {
str->appendf("SkDilateImageFilter: (");
str->appendf("radius: (%d,%d)", this->radius().fWidth, this->radius().fHeight);
str->append(")");
}
#if SK_SUPPORT_GPU
///////////////////////////////////////////////////////////////////////////////

View File

@ -124,3 +124,13 @@ SkOffsetImageFilter::SkOffsetImageFilter(SkScalar dx, SkScalar dy,
: INHERITED(&input, 1, cropRect) {
fOffset.set(dx, dy);
}
void SkOffsetImageFilter::toString(SkString* str) const {
str->appendf("SkOffsetImageFilter: (");
str->appendf("offset: (%f, %f) ", fOffset.fX, fOffset.fY);
str->append("input: (");
if (this->getInput(0)) {
this->getInput(0)->toString(str);
}
str->append("))");
}

View File

@ -36,6 +36,14 @@ void SkOverdrawColorFilter::onAppendStages(SkRasterPipeline* p,
p->append(SkRasterPipeline::callback, ctx);
}
void SkOverdrawColorFilter::toString(SkString* str) const {
str->append("SkOverdrawColorFilter (");
for (int i = 0; i < kNumColors; i++) {
str->appendf("%d: %x\n", i, fColors[i]);
}
str->append(")");
}
void SkOverdrawColorFilter::flatten(SkWriteBuffer& buffer) const {
buffer.writeByteArray(fColors, kNumColors * sizeof(SkPMColor));
}

View File

@ -81,3 +81,9 @@ sk_sp<SkImageFilter> SkPaintImageFilter::onMakeColorSpace(SkColorSpaceXformer* x
bool SkPaintImageFilter::affectsTransparentBlack() const {
return true;
}
void SkPaintImageFilter::toString(SkString* str) const {
str->appendf("SkPaintImageFilter: (");
fPaint.toString(str);
str->append(")");
}

View File

@ -130,3 +130,15 @@ sk_sp<SkImageFilter> SkPictureImageFilter::onMakeColorSpace(SkColorSpaceXformer*
return sk_sp<SkImageFilter>(new SkPictureImageFilter(fPicture, fCropRect, std::move(dstCS)));
}
void SkPictureImageFilter::toString(SkString* str) const {
str->appendf("SkPictureImageFilter: (");
str->appendf("crop: (%f,%f,%f,%f) ",
fCropRect.fLeft, fCropRect.fTop, fCropRect.fRight, fCropRect.fBottom);
if (fPicture) {
str->appendf("picture: (%f,%f,%f,%f)",
fPicture->cullRect().fLeft, fPicture->cullRect().fTop,
fPicture->cullRect().fRight, fPicture->cullRect().fBottom);
}
str->append(")");
}

View File

@ -27,6 +27,7 @@ public:
bool asABlur(BlurRec*) const override { return false; }
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkShaderMF)
protected:
@ -46,6 +47,10 @@ private:
typedef SkMaskFilter INHERITED;
};
void SkShaderMF::toString(SkString* str) const {
str->set("SkShaderMF:");
}
sk_sp<SkFlattenable> SkShaderMF::CreateProc(SkReadBuffer& buffer) {
return SkShaderMaskFilter::Make(buffer.readShader());
}

View File

@ -90,6 +90,8 @@ public:
GrContext*, const GrColorSpaceInfo&) const override;
#endif
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTable_ColorFilter)
enum {
@ -138,6 +140,35 @@ private:
typedef SkColorFilter INHERITED;
};
void SkTable_ColorFilter::toString(SkString* str) const {
const uint8_t* table = fStorage;
const uint8_t* tableA = gIdentityTable;
const uint8_t* tableR = gIdentityTable;
const uint8_t* tableG = gIdentityTable;
const uint8_t* tableB = gIdentityTable;
if (fFlags & kA_Flag) {
tableA = table; table += 256;
}
if (fFlags & kR_Flag) {
tableR = table; table += 256;
}
if (fFlags & kG_Flag) {
tableG = table; table += 256;
}
if (fFlags & kB_Flag) {
tableB = table;
}
str->append("SkTable_ColorFilter (");
for (int i = 0; i < 256; ++i) {
str->appendf("%d: %d,%d,%d,%d\n",
i, tableR[i], tableG[i], tableB[i], tableA[i]);
}
str->append(")");
}
static const uint8_t gCountNibBits[] = {
0, 1, 1, 2,
1, 2, 2, 3,

View File

@ -18,6 +18,7 @@ public:
SkMask::Format getFormat() const override;
bool filterMask(SkMask*, const SkMask&, const SkMatrix&, SkIPoint*) const override;
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTableMaskFilterImpl)
protected:
@ -166,3 +167,15 @@ void SkTableMaskFilter::MakeClipTable(uint8_t table[256], uint8_t min,
SkDebugf("\n\n");
#endif
}
void SkTableMaskFilterImpl::toString(SkString* str) const {
str->append("SkTableMaskFilter: (");
str->append("table: ");
for (int i = 0; i < 255; ++i) {
str->appendf("%d, ", fTable[i]);
}
str->appendf("%d", fTable[255]);
str->append(")");
}

View File

@ -157,3 +157,17 @@ void SkTileImageFilter::flatten(SkWriteBuffer& buffer) const {
buffer.writeRect(fSrcRect);
buffer.writeRect(fDstRect);
}
void SkTileImageFilter::toString(SkString* str) const {
str->appendf("SkTileImageFilter: (");
str->appendf("src: %.2f %.2f %.2f %.2f",
fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBottom);
str->appendf(" dst: %.2f %.2f %.2f %.2f",
fDstRect.fLeft, fDstRect.fTop, fDstRect.fRight, fDstRect.fBottom);
if (this->getInput(0)) {
str->appendf("input: (");
this->getInput(0)->toString(str);
str->appendf(")");
}
str->append(")");
}

View File

@ -71,6 +71,11 @@ void SkToSRGBColorFilter::flatten(SkWriteBuffer& buffer) const {
buffer.writeDataAsByteArray(fSrcColorSpace->serialize().get());
}
void SkToSRGBColorFilter::toString(SkString* str) const {
// TODO
str->append("SkToSRGBColorFilter ");
}
#if SK_SUPPORT_GPU
std::unique_ptr<GrFragmentProcessor> SkToSRGBColorFilter::asFragmentProcessor(
GrContext*, const GrColorSpaceInfo&) const {

View File

@ -18,6 +18,7 @@ public:
bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override;
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTrimPE)
protected:

View File

@ -97,6 +97,10 @@ sk_sp<SkFlattenable> SkTrimPE::CreateProc(SkReadBuffer& buffer) {
(mode & 1) ? SkTrimPathEffect::Mode::kInverted : SkTrimPathEffect::Mode::kNormal);
}
void SkTrimPE::toString(SkString* str) const {
str->appendf("SkTrimPathEffect: (%g %g)", fStartT, fStopT);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
sk_sp<SkPathEffect> SkTrimPathEffect::Make(SkScalar startT, SkScalar stopT, Mode mode) {

View File

@ -34,6 +34,7 @@ public:
SkXfermodeImageFilter_Base(SkBlendMode mode, sk_sp<SkImageFilter> inputs[2],
const CropRect* cropRect);
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkXfermodeImageFilter_Base)
protected:
@ -248,6 +249,22 @@ void SkXfermodeImageFilter_Base::drawForeground(SkCanvas* canvas, SkSpecialImage
canvas->drawPaint(paint);
}
void SkXfermodeImageFilter_Base::toString(SkString* str) const {
str->appendf("SkXfermodeImageFilter: (");
str->appendf("blendmode: (%d)", (int)fMode);
if (this->getInput(0)) {
str->appendf("foreground: (");
this->getInput(0)->toString(str);
str->appendf(")");
}
if (this->getInput(1)) {
str->appendf("background: (");
this->getInput(1)->toString(str);
str->appendf(")");
}
str->append(")");
}
#if SK_SUPPORT_GPU
#include "effects/GrXfermodeFragmentProcessor.h"

View File

@ -74,6 +74,7 @@ public:
bool filterPath(SkPath* dst, const SkPath&, SkStrokeRec* , const SkRect*) const override;
DashType asADash(DashInfo* info) const override;
Factory getFactory() const override { return nullptr; }
void toString(SkString*) const override {}
private:
TestDashPathEffect(const SkScalar* intervals, int count, SkScalar phase);

View File

@ -26,6 +26,7 @@ public:
void computeFastBounds(const SkRect&, SkRect*) const override;
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(GrSDFMaskFilterImpl)
protected:
@ -86,6 +87,10 @@ sk_sp<SkFlattenable> GrSDFMaskFilterImpl::CreateProc(SkReadBuffer& buffer) {
return GrSDFMaskFilter::Make();
}
void GrSDFMaskFilterImpl::toString(SkString* str) const {
str->append("GrSDFMaskFilterImpl: ()");
}
void gr_register_sdf_maskfilter_createproc() {
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(GrSDFMaskFilterImpl)
}

View File

@ -132,6 +132,12 @@ sk_sp<SkImage> SkImage::MakeFromEncoded(sk_sp<SkData> encoded, const SkIRect* su
///////////////////////////////////////////////////////////////////////////////////////////////////
const char* SkImage::toString(SkString* str) const {
str->appendf("image: (id:%d (%d, %d) %s)", this->uniqueID(), this->width(), this->height(),
this->isOpaque() ? "opaque" : "");
return str->c_str();
}
sk_sp<SkImage> SkImage::makeSubset(const SkIRect& subset) const {
if (subset.isEmpty()) {
return nullptr;

View File

@ -71,6 +71,19 @@ std::unique_ptr<GrFragmentProcessor> SkColorFilterShader::asFragmentProcessor(
}
#endif
void SkColorFilterShader::toString(SkString* str) const {
str->append("SkColorFilterShader: (");
str->append("Shader: ");
as_SB(fShader)->toString(str);
str->append(" Filter: ");
// TODO: add "fFilter->toString(str);" once SkColorFilter::toString is added
this->INHERITED::toString(str);
str->append(")");
}
///////////////////////////////////////////////////////////////////////////////////////////////////
sk_sp<SkShader> SkShader::makeWithColorFilter(sk_sp<SkColorFilter> filter) const {

View File

@ -21,6 +21,7 @@ public:
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const GrFPArgs&) const override;
#endif
void toString(SkString* str) const override;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorFilterShader)
protected:

View File

@ -97,6 +97,17 @@ std::unique_ptr<GrFragmentProcessor> SkColorShader::asFragmentProcessor(
#endif
void SkColorShader::toString(SkString* str) const {
str->append("SkColorShader: (");
str->append("Color: ");
str->appendHex(fColor);
this->INHERITED::toString(str);
str->append(")");
}
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
@ -212,6 +223,16 @@ std::unique_ptr<GrFragmentProcessor> SkColor4Shader::asFragmentProcessor(
#endif
void SkColor4Shader::toString(SkString* str) const {
str->append("SkColor4Shader: (");
str->append("RGBA:");
for (int i = 0; i < 4; ++i) {
str->appendf(" %g", fColor4.vec()[i]);
}
str->append(" )");
}
sk_sp<SkShader> SkColor4Shader::onMakeColorSpace(SkColorSpaceXformer* xformer) const {
return SkShader::MakeColorShader(xformer->apply(fCachedByteColor));
}

Some files were not shown because too many files have changed in this diff Show More