// A list of all the types of canvas calls we can record. // Each of these is reified into a struct below. // // (We're using the macro-of-macro trick here to do several different things with the same list.) // // We leave this SK_RECORD_TYPES macro defined for use by code that wants to operate on SkRecords // types polymorphically. (See SkRecord::Record::{visit,mutate} for an example.) // // Order doesn't technically matter here, but the compiler can generally generate better code if // you keep them semantically grouped, especially the Draws. It's also nice to leave NoOp at 0. #define SK_RECORD_TYPES(M) \
M(NoOp) \
M(Restore) \
M(Save) \
M(SaveLayer) \
M(SaveBehind) \
M(SetMatrix) \
M(SetM44) \
M(Translate) \
M(Scale) \
M(Concat) \
M(Concat44) \
M(ClipPath) \
M(ClipRRect) \
M(ClipRect) \
M(ClipRegion) \
M(ClipShader) \
M(ResetClip) \
M(DrawArc) \
M(DrawDrawable) \
M(DrawImage) \
M(DrawImageLattice) \
M(DrawImageRect) \
M(DrawDRRect) \
M(DrawOval) \
M(DrawBehind) \
M(DrawPaint) \
M(DrawPath) \
M(DrawPatch) \
M(DrawPicture) \
M(DrawPoints) \
M(DrawRRect) \
M(DrawRect) \
M(DrawRegion) \
M(DrawTextBlob) \
M(DrawSlug) \
M(DrawAtlas) \
M(DrawVertices) \
M(DrawMesh) \
M(DrawShadowRec) \
M(DrawAnnotation) \
M(DrawEdgeAAQuad) \
M(DrawEdgeAAImageSet)
// Defines SkRecords::Type, an enum of all record types. #defineENUM(T) T##_Type, enum Type { SK_RECORD_TYPES(ENUM) }; #undefENUM
// PODArray doesn't own the pointer's memory, and we assume the data is POD. template <typename T> class PODArray { public:
PODArray() {}
PODArray(T* ptr) : fPtr(ptr) {} // Default copy and assign.
ACT_AS_PTR(fPtr) private:
T* fPtr;
};
#undef ACT_AS_PTR
// SkPath::getBounds() isn't thread safe unless we precache the bounds in a singlethreaded context. // SkPath::cheapComputeDirection() is similar. // Recording is a convenient time to cache these, or we can delay it to between record and playback. struct PreCachedPath : public SkPath {
PreCachedPath() {}
PreCachedPath(const SkPath& path);
};
// Like SkPath::getBounds(), SkMatrix::getType() isn't thread safe unless we precache it. // This may not cover all SkMatrices used by the picture (e.g. some could be hiding in a shader). struct TypedMatrix : public SkMatrix {
TypedMatrix() {}
TypedMatrix(const SkMatrix& matrix);
};
enum Tags {
kDraw_Tag = 1, // May draw something (usually named DrawFoo).
kHasImage_Tag = 2, // Contains an SkImage or SkBitmap.
kHasText_Tag = 4, // Contains text.
kHasPaint_Tag = 8, // May have an SkPaint field, at least optionally.
kMultiDraw_Tag = 16, // Drawing operations that render multiple independent primitives. // These draws are capable of blending with themselves.
// A macro to make it a little easier to define a struct that can be stored in SkRecord. #define RECORD(T, tags, ...) \ struct T { \ staticconst Type kType = T##_Type; \ staticconstint kTags = tags; \
__VA_ARGS__; \
};
#define RECORD_TRIVIAL(T, tags) \ struct T { \ staticconst Type kType = T##_Type; \ staticconstint kTags = tags; \
};
private: unsigned fOp : 31; // This really only needs to be 3, but there's no win today to do so. unsigned fAA : 1; // MSVC won't pack an enum with an bool, so we call this an unsigned.
};
static_assert(sizeof(ClipOpAndAA) == 4, "ClipOpAndAASize");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.