experimental
BUG=skia: Review URL: https://codereview.chromium.org/716793004
This commit is contained in:
parent
ad8aa1dcf3
commit
6a070dc06a
@ -25,8 +25,9 @@
|
||||
#define SK_LEGACY_DRAWTEXT_VIRTUAL
|
||||
#endif
|
||||
|
||||
class SkCanvasClipVisitor;
|
||||
class SkBaseDevice;
|
||||
class SkCanvasClipVisitor;
|
||||
class SkCanvasDrawable;
|
||||
class SkDraw;
|
||||
class SkDrawFilter;
|
||||
class SkImage;
|
||||
@ -1069,6 +1070,8 @@ public:
|
||||
void drawPatch(const SkPoint cubics[12], const SkColor colors[4],
|
||||
const SkPoint texCoords[4], SkXfermode* xmode, const SkPaint& paint);
|
||||
|
||||
void EXPERIMENTAL_drawDrawable(SkCanvasDrawable*);
|
||||
|
||||
/** Send a blob of data to the canvas.
|
||||
For canvases that draw, this call is effectively a no-op, as the data
|
||||
is not parsed, but just ignored. However, this call exists for
|
||||
@ -1254,6 +1257,8 @@ protected:
|
||||
virtual void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
|
||||
const SkPoint texCoords[4], SkXfermode* xmode, const SkPaint& paint);
|
||||
|
||||
virtual void onDrawDrawable(SkCanvasDrawable*);
|
||||
|
||||
enum ClipEdgeStyle {
|
||||
kHard_ClipEdgeStyle,
|
||||
kSoft_ClipEdgeStyle
|
||||
|
@ -22,6 +22,8 @@
|
||||
#include "SkColorFilter.h"
|
||||
#include "SkLayerRasterizer.h"
|
||||
|
||||
#include "SkCanvasDrawable.h"
|
||||
|
||||
#include "SkParsePath.h"
|
||||
static void testparse() {
|
||||
SkRect r;
|
||||
@ -36,11 +38,58 @@ static void testparse() {
|
||||
}
|
||||
|
||||
class ArcsView : public SampleView {
|
||||
class MyDrawable : public SkCanvasDrawable {
|
||||
SkRect fR;
|
||||
SkScalar fSweep;
|
||||
public:
|
||||
MyDrawable(const SkRect& r) : fR(r), fSweep(0) {
|
||||
}
|
||||
|
||||
void setSweep(SkScalar sweep) {
|
||||
if (fSweep != sweep) {
|
||||
fSweep = sweep;
|
||||
this->notifyDrawingChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void onDraw(SkCanvas* canvas) SK_OVERRIDE {
|
||||
SkPaint paint;
|
||||
paint.setAntiAlias(true);
|
||||
paint.setStrokeWidth(SkIntToScalar(2));
|
||||
|
||||
paint.setStyle(SkPaint::kFill_Style);
|
||||
paint.setColor(0x800000FF);
|
||||
canvas->drawArc(fR, 0, fSweep, true, paint);
|
||||
|
||||
paint.setColor(0x800FF000);
|
||||
canvas->drawArc(fR, 0, fSweep, false, paint);
|
||||
|
||||
paint.setStyle(SkPaint::kStroke_Style);
|
||||
paint.setColor(SK_ColorRED);
|
||||
canvas->drawArc(fR, 0, fSweep, true, paint);
|
||||
|
||||
paint.setStrokeWidth(0);
|
||||
paint.setColor(SK_ColorBLUE);
|
||||
canvas->drawArc(fR, 0, fSweep, false, paint);
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
SkRect fRect;
|
||||
MyDrawable* fDrawable;
|
||||
|
||||
ArcsView() {
|
||||
testparse();
|
||||
fSweep = SkIntToScalar(100);
|
||||
this->setBGColor(0xFFDDDDDD);
|
||||
|
||||
fRect.set(0, 0, SkIntToScalar(200), SkIntToScalar(200));
|
||||
fRect.offset(SkIntToScalar(20), SkIntToScalar(20));
|
||||
fDrawable = SkNEW_ARGS(MyDrawable, (fRect));
|
||||
}
|
||||
|
||||
virtual ~ArcsView() SK_OVERRIDE {
|
||||
fDrawable->unref();
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -121,48 +170,17 @@ protected:
|
||||
}
|
||||
|
||||
virtual void onDrawContent(SkCanvas* canvas) {
|
||||
fSweep = SampleCode::GetAnimScalar(SkIntToScalar(360)/24,
|
||||
SkIntToScalar(360));
|
||||
// fSweep = 359.99f;
|
||||
fDrawable->setSweep(SampleCode::GetAnimScalar(SkIntToScalar(360)/24,
|
||||
SkIntToScalar(360)));
|
||||
|
||||
SkRect r;
|
||||
SkPaint paint;
|
||||
|
||||
paint.setAntiAlias(true);
|
||||
paint.setStrokeWidth(SkIntToScalar(2));
|
||||
paint.setStyle(SkPaint::kStroke_Style);
|
||||
|
||||
r.set(0, 0, SkIntToScalar(200), SkIntToScalar(200));
|
||||
r.offset(SkIntToScalar(20), SkIntToScalar(20));
|
||||
drawRectWithLines(canvas, fRect, paint);
|
||||
|
||||
if (false) {
|
||||
const SkScalar d = SkIntToScalar(3);
|
||||
const SkScalar rad[] = { d, d, d, d, d, d, d, d };
|
||||
SkPath path;
|
||||
path.addRoundRect(r, rad);
|
||||
canvas->drawPath(path, paint);
|
||||
return;
|
||||
}
|
||||
|
||||
drawRectWithLines(canvas, r, paint);
|
||||
|
||||
// printf("----- sweep %g %X\n", SkScalarToFloat(fSweep), SkDegreesToRadians(fSweep));
|
||||
|
||||
|
||||
paint.setStyle(SkPaint::kFill_Style);
|
||||
paint.setColor(0x800000FF);
|
||||
canvas->drawArc(r, 0, fSweep, true, paint);
|
||||
|
||||
paint.setColor(0x800FF000);
|
||||
canvas->drawArc(r, 0, fSweep, false, paint);
|
||||
|
||||
paint.setStyle(SkPaint::kStroke_Style);
|
||||
paint.setColor(SK_ColorRED);
|
||||
canvas->drawArc(r, 0, fSweep, true, paint);
|
||||
|
||||
paint.setStrokeWidth(0);
|
||||
paint.setColor(SK_ColorBLUE);
|
||||
canvas->drawArc(r, 0, fSweep, false, paint);
|
||||
canvas->EXPERIMENTAL_drawDrawable(fDrawable);
|
||||
|
||||
drawArcs(canvas);
|
||||
this->inval(NULL);
|
||||
|
@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "SkCanvas.h"
|
||||
#include "SkCanvasDrawable.h"
|
||||
#include "SkCanvasPriv.h"
|
||||
#include "SkBitmapDevice.h"
|
||||
#include "SkDeviceImageFilterProxy.h"
|
||||
@ -2304,6 +2305,19 @@ void SkCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
|
||||
LOOPER_END
|
||||
}
|
||||
|
||||
void SkCanvas::EXPERIMENTAL_drawDrawable(SkCanvasDrawable* dr) {
|
||||
if (dr) {
|
||||
SkRect bounds;
|
||||
if (!dr->getBounds(&bounds) || !this->quickReject(bounds)) {
|
||||
this->onDrawDrawable(dr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SkCanvas::onDrawDrawable(SkCanvasDrawable* dr) {
|
||||
dr->draw(this);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// These methods are NOT virtual, and therefore must call back into virtual
|
||||
// methods, rather than actually drawing themselves.
|
||||
|
Loading…
Reference in New Issue
Block a user