Plumb drawArc to SkDevice.
Plumbs the drawArc canvas method down to SkDevice without converting to a path. Plumbs through the various recording canvas classes. BUG=skia:5227 GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2257023003 Review-Url: https://codereview.chromium.org/2257023003
This commit is contained in:
parent
af0f6efa35
commit
ac3aa245ac
@ -739,9 +739,9 @@ public:
|
||||
specified oval. If the sweep angle is >= 360, then the oval is drawn
|
||||
completely. Note that this differs slightly from SkPath::arcTo, which
|
||||
treats the sweep angle mod 360.
|
||||
@param oval The bounds of oval used to define the shape of the arc
|
||||
@param oval The bounds of oval used to define the shape of the arc.
|
||||
@param startAngle Starting angle (in degrees) where the arc begins
|
||||
@param sweepAngle Sweep angle (in degrees) measured clockwise
|
||||
@param sweepAngle Sweep angle (in degrees) measured clockwise.
|
||||
@param useCenter true means include the center of the oval. For filling
|
||||
this will draw a wedge. False means just use the arc.
|
||||
@param paint The paint used to draw the arc
|
||||
@ -1390,6 +1390,8 @@ protected:
|
||||
virtual void onDrawPaint(const SkPaint&);
|
||||
virtual void onDrawRect(const SkRect&, const SkPaint&);
|
||||
virtual void onDrawOval(const SkRect&, const SkPaint&);
|
||||
virtual void onDrawArc(const SkRect&, SkScalar startAngle, SkScalar sweepAngle, bool useCenter,
|
||||
const SkPaint&);
|
||||
virtual void onDrawRRect(const SkRRect&, const SkPaint&);
|
||||
virtual void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&);
|
||||
virtual void onDrawVertices(VertexMode, int vertexCount, const SkPoint vertices[],
|
||||
|
@ -161,6 +161,9 @@ protected:
|
||||
const SkPaint& paint) = 0;
|
||||
virtual void drawOval(const SkDraw&, const SkRect& oval,
|
||||
const SkPaint& paint) = 0;
|
||||
/** By the time this is called we know that abs(sweepAngle) is in the range [0, 360). */
|
||||
virtual void drawArc(const SkDraw&, const SkRect& oval, SkScalar startAngle,
|
||||
SkScalar sweepAngle, bool useCenter, const SkPaint& paint);
|
||||
virtual void drawRRect(const SkDraw&, const SkRRect& rr,
|
||||
const SkPaint& paint) = 0;
|
||||
|
||||
|
@ -54,6 +54,7 @@ namespace SkRecords {
|
||||
M(ClipRRect) \
|
||||
M(ClipRect) \
|
||||
M(ClipRegion) \
|
||||
M(DrawArc) \
|
||||
M(DrawDrawable) \
|
||||
M(DrawImage) \
|
||||
M(DrawImageLattice) \
|
||||
@ -214,6 +215,12 @@ RECORD(ClipRegion, 0,
|
||||
SkRegion::Op op);
|
||||
|
||||
// While not strictly required, if you have an SkPaint, it's fastest to put it first.
|
||||
RECORD(DrawArc, kDraw_Tag|kHasPaint_Tag,
|
||||
SkPaint paint;
|
||||
SkRect oval;
|
||||
SkScalar startAngle;
|
||||
SkScalar sweepAngle;
|
||||
unsigned useCenter);
|
||||
RECORD(DrawDRRect, kDraw_Tag|kHasPaint_Tag,
|
||||
SkPaint paint;
|
||||
SkRRect outer;
|
||||
|
@ -36,6 +36,7 @@ public:
|
||||
kDrawPaint_Verb,
|
||||
kDrawPoints_Verb,
|
||||
kDrawOval_Verb,
|
||||
kDrawArc_Verb,
|
||||
kDrawRect_Verb,
|
||||
kDrawRRect_Verb,
|
||||
kDrawDRRect_Verb,
|
||||
@ -99,6 +100,7 @@ protected:
|
||||
void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) override;
|
||||
void onDrawRect(const SkRect&, const SkPaint&) override;
|
||||
void onDrawOval(const SkRect&, const SkPaint&) override;
|
||||
void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override;
|
||||
void onDrawRRect(const SkRRect&, const SkPaint&) override;
|
||||
void onDrawPath(const SkPath&, const SkPaint&) override;
|
||||
void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
|
||||
|
@ -46,6 +46,7 @@ protected:
|
||||
void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) override;
|
||||
void onDrawRect(const SkRect&, const SkPaint&) override;
|
||||
void onDrawOval(const SkRect&, const SkPaint&) override;
|
||||
void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override;
|
||||
void onDrawRRect(const SkRRect&, const SkPaint&) override;
|
||||
void onDrawPath(const SkPath&, const SkPaint&) override;
|
||||
void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
|
||||
|
@ -59,6 +59,7 @@ protected:
|
||||
void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) override;
|
||||
void onDrawRect(const SkRect&, const SkPaint&) override;
|
||||
void onDrawOval(const SkRect&, const SkPaint&) override;
|
||||
void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override;
|
||||
void onDrawRRect(const SkRRect&, const SkPaint&) override;
|
||||
void onDrawPath(const SkPath&, const SkPaint&) override;
|
||||
void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
|
||||
|
@ -31,6 +31,7 @@ public:
|
||||
enum Type {
|
||||
kPaint_Type,
|
||||
kPoint_Type,
|
||||
kArc_Type,
|
||||
kBitmap_Type,
|
||||
kRect_Type,
|
||||
kRRect_Type,
|
||||
@ -66,6 +67,7 @@ protected:
|
||||
void onDrawRRect(const SkRRect&, const SkPaint&) override;
|
||||
void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
|
||||
void onDrawOval(const SkRect&, const SkPaint&) override;
|
||||
void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override;
|
||||
void onDrawPath(const SkPath&, const SkPaint&) override;
|
||||
void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
|
||||
void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
|
||||
|
@ -2265,6 +2265,29 @@ void SkCanvas::onDrawOval(const SkRect& oval, const SkPaint& paint) {
|
||||
LOOPER_END
|
||||
}
|
||||
|
||||
void SkCanvas::onDrawArc(const SkRect& oval, SkScalar startAngle,
|
||||
SkScalar sweepAngle, bool useCenter,
|
||||
const SkPaint& paint) {
|
||||
TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawArc()");
|
||||
const SkRect* bounds = nullptr;
|
||||
if (paint.canComputeFastBounds()) {
|
||||
SkRect storage;
|
||||
// Note we're using the entire oval as the bounds.
|
||||
if (this->quickReject(paint.computeFastBounds(oval, &storage))) {
|
||||
return;
|
||||
}
|
||||
bounds = &oval;
|
||||
}
|
||||
|
||||
LOOPER_BEGIN(paint, SkDrawFilter::kOval_Type, bounds)
|
||||
|
||||
while (iter.next()) {
|
||||
iter.fDevice->drawArc(iter, oval, startAngle, sweepAngle, useCenter, looper.paint());
|
||||
}
|
||||
|
||||
LOOPER_END
|
||||
}
|
||||
|
||||
void SkCanvas::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) {
|
||||
TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawRRect()");
|
||||
SkRect storage;
|
||||
@ -3073,15 +3096,7 @@ void SkCanvas::drawArc(const SkRect& oval, SkScalar startAngle,
|
||||
if (SkScalarAbs(sweepAngle) >= SkIntToScalar(360)) {
|
||||
this->drawOval(oval, paint);
|
||||
} else {
|
||||
SkPath path;
|
||||
if (useCenter) {
|
||||
path.moveTo(oval.centerX(), oval.centerY());
|
||||
}
|
||||
path.arcTo(oval, startAngle, sweepAngle, !useCenter);
|
||||
if (useCenter) {
|
||||
path.close();
|
||||
}
|
||||
this->drawPath(path, paint);
|
||||
this->onDrawArc(oval, startAngle, sweepAngle, useCenter, paint);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,6 +73,20 @@ SkPixelGeometry SkBaseDevice::CreateInfo::AdjustGeometry(const SkImageInfo& info
|
||||
return geo;
|
||||
}
|
||||
|
||||
void SkBaseDevice::drawArc(const SkDraw& draw, const SkRect& oval, SkScalar startAngle,
|
||||
SkScalar sweepAngle, bool useCenter, const SkPaint& paint) {
|
||||
SkASSERT(SkScalarAbs(sweepAngle) >= 0.f && SkScalarAbs(sweepAngle) < 360.f);
|
||||
SkPath path;
|
||||
if (useCenter) {
|
||||
path.moveTo(oval.centerX(), oval.centerY());
|
||||
}
|
||||
path.arcTo(oval, startAngle, sweepAngle, !useCenter);
|
||||
if (useCenter) {
|
||||
path.close();
|
||||
}
|
||||
this->drawPath(draw, path, paint);
|
||||
}
|
||||
|
||||
void SkBaseDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer,
|
||||
const SkRRect& inner, const SkPaint& paint) {
|
||||
SkPath path;
|
||||
|
@ -54,8 +54,9 @@ namespace {
|
||||
M(Save) M(Restore) M(SaveLayer) \
|
||||
M(Concat) M(SetMatrix) M(Translate) M(TranslateZ) \
|
||||
M(ClipPath) M(ClipRect) M(ClipRRect) M(ClipRegion) \
|
||||
M(DrawPaint) M(DrawPath) M(DrawRect) M(DrawOval) M(DrawRRect) M(DrawDRRect) \
|
||||
M(DrawAnnotation) M(DrawDrawable) M(DrawPicture) M(DrawShadowedPicture) \
|
||||
M(DrawPaint) M(DrawPath) M(DrawRect) M(DrawOval) M(DrawArc) M(DrawRRect) \
|
||||
M(DrawDRRect) M(DrawAnnotation) M(DrawDrawable) M(DrawPicture) \
|
||||
M(DrawShadowedPicture) \
|
||||
M(DrawImage) M(DrawImageNine) M(DrawImageRect) M(DrawImageLattice) \
|
||||
M(DrawText) M(DrawPosText) M(DrawPosTextH) \
|
||||
M(DrawTextOnPath) M(DrawTextRSXform) M(DrawTextBlob) \
|
||||
@ -195,6 +196,20 @@ namespace {
|
||||
SkPaint paint;
|
||||
void draw(SkCanvas* c, const SkMatrix&) { c->drawOval(oval, paint); }
|
||||
};
|
||||
struct DrawArc final : Op {
|
||||
static const auto kType = Type::DrawArc;
|
||||
DrawArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, bool useCenter,
|
||||
const SkPaint& paint)
|
||||
: oval(oval), startAngle(startAngle), sweepAngle(sweepAngle), useCenter(useCenter)
|
||||
, paint(paint) {}
|
||||
SkRect oval;
|
||||
SkScalar startAngle;
|
||||
SkScalar sweepAngle;
|
||||
bool useCenter;
|
||||
SkPaint paint;
|
||||
void draw(SkCanvas* c, const SkMatrix&) { c->drawArc(oval, startAngle, sweepAngle,
|
||||
useCenter, paint); }
|
||||
};
|
||||
struct DrawRRect final : Op {
|
||||
static const auto kType = Type::DrawRRect;
|
||||
DrawRRect(const SkRRect& rrect, const SkPaint& paint) : rrect(rrect), paint(paint) {}
|
||||
@ -577,6 +592,10 @@ void SkLiteDL::drawRect(const SkRect& rect, const SkPaint& paint) {
|
||||
void SkLiteDL::drawOval(const SkRect& oval, const SkPaint& paint) {
|
||||
this->push<DrawOval>(0, oval, paint);
|
||||
}
|
||||
void SkLiteDL::drawArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, bool useCenter,
|
||||
const SkPaint& paint) {
|
||||
this->push<DrawArc>(0, oval, startAngle, sweepAngle, useCenter, paint);
|
||||
}
|
||||
void SkLiteDL::drawRRect(const SkRRect& rrect, const SkPaint& paint) {
|
||||
this->push<DrawRRect>(0, rrect, paint);
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ public:
|
||||
void drawPath (const SkPath&, const SkPaint&);
|
||||
void drawRect (const SkRect&, const SkPaint&);
|
||||
void drawOval (const SkRect&, const SkPaint&);
|
||||
void drawArc (const SkRect&, SkScalar, SkScalar, bool, const SkPaint&);
|
||||
void drawRRect (const SkRRect&, const SkPaint&);
|
||||
void drawDRRect(const SkRRect&, const SkRRect&, const SkPaint&);
|
||||
|
||||
|
@ -55,9 +55,13 @@ void SkLiteRecorder::onDrawPath(const SkPath& path, const SkPaint& paint) {
|
||||
void SkLiteRecorder::onDrawRect(const SkRect& rect, const SkPaint& paint) {
|
||||
fDL->drawRect(rect, paint);
|
||||
}
|
||||
void SkLiteRecorder::onDrawOval(const SkRect& oval, const SkPaint& paint) {
|
||||
void SkLiteRecorder::onDrawOval(const SkRect& oval, const SkPaint& paint) {
|
||||
fDL->drawOval(oval, paint);
|
||||
}
|
||||
void SkLiteRecorder::onDrawArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
|
||||
bool useCenter, const SkPaint& paint) {
|
||||
fDL->drawArc(oval, startAngle, sweepAngle, useCenter, paint);
|
||||
}
|
||||
void SkLiteRecorder::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) {
|
||||
fDL->drawRRect(rrect, paint);
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ public:
|
||||
void onDrawPath (const SkPath&, const SkPaint&) override;
|
||||
void onDrawRect (const SkRect&, const SkPaint&) override;
|
||||
void onDrawOval (const SkRect&, const SkPaint&) override;
|
||||
void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override;
|
||||
void onDrawRRect (const SkRRect&, const SkPaint&) override;
|
||||
void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
|
||||
|
||||
|
@ -92,8 +92,9 @@ enum DrawType {
|
||||
|
||||
DRAW_SHADOWED_PICTURE_LIGHTS,
|
||||
DRAW_IMAGE_LATTICE,
|
||||
DRAW_ARC,
|
||||
|
||||
LAST_DRAWTYPE_ENUM = DRAW_IMAGE_LATTICE
|
||||
LAST_DRAWTYPE_ENUM = DRAW_ARC
|
||||
};
|
||||
|
||||
// In the 'match' method, this constant will match any flavor of DRAW_BITMAP*
|
||||
|
@ -188,6 +188,17 @@ void SkPicturePlayback::handleOp(SkReadBuffer* reader,
|
||||
reader->readString(&key);
|
||||
canvas->drawAnnotation(rect, key.c_str(), reader->readByteArrayAsData().get());
|
||||
} break;
|
||||
case DRAW_ARC: {
|
||||
const SkPaint* paint = fPictureData->getPaint(reader);
|
||||
SkRect rect;
|
||||
reader->readRect(&rect);
|
||||
SkScalar startAngle = reader->readScalar();
|
||||
SkScalar sweepAngle = reader->readScalar();
|
||||
int useCenter = reader->readInt();
|
||||
if (paint) {
|
||||
canvas->drawArc(rect, startAngle, sweepAngle, SkToBool(useCenter), *paint);
|
||||
}
|
||||
} break;
|
||||
case DRAW_ATLAS: {
|
||||
const SkPaint* paint = fPictureData->getPaint(reader);
|
||||
const SkImage* atlas = fPictureData->getImage(reader);
|
||||
|
@ -428,6 +428,20 @@ void SkPictureRecord::onDrawOval(const SkRect& oval, const SkPaint& paint) {
|
||||
this->validate(initialOffset, size);
|
||||
}
|
||||
|
||||
void SkPictureRecord::onDrawArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
|
||||
bool useCenter, const SkPaint& paint) {
|
||||
// op + paint index + rect + start + sweep + bool (as int)
|
||||
size_t size = 2 * kUInt32Size + sizeof(oval) + sizeof(startAngle) + sizeof(sweepAngle) +
|
||||
sizeof(int);
|
||||
size_t initialOffset = this->addDraw(DRAW_ARC, &size);
|
||||
this->addPaint(paint);
|
||||
this->addRect(oval);
|
||||
this->addScalar(startAngle);
|
||||
this->addScalar(sweepAngle);
|
||||
this->addInt(useCenter);
|
||||
this->validate(initialOffset, size);
|
||||
}
|
||||
|
||||
void SkPictureRecord::onDrawRect(const SkRect& rect, const SkPaint& paint) {
|
||||
// op + paint index + rect
|
||||
size_t size = 2 * kUInt32Size + sizeof(rect);
|
||||
|
@ -187,6 +187,7 @@ protected:
|
||||
void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) override;
|
||||
void onDrawRect(const SkRect&, const SkPaint&) override;
|
||||
void onDrawOval(const SkRect&, const SkPaint&) override;
|
||||
void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override;
|
||||
void onDrawRRect(const SkRRect&, const SkPaint&) override;
|
||||
void onDrawPath(const SkPath&, const SkPaint&) override;
|
||||
void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
|
||||
|
@ -96,6 +96,7 @@ DRAW(TranslateZ, SkCanvas::translateZ(r.z));
|
||||
template <> void Draw::draw(const TranslateZ& r) { }
|
||||
#endif
|
||||
|
||||
DRAW(DrawArc, drawArc(r.oval, r.startAngle, r.sweepAngle, r.useCenter, r.paint));
|
||||
DRAW(DrawDRRect, drawDRRect(r.outer, r.inner, r.paint));
|
||||
DRAW(DrawImage, drawImage(r.image.get(), r.left, r.top, r.paint));
|
||||
|
||||
@ -413,6 +414,8 @@ private:
|
||||
|
||||
Bounds bounds(const DrawRect& op) const { return this->adjustAndMap(op.rect, &op.paint); }
|
||||
Bounds bounds(const DrawOval& op) const { return this->adjustAndMap(op.oval, &op.paint); }
|
||||
// Tighter arc bounds?
|
||||
Bounds bounds(const DrawArc& op) const { return this->adjustAndMap(op.oval, &op.paint); }
|
||||
Bounds bounds(const DrawRRect& op) const {
|
||||
return this->adjustAndMap(op.rrect.rect(), &op.paint);
|
||||
}
|
||||
|
@ -149,6 +149,11 @@ void SkRecorder::onDrawOval(const SkRect& oval, const SkPaint& paint) {
|
||||
APPEND(DrawOval, paint, oval);
|
||||
}
|
||||
|
||||
void SkRecorder::onDrawArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
|
||||
bool useCenter, const SkPaint& paint) {
|
||||
APPEND(DrawArc, paint, oval, startAngle, sweepAngle, useCenter);
|
||||
}
|
||||
|
||||
void SkRecorder::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) {
|
||||
APPEND(DrawRRect, paint, rrect);
|
||||
}
|
||||
|
@ -106,6 +106,7 @@ public:
|
||||
void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) override;
|
||||
void onDrawRect(const SkRect&, const SkPaint&) override;
|
||||
void onDrawOval(const SkRect&, const SkPaint&) override;
|
||||
void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override;
|
||||
void onDrawRRect(const SkRRect&, const SkPaint&) override;
|
||||
void onDrawPath(const SkPath&, const SkPaint&) override;
|
||||
void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
|
||||
|
@ -324,6 +324,13 @@ void SkDeferredCanvas::onDrawOval(const SkRect& rect, const SkPaint& paint) {
|
||||
fCanvas->drawOval(modRect, paint);
|
||||
}
|
||||
|
||||
void SkDeferredCanvas::onDrawArc(const SkRect& rect, SkScalar startAngle, SkScalar sweepAngle,
|
||||
bool useCenter, const SkPaint& paint) {
|
||||
SkRect modRect = rect;
|
||||
this->flush_check(&modRect, &paint, kNoClip_Flag);
|
||||
fCanvas->drawArc(modRect, startAngle, sweepAngle, useCenter, paint);
|
||||
}
|
||||
|
||||
static SkRRect make_offset(const SkRRect& src, SkScalar dx, SkScalar dy) {
|
||||
SkRRect dst = src;
|
||||
dst.offset(dx, dy);
|
||||
|
@ -63,6 +63,7 @@ protected:
|
||||
void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) override;
|
||||
void onDrawRect(const SkRect&, const SkPaint&) override;
|
||||
void onDrawOval(const SkRect&, const SkPaint&) override;
|
||||
void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override;
|
||||
void onDrawRRect(const SkRRect&, const SkPaint&) override;
|
||||
void onDrawPath(const SkPath&, const SkPaint&) override;
|
||||
void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
|
||||
|
@ -308,6 +308,14 @@ void SkDumpCanvas::onDrawOval(const SkRect& rect, const SkPaint& paint) {
|
||||
this->dump(kDrawOval_Verb, &paint, "drawOval(%s)", str.c_str());
|
||||
}
|
||||
|
||||
void SkDumpCanvas::onDrawArc(const SkRect& rect, SkScalar startAngle, SkScalar sweepAngle,
|
||||
bool useCenter, const SkPaint& paint) {
|
||||
SkString str;
|
||||
toString(rect, &str);
|
||||
this->dump(kDrawArc_Verb, &paint, "drawArc(%s, %g, %g, %d)", str.c_str(), startAngle,
|
||||
sweepAngle, useCenter);
|
||||
}
|
||||
|
||||
void SkDumpCanvas::onDrawRect(const SkRect& rect, const SkPaint& paint) {
|
||||
SkString str;
|
||||
toString(rect, &str);
|
||||
|
@ -179,6 +179,16 @@ void SkLuaCanvas::onDrawOval(const SkRect& rect, const SkPaint& paint) {
|
||||
lua.pushPaint(paint, "paint");
|
||||
}
|
||||
|
||||
void SkLuaCanvas::onDrawArc(const SkRect& rect, SkScalar startAngle, SkScalar sweepAngle,
|
||||
bool useCenter, const SkPaint& paint) {
|
||||
AUTO_LUA("drawArc");
|
||||
lua.pushRect(rect, "rect");
|
||||
lua.pushScalar(startAngle, "startAngle");
|
||||
lua.pushScalar(sweepAngle, "sweepAngle");
|
||||
lua.pushBool(useCenter, "useCenter");
|
||||
lua.pushPaint(paint, "paint");
|
||||
}
|
||||
|
||||
void SkLuaCanvas::onDrawRect(const SkRect& rect, const SkPaint& paint) {
|
||||
AUTO_LUA("drawRect");
|
||||
lua.pushRect(rect, "rect");
|
||||
|
@ -161,6 +161,14 @@ void SkNWayCanvas::onDrawOval(const SkRect& rect, const SkPaint& paint) {
|
||||
}
|
||||
}
|
||||
|
||||
void SkNWayCanvas::onDrawArc(const SkRect& rect, SkScalar startAngle, SkScalar sweepAngle,
|
||||
bool useCenter, const SkPaint& paint) {
|
||||
Iter iter(fList);
|
||||
while (iter.next()) {
|
||||
iter->drawArc(rect, startAngle, sweepAngle, useCenter, paint);
|
||||
}
|
||||
}
|
||||
|
||||
void SkNWayCanvas::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) {
|
||||
Iter iter(fList);
|
||||
while (iter.next()) {
|
||||
|
@ -87,6 +87,14 @@ void SkPaintFilterCanvas::onDrawOval(const SkRect& rect, const SkPaint& paint) {
|
||||
}
|
||||
}
|
||||
|
||||
void SkPaintFilterCanvas::onDrawArc(const SkRect& rect, SkScalar startAngle, SkScalar sweepAngle,
|
||||
bool useCenter, const SkPaint& paint) {
|
||||
AutoPaintFilter apf(this, kArc_Type, paint);
|
||||
if (apf.shouldDraw()) {
|
||||
this->INHERITED::onDrawArc(rect, startAngle, sweepAngle, useCenter, *apf.paint());
|
||||
}
|
||||
}
|
||||
|
||||
void SkPaintFilterCanvas::onDrawPath(const SkPath& path, const SkPaint& paint) {
|
||||
AutoPaintFilter apf(this, kPath_Type, paint);
|
||||
if (apf.shouldDraw()) {
|
||||
|
@ -103,6 +103,14 @@ void SkShadowPaintFilterCanvas::onDrawOval(const SkRect &rect, const SkPaint &pa
|
||||
this->restore();
|
||||
}
|
||||
|
||||
void SkShadowPaintFilterCanvas::onDrawArc(const SkRect &rect, SkScalar startAngle,
|
||||
SkScalar sweepAngle, bool useCenter,
|
||||
const SkPaint &paint) {
|
||||
this->updateMatrix();
|
||||
this->INHERITED::onDrawArc(rect, startAngle, sweepAngle, useCenter, paint);
|
||||
this->restore();
|
||||
}
|
||||
|
||||
void SkShadowPaintFilterCanvas::onDrawPath(const SkPath &path, const SkPaint &paint) {
|
||||
this->updateMatrix();
|
||||
this->INHERITED::onDrawPath(path, paint);
|
||||
|
@ -55,6 +55,8 @@ protected:
|
||||
|
||||
void onDrawOval(const SkRect &rect, const SkPaint &paint) override;
|
||||
|
||||
void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override;
|
||||
|
||||
void onDrawPath(const SkPath &path, const SkPaint &paint) override;
|
||||
|
||||
void onDrawBitmap(const SkBitmap &bm, SkScalar left, SkScalar top,
|
||||
|
@ -124,6 +124,11 @@ void SkAndroidSDKCanvas::onDrawOval(const SkRect& r, const SkPaint& paint) {
|
||||
FILTER(paint);
|
||||
fProxyTarget->drawOval(r, filteredPaint);
|
||||
}
|
||||
void SkAndroidSDKCanvas::onDrawArc(const SkRect& r, SkScalar startAngle, SkScalar sweepAngle,
|
||||
bool useCenter, const SkPaint& paint) {
|
||||
FILTER(paint);
|
||||
fProxyTarget->drawArc(r, startAngle, sweepAngle, useCenter, filteredPaint);
|
||||
}
|
||||
void SkAndroidSDKCanvas::onDrawRect(const SkRect& r, const SkPaint& paint) {
|
||||
FILTER(paint);
|
||||
fProxyTarget->drawRect(r, filteredPaint);
|
||||
|
@ -37,6 +37,8 @@ protected:
|
||||
void onDrawPoints(PointMode pMode, size_t count, const SkPoint pts[],
|
||||
const SkPaint& paint) override;
|
||||
void onDrawOval(const SkRect& r, const SkPaint& paint) override;
|
||||
void onDrawArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, bool useCenter,
|
||||
const SkPaint& paint) override;
|
||||
void onDrawRect(const SkRect& r, const SkPaint& paint) override;
|
||||
void onDrawRRect(const SkRRect& r, const SkPaint& paint) override;
|
||||
void onDrawPath(const SkPath& path, const SkPaint& paint) override;
|
||||
|
@ -596,6 +596,11 @@ void SkDebugCanvas::onDrawOval(const SkRect& oval, const SkPaint& paint) {
|
||||
this->addDrawCommand(new SkDrawOvalCommand(oval, paint));
|
||||
}
|
||||
|
||||
void SkDebugCanvas::onDrawArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
|
||||
bool useCenter, const SkPaint& paint) {
|
||||
this->addDrawCommand(new SkDrawArcCommand(oval, startAngle, sweepAngle, useCenter, paint));
|
||||
}
|
||||
|
||||
void SkDebugCanvas::onDrawPaint(const SkPaint& paint) {
|
||||
this->addDrawCommand(new SkDrawPaintCommand(paint));
|
||||
}
|
||||
|
@ -231,6 +231,7 @@ protected:
|
||||
|
||||
void onDrawRect(const SkRect&, const SkPaint&) override;
|
||||
void onDrawOval(const SkRect&, const SkPaint&) override;
|
||||
void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override;
|
||||
void onDrawRRect(const SkRRect&, const SkPaint&) override;
|
||||
void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) override;
|
||||
void onDrawVertices(VertexMode vmode, int vertexCount,
|
||||
|
@ -92,7 +92,9 @@
|
||||
#define SKDEBUGCANVAS_ATTRIBUTE_COLORS "colors"
|
||||
#define SKDEBUGCANVAS_ATTRIBUTE_TEXTURECOORDS "textureCoords"
|
||||
#define SKDEBUGCANVAS_ATTRIBUTE_FILTERQUALITY "filterQuality"
|
||||
|
||||
#define SKDEBUGCANVAS_ATTRIBUTE_STARTANGLE "startAngle"
|
||||
#define SKDEBUGCANVAS_ATTRIBUTE_SWEEPANGLE "sweepAngle"
|
||||
#define SKDEBUGCANVAS_ATTRIBUTE_USECENTER "useCenter"
|
||||
#define SKDEBUGCANVAS_ATTRIBUTE_SHORTDESC "shortDesc"
|
||||
|
||||
#define SKDEBUGCANVAS_VERB_MOVE "move"
|
||||
@ -2260,6 +2262,64 @@ SkDrawOvalCommand* SkDrawOvalCommand::fromJSON(Json::Value& command,
|
||||
return new SkDrawOvalCommand(coords, paint);
|
||||
}
|
||||
|
||||
SkDrawArcCommand::SkDrawArcCommand(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
|
||||
bool useCenter, const SkPaint& paint)
|
||||
: INHERITED(kDrawOval_OpType) {
|
||||
fOval = oval;
|
||||
fStartAngle = startAngle;
|
||||
fSweepAngle = sweepAngle;
|
||||
fUseCenter = useCenter;
|
||||
fPaint = paint;
|
||||
|
||||
fInfo.push(SkObjectParser::RectToString(oval));
|
||||
fInfo.push(SkObjectParser::ScalarToString(startAngle, "StartAngle: "));
|
||||
fInfo.push(SkObjectParser::ScalarToString(sweepAngle, "SweepAngle: "));
|
||||
fInfo.push(SkObjectParser::BoolToString(useCenter));
|
||||
fInfo.push(SkObjectParser::PaintToString(paint));
|
||||
}
|
||||
|
||||
void SkDrawArcCommand::execute(SkCanvas* canvas) const {
|
||||
canvas->drawArc(fOval, fStartAngle, fSweepAngle, fUseCenter, fPaint);
|
||||
}
|
||||
|
||||
bool SkDrawArcCommand::render(SkCanvas* canvas) const {
|
||||
canvas->clear(0xFFFFFFFF);
|
||||
canvas->save();
|
||||
|
||||
xlate_and_scale_to_bounds(canvas, fOval);
|
||||
|
||||
SkPaint p;
|
||||
p.setColor(SK_ColorBLACK);
|
||||
p.setStyle(SkPaint::kStroke_Style);
|
||||
|
||||
canvas->drawArc(fOval, fStartAngle, fSweepAngle, fUseCenter, p);
|
||||
canvas->restore();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Json::Value SkDrawArcCommand::toJSON(UrlDataManager& urlDataManager) const {
|
||||
Json::Value result = INHERITED::toJSON(urlDataManager);
|
||||
result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonRect(fOval);
|
||||
result[SKDEBUGCANVAS_ATTRIBUTE_STARTANGLE] = MakeJsonScalar(fStartAngle);
|
||||
result[SKDEBUGCANVAS_ATTRIBUTE_SWEEPANGLE] = MakeJsonScalar(fSweepAngle);
|
||||
result[SKDEBUGCANVAS_ATTRIBUTE_USECENTER] = fUseCenter;
|
||||
result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(fPaint, urlDataManager);
|
||||
return result;
|
||||
}
|
||||
|
||||
SkDrawArcCommand* SkDrawArcCommand::fromJSON(Json::Value& command,
|
||||
UrlDataManager& urlDataManager) {
|
||||
SkRect coords;
|
||||
extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &coords);
|
||||
SkScalar startAngle = command[SKDEBUGCANVAS_ATTRIBUTE_STARTANGLE].asFloat();
|
||||
SkScalar sweepAngle = command[SKDEBUGCANVAS_ATTRIBUTE_SWEEPANGLE].asFloat();
|
||||
bool useCenter = command[SKDEBUGCANVAS_ATTRIBUTE_USECENTER].asBool();
|
||||
SkPaint paint;
|
||||
extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &paint);
|
||||
return new SkDrawArcCommand(coords, startAngle, sweepAngle, useCenter, paint);
|
||||
}
|
||||
|
||||
SkDrawPaintCommand::SkDrawPaintCommand(const SkPaint& paint)
|
||||
: INHERITED(kDrawPaint_OpType) {
|
||||
fPaint = paint;
|
||||
|
@ -399,6 +399,25 @@ private:
|
||||
typedef SkDrawCommand INHERITED;
|
||||
};
|
||||
|
||||
class SkDrawArcCommand : public SkDrawCommand {
|
||||
public:
|
||||
SkDrawArcCommand(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, bool useCenter,
|
||||
const SkPaint& paint);
|
||||
void execute(SkCanvas* canvas) const override;
|
||||
bool render(SkCanvas* canvas) const override;
|
||||
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
|
||||
static SkDrawArcCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
|
||||
|
||||
private:
|
||||
SkRect fOval;
|
||||
SkScalar fStartAngle;
|
||||
SkScalar fSweepAngle;
|
||||
bool fUseCenter;
|
||||
SkPaint fPaint;
|
||||
|
||||
typedef SkDrawCommand INHERITED;
|
||||
};
|
||||
|
||||
class SkDrawPaintCommand : public SkDrawCommand {
|
||||
public:
|
||||
SkDrawPaintCommand(const SkPaint& paint);
|
||||
|
Loading…
Reference in New Issue
Block a user