Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1039)

Unified Diff: src/utils/SkDeferredCanvas.h

Issue 2120333002: deferred canvas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: override drawTextRSXform Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samplecode/SampleApp.cpp ('k') | src/utils/SkDeferredCanvas.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils/SkDeferredCanvas.h
diff --git a/include/utils/SkNWayCanvas.h b/src/utils/SkDeferredCanvas.h
similarity index 57%
copy from include/utils/SkNWayCanvas.h
copy to src/utils/SkDeferredCanvas.h
index a4b9c594122e6d1a51e46c4f77d9db67a245fa5d..6400734deffba0da5530edc35ff7df2453ddb475 100644
--- a/include/utils/SkNWayCanvas.h
+++ b/src/utils/SkDeferredCanvas.h
@@ -1,35 +1,39 @@
/*
- * Copyright 2011 Google Inc.
+ * Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#ifndef SkNWayCanvas_DEFINED
-#define SkNWayCanvas_DEFINED
+#ifndef SkDeferredCanvas_DEFINED
+#define SkDeferredCanvas_DEFINED
#include "../private/SkTDArray.h"
#include "SkCanvas.h"
-class SK_API SkNWayCanvas : public SkCanvas {
+class SK_API SkDeferredCanvas : public SkCanvas {
public:
- SkNWayCanvas(int width, int height);
- virtual ~SkNWayCanvas();
-
- virtual void addCanvas(SkCanvas*);
- virtual void removeCanvas(SkCanvas*);
- virtual void removeAll();
-
- ///////////////////////////////////////////////////////////////////////////
- // These are forwarded to the N canvases we're referencing
+ SkDeferredCanvas(SkCanvas*);
+ ~SkDeferredCanvas() override;
#ifdef SK_SUPPORT_LEGACY_DRAWFILTER
SkDrawFilter* setDrawFilter(SkDrawFilter*) override;
#endif
protected:
- SkTDArray<SkCanvas*> fList;
+ sk_sp<SkSurface> onNewSurface(const SkImageInfo&, const SkSurfaceProps&) override;
+ SkISize getBaseLayerSize() const override;
+ bool getClipBounds(SkRect* bounds) const override;
+ bool getClipDeviceBounds(SkIRect* bounds) const override;
+ bool isClipEmpty() const override;
+ bool isClipRect() const override;
+ bool onPeekPixels(SkPixmap*) override;
+ bool onAccessTopLayerPixels(SkPixmap*) override;
+ SkImageInfo onImageInfo() const override;
+ bool onGetProps(SkSurfaceProps*) const override;
+ void onFlush() override;
+// SkCanvas* canvasForDrawIter() override;
void willSave() override;
SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override;
@@ -47,10 +51,10 @@ protected:
SkScalar constY, const SkPaint&) override;
virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
const SkMatrix* matrix, const SkPaint&) override;
+ void onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform[],
+ const SkRect* cullRect, const SkPaint&) override;
virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
const SkPaint& paint) override;
- void onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform xform[],
- const SkRect* cull, const SkPaint& paint) override;
virtual void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
const SkPoint texCoords[4], SkXfermode* xmode,
const SkPaint& paint) override;
@@ -69,23 +73,73 @@ protected:
const SkPaint*, SrcRectConstraint) override;
void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
const SkPaint*) override;
+ void onDrawImageNine(const SkImage* image, const SkIRect& center,
+ const SkRect& dst, const SkPaint*) override;
void onDrawVertices(VertexMode vmode, int vertexCount,
const SkPoint vertices[], const SkPoint texs[],
const SkColor colors[], SkXfermode* xmode,
const uint16_t indices[], int indexCount,
const SkPaint&) override;
+ void onDrawAtlas(const SkImage* image, const SkRSXform xform[],
+ const SkRect rects[], const SkColor colors[],
+ int count, SkXfermode::Mode mode,
+ const SkRect* cull, const SkPaint* paint) 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 onDrawDrawable(SkDrawable*, const SkMatrix*) override;
void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override;
void onDrawAnnotation(const SkRect&, const char[], SkData*) override;
class Iter;
private:
+ SkCanvas* fCanvas;
+
+ enum Type {
+ kSave_Type,
+ kClipRect_Type,
+ kTrans_Type,
+ kScaleTrans_Type,
+ };
+ struct Rec {
+ Type fType;
+ union {
+ SkRect fBounds;
+ SkVector fTranslate;
+ struct {
+ SkVector fScale;
+ SkVector fTrans; // post translate
+ } fScaleTrans;
+ } fData;
+
+ bool isConcat(SkMatrix*) const;
+ void getConcat(SkMatrix* mat) const {
+ SkDEBUGCODE(bool isconcat = ) this->isConcat(mat);
+ SkASSERT(isconcat);
+ }
+ void setConcat(const SkMatrix&);
+ };
+ SkTDArray<Rec> fRecs;
+
+ void push_save();
+ void push_cliprect(const SkRect&);
+ bool push_concat(const SkMatrix&);
+
+ void emit(const Rec& rec);
+
+ void flush_all();
+ void flush_before_saves();
+ void flush_le(int index);
+ void flush_translate(SkScalar* x, SkScalar* y, const SkPaint&);
+ void flush_translate(SkScalar* x, SkScalar* y, const SkRect& bounds, const SkPaint* = nullptr);
+ void flush_check(SkRect* bounds, const SkPaint*, unsigned flags = 0);
+
+ void internal_flush_translate(SkScalar* x, SkScalar* y, const SkRect* boundsOrNull);
+
typedef SkCanvas INHERITED;
};
« no previous file with comments | « samplecode/SampleApp.cpp ('k') | src/utils/SkDeferredCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698