1e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com 2e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com/* 3e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com * Copyright 2012 Google Inc. 4e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com * 5e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com * Use of this source code is governed by a BSD-style license that can be 6e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com * found in the LICENSE file. 7e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com */ 8e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com 9e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com#ifndef SkBBoxRecord_DEFINED 10e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com#define SkBBoxRecord_DEFINED 11e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com 12e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com#include "SkPictureRecord.h" 13837f5321a409228a27fc710eb71c87866b820cfbsenorblanco#include "SkTDArray.h" 14e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com 15e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com/** 1604ba448579b976369075c675d847ef0f779d40f4skia.committer@gmail.com * This is an abstract SkPictureRecord subclass that intercepts draw calls and computes an 17e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com * axis-aligned bounding box for each draw that it sees, subclasses implement handleBBox() 18e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com * which will be called every time we get a new bounding box. 19e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com */ 20e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.comclass SkBBoxRecord : public SkPictureRecord { 21e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.compublic: 22e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com 230bdbea75ff1a6f3c313c18cab0139728967cb93erobertphillips SkBBoxRecord(const SkISize& size, uint32_t recordFlags) 240bdbea75ff1a6f3c313c18cab0139728967cb93erobertphillips : INHERITED(size, recordFlags) { 258f831f262f5e57665587cb3033860eea39fe1621commit-bot@chromium.org } 26837f5321a409228a27fc710eb71c87866b820cfbsenorblanco virtual ~SkBBoxRecord(); 27e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com 28e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com /** 29e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com * This is called each time we get a bounding box, it will be axis-aligned, 30e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com * in device coordinates, and expanded to include stroking, shadows, etc. 31e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com */ 32e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com virtual void handleBBox(const SkRect& bbox) = 0; 33e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com 345f8c8f448673c65c5434cf1e419319eccf34117bjunov@chromium.org virtual void drawOval(const SkRect& rect, const SkPaint& paint) SK_OVERRIDE; 355f8c8f448673c65c5434cf1e419319eccf34117bjunov@chromium.org virtual void drawRRect(const SkRRect& rrect, const SkPaint& paint) SK_OVERRIDE; 367ce564cccb246ec56427085872b2e1458fe74bd1bsalomon@google.com virtual void drawRect(const SkRect& rect, const SkPaint& paint) SK_OVERRIDE; 377ce564cccb246ec56427085872b2e1458fe74bd1bsalomon@google.com virtual void drawPath(const SkPath& path, const SkPaint& paint) SK_OVERRIDE; 38e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[], 39e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com const SkPaint& paint) SK_OVERRIDE; 40e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE; 41e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com virtual void clear(SkColor) SK_OVERRIDE; 42e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, 43e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com const SkPaint* paint = NULL) SK_OVERRIDE; 447112173c3c4cd1b1e7da8cdf971d71f01dd91299reed@google.com virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src, 45eed779d866e1e239bfb9ebc6a225b7345a41adf9commit-bot@chromium.org const SkRect& dst, const SkPaint* paint, 46eed779d866e1e239bfb9ebc6a225b7345a41adf9commit-bot@chromium.org DrawBitmapRectFlags flags) SK_OVERRIDE; 47e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& mat, 48e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com const SkPaint* paint) SK_OVERRIDE; 49e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, 50e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com const SkRect& dst, const SkPaint* paint) SK_OVERRIDE; 51e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com virtual void drawSprite(const SkBitmap& bitmap, int left, int top, 52e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com const SkPaint* paint) SK_OVERRIDE; 53e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com virtual void drawVertices(VertexMode mode, int vertexCount, 54e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com const SkPoint vertices[], const SkPoint texs[], 55e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com const SkColor colors[], SkXfermode* xfer, 56e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com const uint16_t indices[], int indexCount, 57e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com const SkPaint& paint) SK_OVERRIDE; 58e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com 59ed9806f5c972513d4141c9d1b5a04ab78b3af4cbcommit-bot@chromium.orgprotected: 60ed9806f5c972513d4141c9d1b5a04ab78b3af4cbcommit-bot@chromium.org virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE; 61e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, 62e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com const SkPaint&) SK_OVERRIDE; 63e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com virtual void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], 64e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com const SkPaint&) SK_OVERRIDE; 65e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], 66e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com SkScalar constY, const SkPaint&) SK_OVERRIDE; 67e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path, 68e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com const SkMatrix* matrix, const SkPaint&) SK_OVERRIDE; 69b7425173f96e93b090787e2386ba5f022b6c2869fmalita virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, 70b7425173f96e93b090787e2386ba5f022b6c2869fmalita const SkPaint& paint) SK_OVERRIDE; 71b3c9d1c33caf325aada244204215eb790c228c12dandov virtual void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], 72b3c9d1c33caf325aada244204215eb790c228c12dandov const SkPoint texCoords[4], SkXfermode* xmode, 73b3c9d1c33caf325aada244204215eb790c228c12dandov const SkPaint& paint) SK_OVERRIDE; 74d5fa1a455aad61f3e99081fe7a9b065cb3b115c6reed virtual void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) SK_OVERRIDE; 75837f5321a409228a27fc710eb71c87866b820cfbsenorblanco virtual void willSave() SK_OVERRIDE; 76837f5321a409228a27fc710eb71c87866b820cfbsenorblanco virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags) SK_OVERRIDE; 77837f5321a409228a27fc710eb71c87866b820cfbsenorblanco virtual void willRestore() SK_OVERRIDE; 78ed9806f5c972513d4141c9d1b5a04ab78b3af4cbcommit-bot@chromium.org 79e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.comprivate: 8004ba448579b976369075c675d847ef0f779d40f4skia.committer@gmail.com /** 81e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com * Takes a bounding box in current canvas view space, accounts for stroking and effects, and 82e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com * computes an axis-aligned bounding box in device coordinates, then passes it to handleBBox() 83e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com * returns false if the draw is completely clipped out, and may safely be ignored. 84e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com **/ 85e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com bool transformBounds(const SkRect& bounds, const SkPaint* paint); 86e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com 87837f5321a409228a27fc710eb71c87866b820cfbsenorblanco /** 88837f5321a409228a27fc710eb71c87866b820cfbsenorblanco * Paints from currently-active saveLayers that need to be applied to bounding boxes of all 89837f5321a409228a27fc710eb71c87866b820cfbsenorblanco * primitives drawn inside them. We own these pointers. 90837f5321a409228a27fc710eb71c87866b820cfbsenorblanco **/ 91837f5321a409228a27fc710eb71c87866b820cfbsenorblanco SkTDArray<const SkPaint*> fSaveStack; 92837f5321a409228a27fc710eb71c87866b820cfbsenorblanco 93e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com typedef SkPictureRecord INHERITED; 94e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com}; 95e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com 96e0201a4448f5e770cc081ca3425bed528af27f8drileya@google.com#endif 97