rileya@google.com | e0201a4 | 2012-09-06 20:50:11 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2012 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
| 8 | |
| 9 | #ifndef SkBBoxRecord_DEFINED |
| 10 | #define SkBBoxRecord_DEFINED |
| 11 | |
| 12 | #include "SkPictureRecord.h" |
| 13 | |
| 14 | /** |
skia.committer@gmail.com | 04ba448 | 2012-09-07 02:01:30 +0000 | [diff] [blame] | 15 | * This is an abstract SkPictureRecord subclass that intercepts draw calls and computes an |
rileya@google.com | e0201a4 | 2012-09-06 20:50:11 +0000 | [diff] [blame] | 16 | * axis-aligned bounding box for each draw that it sees, subclasses implement handleBBox() |
| 17 | * which will be called every time we get a new bounding box. |
| 18 | */ |
| 19 | class SkBBoxRecord : public SkPictureRecord { |
| 20 | public: |
| 21 | |
robertphillips@google.com | 9b051a3 | 2013-08-20 20:06:40 +0000 | [diff] [blame^] | 22 | SkBBoxRecord(uint32_t recordFlags, SkDevice* device) |
reed@google.com | d86e7ab | 2012-09-27 20:31:31 +0000 | [diff] [blame] | 23 | : INHERITED(recordFlags, device) { } |
rileya@google.com | e0201a4 | 2012-09-06 20:50:11 +0000 | [diff] [blame] | 24 | virtual ~SkBBoxRecord() { } |
| 25 | |
| 26 | /** |
| 27 | * This is called each time we get a bounding box, it will be axis-aligned, |
| 28 | * in device coordinates, and expanded to include stroking, shadows, etc. |
| 29 | */ |
| 30 | virtual void handleBBox(const SkRect& bbox) = 0; |
| 31 | |
junov@chromium.org | 5f8c8f4 | 2012-12-17 16:29:34 +0000 | [diff] [blame] | 32 | virtual void drawOval(const SkRect& rect, const SkPaint& paint) SK_OVERRIDE; |
| 33 | virtual void drawRRect(const SkRRect& rrect, const SkPaint& paint) SK_OVERRIDE; |
rileya@google.com | e0201a4 | 2012-09-06 20:50:11 +0000 | [diff] [blame] | 34 | virtual void drawRect(const SkRect& rect, const SkPaint& paint) SK_OVERRIDE; |
| 35 | virtual void drawPath(const SkPath& path, const SkPaint& paint) SK_OVERRIDE; |
| 36 | virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[], |
| 37 | const SkPaint& paint) SK_OVERRIDE; |
| 38 | virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE; |
| 39 | virtual void clear(SkColor) SK_OVERRIDE; |
skia.committer@gmail.com | 04ba448 | 2012-09-07 02:01:30 +0000 | [diff] [blame] | 40 | virtual void drawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, |
rileya@google.com | e0201a4 | 2012-09-06 20:50:11 +0000 | [diff] [blame] | 41 | const SkPaint& paint) SK_OVERRIDE; |
| 42 | virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, |
| 43 | const SkPaint* paint = NULL) SK_OVERRIDE; |
reed@google.com | 7112173 | 2012-09-18 15:14:33 +0000 | [diff] [blame] | 44 | virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src, |
commit-bot@chromium.org | eed779d | 2013-08-16 10:24:37 +0000 | [diff] [blame] | 45 | const SkRect& dst, const SkPaint* paint, |
| 46 | DrawBitmapRectFlags flags) SK_OVERRIDE; |
rileya@google.com | e0201a4 | 2012-09-06 20:50:11 +0000 | [diff] [blame] | 47 | virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& mat, |
| 48 | const SkPaint* paint) SK_OVERRIDE; |
| 49 | virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, |
| 50 | const SkRect& dst, const SkPaint* paint) SK_OVERRIDE; |
| 51 | virtual void drawPosText(const void* text, size_t byteLength, |
| 52 | const SkPoint pos[], const SkPaint& paint) SK_OVERRIDE; |
| 53 | virtual void drawPosTextH(const void* text, size_t byteLength, |
skia.committer@gmail.com | 04ba448 | 2012-09-07 02:01:30 +0000 | [diff] [blame] | 54 | const SkScalar xpos[], SkScalar constY, |
rileya@google.com | e0201a4 | 2012-09-06 20:50:11 +0000 | [diff] [blame] | 55 | const SkPaint& paint) SK_OVERRIDE; |
| 56 | virtual void drawSprite(const SkBitmap& bitmap, int left, int top, |
| 57 | const SkPaint* paint) SK_OVERRIDE; |
| 58 | virtual void drawTextOnPath(const void* text, size_t byteLength, |
| 59 | const SkPath& path, const SkMatrix* matrix, |
| 60 | const SkPaint& paint) SK_OVERRIDE; |
| 61 | virtual void drawVertices(VertexMode mode, int vertexCount, |
| 62 | const SkPoint vertices[], const SkPoint texs[], |
| 63 | const SkColor colors[], SkXfermode* xfer, |
| 64 | const uint16_t indices[], int indexCount, |
| 65 | const SkPaint& paint) SK_OVERRIDE; |
| 66 | virtual void drawPicture(SkPicture& picture) SK_OVERRIDE; |
| 67 | |
| 68 | private: |
skia.committer@gmail.com | 04ba448 | 2012-09-07 02:01:30 +0000 | [diff] [blame] | 69 | /** |
rileya@google.com | e0201a4 | 2012-09-06 20:50:11 +0000 | [diff] [blame] | 70 | * Takes a bounding box in current canvas view space, accounts for stroking and effects, and |
| 71 | * computes an axis-aligned bounding box in device coordinates, then passes it to handleBBox() |
| 72 | * returns false if the draw is completely clipped out, and may safely be ignored. |
| 73 | **/ |
| 74 | bool transformBounds(const SkRect& bounds, const SkPaint* paint); |
| 75 | |
| 76 | typedef SkPictureRecord INHERITED; |
| 77 | }; |
| 78 | |
| 79 | #endif |