michael@0: michael@0: /* michael@0: * Copyright 2012 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: #ifndef SkBBoxRecord_DEFINED michael@0: #define SkBBoxRecord_DEFINED michael@0: michael@0: #include "SkPictureRecord.h" michael@0: michael@0: /** michael@0: * This is an abstract SkPictureRecord subclass that intercepts draw calls and computes an michael@0: * axis-aligned bounding box for each draw that it sees, subclasses implement handleBBox() michael@0: * which will be called every time we get a new bounding box. michael@0: */ michael@0: class SkBBoxRecord : public SkPictureRecord { michael@0: public: michael@0: michael@0: SkBBoxRecord(const SkISize& size, uint32_t recordFlags) : INHERITED(size, recordFlags) {} michael@0: virtual ~SkBBoxRecord() { } michael@0: michael@0: /** michael@0: * This is called each time we get a bounding box, it will be axis-aligned, michael@0: * in device coordinates, and expanded to include stroking, shadows, etc. michael@0: */ michael@0: virtual void handleBBox(const SkRect& bbox) = 0; michael@0: michael@0: virtual void drawOval(const SkRect& rect, const SkPaint& paint) SK_OVERRIDE; michael@0: virtual void drawRRect(const SkRRect& rrect, const SkPaint& paint) SK_OVERRIDE; michael@0: virtual void drawRect(const SkRect& rect, const SkPaint& paint) SK_OVERRIDE; michael@0: virtual void drawPath(const SkPath& path, const SkPaint& paint) SK_OVERRIDE; michael@0: virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[], michael@0: const SkPaint& paint) SK_OVERRIDE; michael@0: virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE; michael@0: virtual void clear(SkColor) SK_OVERRIDE; michael@0: virtual void drawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, michael@0: const SkPaint& paint) SK_OVERRIDE; michael@0: virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, michael@0: const SkPaint* paint = NULL) SK_OVERRIDE; michael@0: virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src, michael@0: const SkRect& dst, const SkPaint* paint, michael@0: DrawBitmapRectFlags flags) SK_OVERRIDE; michael@0: virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& mat, michael@0: const SkPaint* paint) SK_OVERRIDE; michael@0: virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, michael@0: const SkRect& dst, const SkPaint* paint) SK_OVERRIDE; michael@0: virtual void drawPosText(const void* text, size_t byteLength, michael@0: const SkPoint pos[], const SkPaint& paint) SK_OVERRIDE; michael@0: virtual void drawPosTextH(const void* text, size_t byteLength, michael@0: const SkScalar xpos[], SkScalar constY, michael@0: const SkPaint& paint) SK_OVERRIDE; michael@0: virtual void drawSprite(const SkBitmap& bitmap, int left, int top, michael@0: const SkPaint* paint) SK_OVERRIDE; michael@0: virtual void drawTextOnPath(const void* text, size_t byteLength, michael@0: const SkPath& path, const SkMatrix* matrix, michael@0: const SkPaint& paint) SK_OVERRIDE; michael@0: virtual void drawVertices(VertexMode mode, int vertexCount, michael@0: const SkPoint vertices[], const SkPoint texs[], michael@0: const SkColor colors[], SkXfermode* xfer, michael@0: const uint16_t indices[], int indexCount, michael@0: const SkPaint& paint) SK_OVERRIDE; michael@0: virtual void drawPicture(SkPicture& picture) SK_OVERRIDE; michael@0: michael@0: protected: michael@0: virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE; michael@0: michael@0: private: michael@0: /** michael@0: * Takes a bounding box in current canvas view space, accounts for stroking and effects, and michael@0: * computes an axis-aligned bounding box in device coordinates, then passes it to handleBBox() michael@0: * returns false if the draw is completely clipped out, and may safely be ignored. michael@0: **/ michael@0: bool transformBounds(const SkRect& bounds, const SkPaint* paint); michael@0: michael@0: typedef SkPictureRecord INHERITED; michael@0: }; michael@0: michael@0: #endif