2015-03-23 19:51:20 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2015 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkAndroidSDKCanvas_DEFINED
|
|
|
|
#define SkAndroidSDKCanvas_DEFINED
|
|
|
|
|
|
|
|
#include "SkBitmap.h"
|
|
|
|
#include "SkCanvas.h"
|
|
|
|
#include "SkPaint.h"
|
|
|
|
#include "SkPath.h"
|
|
|
|
#include "SkRect.h"
|
|
|
|
|
|
|
|
/** SkDrawFilter is likely to be deprecated; this is a proxy
|
|
|
|
canvas that does the same thing: alter SkPaint fields.
|
|
|
|
|
|
|
|
onDraw*() functions may have their SkPaint modified, and are then
|
|
|
|
passed on to the same function on proxyTarget. THIS BREAKS CONSTNESS!
|
|
|
|
|
|
|
|
This still suffers one of the same architectural flaws as SkDrawFilter:
|
|
|
|
TextBlob paints are incomplete when filter is called.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class SkAndroidSDKCanvas : public SkCanvas {
|
|
|
|
public:
|
|
|
|
SkAndroidSDKCanvas();
|
|
|
|
void reset(SkCanvas* newTarget);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
// FILTERING
|
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
void onDrawPaint(const SkPaint& paint) override;
|
2015-03-23 19:51:20 +00:00
|
|
|
void onDrawPoints(PointMode pMode, size_t count, const SkPoint pts[],
|
2015-03-26 01:17:31 +00:00
|
|
|
const SkPaint& paint) override;
|
|
|
|
void onDrawOval(const SkRect& r, 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;
|
2015-03-23 19:51:20 +00:00
|
|
|
void onDrawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
|
2015-03-26 01:17:31 +00:00
|
|
|
const SkPaint* paint) override;
|
2015-03-23 19:51:20 +00:00
|
|
|
void onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
|
2015-07-31 21:29:26 +00:00
|
|
|
const SkPaint* paint, SkCanvas::SrcRectConstraint) override;
|
2015-03-23 19:51:20 +00:00
|
|
|
void onDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
|
2015-03-26 01:17:31 +00:00
|
|
|
const SkRect& dst, const SkPaint* paint) override;
|
2015-03-23 19:51:20 +00:00
|
|
|
void onDrawVertices(VertexMode vMode, int vertexCount, const SkPoint vertices[],
|
|
|
|
const SkPoint texs[], const SkColor colors[], SkXfermode* xMode,
|
|
|
|
const uint16_t indices[], int indexCount,
|
2015-03-26 01:17:31 +00:00
|
|
|
const SkPaint& paint) override;
|
2015-03-23 19:51:20 +00:00
|
|
|
|
|
|
|
void onDrawDRRect(const SkRRect& outer, const SkRRect& inner,
|
2015-03-26 01:17:31 +00:00
|
|
|
const SkPaint& paint) override;
|
2015-03-23 19:51:20 +00:00
|
|
|
|
|
|
|
void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
|
2015-03-26 01:17:31 +00:00
|
|
|
const SkPaint& paint) override;
|
2015-03-23 19:51:20 +00:00
|
|
|
void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
|
2015-03-26 01:17:31 +00:00
|
|
|
const SkPaint& paint) override;
|
2015-03-23 19:51:20 +00:00
|
|
|
void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
|
2015-03-26 01:17:31 +00:00
|
|
|
SkScalar constY, const SkPaint& paint) override;
|
2015-03-23 19:51:20 +00:00
|
|
|
void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
|
2015-03-26 01:17:31 +00:00
|
|
|
const SkMatrix* matrix, const SkPaint& paint) override;
|
2015-03-23 19:51:20 +00:00
|
|
|
void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
|
2015-03-26 01:17:31 +00:00
|
|
|
const SkPaint& paint) override;
|
2015-03-23 19:51:20 +00:00
|
|
|
|
|
|
|
void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
|
|
|
|
const SkPoint texCoords[4], SkXfermode* xmode,
|
2015-03-26 01:17:31 +00:00
|
|
|
const SkPaint& paint) override;
|
2015-03-23 19:51:20 +00:00
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
void onDrawImage(const SkImage*, SkScalar, SkScalar, const SkPaint*) override;
|
2015-08-03 13:03:06 +00:00
|
|
|
void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, const SkPaint*,
|
|
|
|
SrcRectConstraint) override;
|
2015-03-23 19:51:20 +00:00
|
|
|
void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*);
|
2015-10-01 15:02:22 +00:00
|
|
|
void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[],
|
|
|
|
const SkColor[], int count, SkXfermode::Mode,
|
|
|
|
const SkRect* cull, const SkPaint*) override;
|
|
|
|
void onDrawImageNine(const SkImage*, const SkIRect& center,
|
|
|
|
const SkRect& dst, const SkPaint*) override;
|
2015-03-23 19:51:20 +00:00
|
|
|
|
|
|
|
// PASS THROUGH
|
|
|
|
|
2015-07-07 17:22:31 +00:00
|
|
|
void onDrawDrawable(SkDrawable*, const SkMatrix*) override;
|
2015-03-26 01:17:31 +00:00
|
|
|
SkISize getBaseLayerSize() const override;
|
|
|
|
bool getClipBounds(SkRect*) const override;
|
|
|
|
bool getClipDeviceBounds(SkIRect*) const override;
|
|
|
|
bool isClipEmpty() const override;
|
|
|
|
bool isClipRect() const override;
|
|
|
|
SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&) override;
|
2015-05-26 21:12:24 +00:00
|
|
|
bool onPeekPixels(SkPixmap*) override;
|
|
|
|
bool onAccessTopLayerPixels(SkPixmap*) override;
|
2015-03-26 01:17:31 +00:00
|
|
|
void willSave() override;
|
2015-12-18 15:38:26 +00:00
|
|
|
SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override;
|
2015-03-26 01:17:31 +00:00
|
|
|
void willRestore() override;
|
|
|
|
void didRestore() override;
|
|
|
|
void didConcat(const SkMatrix&) override;
|
|
|
|
void didSetMatrix(const SkMatrix&) override;
|
|
|
|
void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) override;
|
|
|
|
void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) override;
|
|
|
|
void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) override;
|
|
|
|
void onClipRegion(const SkRegion&, SkRegion::Op) override;
|
|
|
|
void onDiscard() override;
|
2015-03-23 19:51:20 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
SkCanvas* fProxyTarget;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SkAndroidSDKCanvas_DEFINED
|
|
|
|
|