aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkBBoxRecord.h
diff options
context:
space:
mode:
authorGravatar rileya@google.com <rileya@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-09-06 20:50:11 +0000
committerGravatar rileya@google.com <rileya@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-09-06 20:50:11 +0000
commite0201a4448f5e770cc081ca3425bed528af27f8d (patch)
tree3a2ac83f51b2c54f8b3c58721528a44ad0dcb1a7 /src/core/SkBBoxRecord.h
parentf06df1bb9ab201a78bfc906a9e95326c6e15a119 (diff)
Add SkPictureRecord subclass that computes bounding boxes.
Review URL: https://codereview.appspot.com/6506082 git-svn-id: http://skia.googlecode.com/svn/trunk@5423 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkBBoxRecord.h')
-rw-r--r--src/core/SkBBoxRecord.h76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/core/SkBBoxRecord.h b/src/core/SkBBoxRecord.h
new file mode 100644
index 0000000000..5a90727151
--- /dev/null
+++ b/src/core/SkBBoxRecord.h
@@ -0,0 +1,76 @@
+
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkBBoxRecord_DEFINED
+#define SkBBoxRecord_DEFINED
+
+#include "SkPictureRecord.h"
+
+/**
+ * This is an abstract SkPictureRecord subclass that intercepts draw calls and computes an
+ * axis-aligned bounding box for each draw that it sees, subclasses implement handleBBox()
+ * which will be called every time we get a new bounding box.
+ */
+class SkBBoxRecord : public SkPictureRecord {
+public:
+
+ SkBBoxRecord(uint32_t recordFlags) :INHERITED(recordFlags) { }
+ virtual ~SkBBoxRecord() { }
+
+ /**
+ * This is called each time we get a bounding box, it will be axis-aligned,
+ * in device coordinates, and expanded to include stroking, shadows, etc.
+ */
+ virtual void handleBBox(const SkRect& bbox) = 0;
+
+ virtual void drawRect(const SkRect& rect, const SkPaint& paint) SK_OVERRIDE;
+ virtual void drawPath(const SkPath& path, const SkPaint& paint) SK_OVERRIDE;
+ virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[],
+ const SkPaint& paint) SK_OVERRIDE;
+ virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE;
+ virtual void clear(SkColor) SK_OVERRIDE;
+ virtual void drawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
+ const SkPaint& paint) SK_OVERRIDE;
+ virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
+ const SkPaint* paint = NULL) SK_OVERRIDE;
+ virtual void drawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
+ const SkRect& dst, const SkPaint* paint) SK_OVERRIDE;
+ virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& mat,
+ const SkPaint* paint) SK_OVERRIDE;
+ virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
+ const SkRect& dst, const SkPaint* paint) SK_OVERRIDE;
+ virtual void drawPosText(const void* text, size_t byteLength,
+ const SkPoint pos[], const SkPaint& paint) SK_OVERRIDE;
+ virtual void drawPosTextH(const void* text, size_t byteLength,
+ const SkScalar xpos[], SkScalar constY,
+ const SkPaint& paint) SK_OVERRIDE;
+ virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
+ const SkPaint* paint) SK_OVERRIDE;
+ virtual void drawTextOnPath(const void* text, size_t byteLength,
+ const SkPath& path, const SkMatrix* matrix,
+ const SkPaint& paint) SK_OVERRIDE;
+ virtual void drawVertices(VertexMode mode, int vertexCount,
+ const SkPoint vertices[], const SkPoint texs[],
+ const SkColor colors[], SkXfermode* xfer,
+ const uint16_t indices[], int indexCount,
+ const SkPaint& paint) SK_OVERRIDE;
+ virtual void drawPicture(SkPicture& picture) SK_OVERRIDE;
+
+private:
+ /**
+ * Takes a bounding box in current canvas view space, accounts for stroking and effects, and
+ * computes an axis-aligned bounding box in device coordinates, then passes it to handleBBox()
+ * returns false if the draw is completely clipped out, and may safely be ignored.
+ **/
+ bool transformBounds(const SkRect& bounds, const SkPaint* paint);
+
+ typedef SkPictureRecord INHERITED;
+};
+
+#endif
+