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

Unified Diff: src/utils/SkShadowPaintFilterCanvas.h

Issue 2198933002: Making a sample for shadow maps for more intensive development (Closed) Base URL: https://skia.googlesource.com/skia@shadow-gm
Patch Set: argh fixed utils include error Created 4 years, 4 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 | « src/core/SkShadowShader.cpp ('k') | src/utils/SkShadowPaintFilterCanvas.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils/SkShadowPaintFilterCanvas.h
diff --git a/src/utils/SkShadowPaintFilterCanvas.h b/src/utils/SkShadowPaintFilterCanvas.h
new file mode 100644
index 0000000000000000000000000000000000000000..ae449d64f9ef873c41b7bbeb89a72d2a1577106f
--- /dev/null
+++ b/src/utils/SkShadowPaintFilterCanvas.h
@@ -0,0 +1,113 @@
+/*
+ * 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 SkShadowPaintFilterCanvas_DEFINED
+#define SkShadowPaintFilterCanvas_DEFINED
+
+#include "SkPaintFilterCanvas.h"
+
+#ifdef SK_EXPERIMENTAL_SHADOWING
+
+/** \class SkShadowPaintFilterCanvas
+ *
+ * A utility proxy class for implementing shadow maps.
+ *
+ * We override the onFilter method to draw depths into the canvas
+ * depending on the current draw depth of the canvas, throwing out
+ * the actual draw color.
+ *
+ * Note that we can only do this for one light at a time!
+ * It is up to the user to set the 0th light in fLights to
+ * the light the want to render the depth map with.
+ */
+class SkShadowPaintFilterCanvas : public SkPaintFilterCanvas {
+public:
+
+ SkShadowPaintFilterCanvas(SkCanvas *canvas);
+
+ // TODO use a shader instead
+ bool onFilter(SkTCopyOnFirstWrite<SkPaint>* paint, Type type) const override;
+
+ static SkISize ComputeDepthMapSize(const SkLights::Light& light, int maxDepth,
+ int width, int height);
+
+protected:
+ void onDrawPicture(const SkPicture *picture, const SkMatrix *matrix,
+ const SkPaint *paint) override;
+
+ void updateMatrix();
+
+ void onDrawPaint(const SkPaint &paint) override;
+
+ void onDrawPoints(PointMode mode, size_t count, const SkPoint pts[],
+ const SkPaint &paint) override;
+
+ void onDrawRect(const SkRect &rect, const SkPaint &paint) override;
+
+ void onDrawRRect(const SkRRect &rrect, const SkPaint &paint) override;
+
+ void onDrawDRRect(const SkRRect &outer, const SkRRect &inner,
+ const SkPaint &paint) override;
+
+ void onDrawOval(const SkRect &rect, const SkPaint &paint) override;
+
+ void onDrawPath(const SkPath &path, const SkPaint &paint) override;
+
+ void onDrawBitmap(const SkBitmap &bm, SkScalar left, SkScalar top,
+ const SkPaint *paint) override;
+
+ void onDrawBitmapRect(const SkBitmap &bm, const SkRect *src, const SkRect &dst,
+ const SkPaint *paint, SrcRectConstraint constraint) override;
+
+ void onDrawBitmapNine(const SkBitmap &bm, const SkIRect &center,
+ const SkRect &dst, const SkPaint *paint) override;
+
+ void onDrawImage(const SkImage *image, SkScalar left, SkScalar top,
+ const SkPaint *paint) override;
+
+ void onDrawImageRect(const SkImage *image, const SkRect *src,
+ const SkRect &dst, const SkPaint *paint,
+ SrcRectConstraint constraint) override;
+
+ void onDrawImageNine(const SkImage *image, const SkIRect &center,
+ const SkRect &dst, const SkPaint *paint) 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 &paint) override;
+
+ void onDrawPatch(const SkPoint cubics[], const SkColor colors[],
+ const SkPoint texCoords[], SkXfermode *xmode,
+ const SkPaint &paint) override;
+
+ void onDrawText(const void *text, size_t byteLength, SkScalar x, SkScalar y,
+ const SkPaint &paint) override;
+
+ void onDrawPosText(const void *text, size_t byteLength, const SkPoint pos[],
+ const SkPaint &paint) override;
+
+ void onDrawPosTextH(const void *text, size_t byteLength, const SkScalar xpos[],
+ SkScalar constY, const SkPaint &paint) override;
+
+ void onDrawTextOnPath(const void *text, size_t byteLength, const SkPath &path,
+ const SkMatrix *matrix, const SkPaint &paint) override;
+
+ void onDrawTextRSXform(const void *text, size_t byteLength,
+ const SkRSXform xform[], const SkRect *cull,
+ const SkPaint &paint) override;
+
+ void onDrawTextBlob(const SkTextBlob *blob, SkScalar x,
+ SkScalar y, const SkPaint &paint) override;
+private:
+ typedef SkPaintFilterCanvas INHERITED;
+};
+
+
+#endif
+#endif
« no previous file with comments | « src/core/SkShadowShader.cpp ('k') | src/utils/SkShadowPaintFilterCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698