Simplify a little in SkRecords.h:
- ACT_AS_PTR can just expose const methods to get at the pointers. (If the thing stored must stay const, we pass a const T.) - DrawPatch works fine with Record# macros, so use Record5. BUG=skia: R=fmalita@google.com, mtklein@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/585523003
This commit is contained in:
parent
a10742c69c
commit
9b222a5ddd
@ -96,7 +96,7 @@ DRAW(DrawDRRect, drawDRRect(r.outer, r.inner, r.paint));
|
||||
DRAW(DrawOval, drawOval(r.oval, r.paint));
|
||||
DRAW(DrawPaint, drawPaint(r.paint));
|
||||
DRAW(DrawPath, drawPath(r.path, r.paint));
|
||||
DRAW(DrawPatch, drawPatch(r.cubics, r.colors, r.texCoords, r.xmode.get(), r.paint));
|
||||
DRAW(DrawPatch, drawPatch(r.cubics, r.colors, r.texCoords, r.xmode, r.paint));
|
||||
DRAW(DrawPicture, drawPicture(r.picture, r.matrix, r.paint));
|
||||
DRAW(DrawPoints, drawPoints(r.mode, r.count, r.pts, r.paint));
|
||||
DRAW(DrawPosText, drawPosText(r.text, r.byteLength, r.pos, r.paint));
|
||||
|
@ -118,17 +118,15 @@ struct T { \
|
||||
A a; B b; C c; D d; E e; \
|
||||
};
|
||||
|
||||
#define ACT_AS_PTR(ptr) \
|
||||
operator T*() { return ptr; } \
|
||||
operator const T*() const { return ptr; } \
|
||||
T* operator->() { return ptr; } \
|
||||
const T* operator->() const { return ptr; }
|
||||
#define ACT_AS_PTR(ptr) \
|
||||
operator T*() const { return ptr; } \
|
||||
T* operator->() const { return ptr; }
|
||||
|
||||
template <typename T>
|
||||
class RefBox : SkNoncopyable {
|
||||
public:
|
||||
RefBox(T* obj) : fObj(SkRef(obj)) {}
|
||||
~RefBox() { fObj->unref(); }
|
||||
RefBox(T* obj) : fObj(SkSafeRef(obj)) {}
|
||||
~RefBox() { SkSafeUnref(fObj); }
|
||||
|
||||
ACT_AS_PTR(fObj);
|
||||
|
||||
@ -239,7 +237,6 @@ RECORD3(DrawDRRect, SkPaint, paint, SkRRect, outer, SkRRect, inner);
|
||||
RECORD2(DrawOval, SkPaint, paint, SkRect, oval);
|
||||
RECORD1(DrawPaint, SkPaint, paint);
|
||||
RECORD2(DrawPath, SkPaint, paint, SkPath, path);
|
||||
//RECORD2(DrawPatch, SkPaint, paint, SkPatch, patch);
|
||||
RECORD3(DrawPicture, Optional<SkPaint>, paint,
|
||||
RefBox<const SkPicture>, picture,
|
||||
Optional<SkMatrix>, matrix);
|
||||
@ -273,6 +270,12 @@ RECORD5(DrawTextOnPath, SkPaint, paint,
|
||||
|
||||
RECORD2(DrawData, PODArray<char>, data, size_t, length);
|
||||
|
||||
RECORD5(DrawPatch, SkPaint, paint,
|
||||
PODArray<SkPoint>, cubics,
|
||||
PODArray<SkColor>, colors,
|
||||
PODArray<SkPoint>, texCoords,
|
||||
RefBox<SkXfermode>, xmode);
|
||||
|
||||
// This guy is so ugly we just write it manually.
|
||||
struct DrawVertices {
|
||||
static const Type kType = DrawVertices_Type;
|
||||
@ -307,24 +310,6 @@ struct DrawVertices {
|
||||
int indexCount;
|
||||
};
|
||||
|
||||
struct DrawPatch {
|
||||
static const Type kType = DrawPatch_Type;
|
||||
|
||||
DrawPatch(const SkPaint& paint, SkPoint cubics[12], SkColor colors[4],
|
||||
SkPoint texCoords[4], SkXfermode* xmode)
|
||||
: paint(paint)
|
||||
, cubics(cubics)
|
||||
, colors(colors)
|
||||
, texCoords(texCoords)
|
||||
, xmode(SkSafeRef(xmode)) { }
|
||||
|
||||
SkPaint paint;
|
||||
PODArray<SkPoint> cubics;
|
||||
PODArray<SkColor> colors;
|
||||
PODArray<SkPoint> texCoords;
|
||||
SkAutoTUnref<SkXfermode> xmode;
|
||||
};
|
||||
|
||||
#undef RECORD0
|
||||
#undef RECORD1
|
||||
#undef RECORD2
|
||||
|
Loading…
Reference in New Issue
Block a user