| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #ifndef SkBBoxRecord_DEFINED | 9 #ifndef SkBBoxRecord_DEFINED |
| 10 #define SkBBoxRecord_DEFINED | 10 #define SkBBoxRecord_DEFINED |
| 11 | 11 |
| 12 #include "SkPictureRecord.h" | 12 #include "SkPictureRecord.h" |
| 13 #include "SkTDStack.h" | |
| 14 | 13 |
| 15 /** | 14 /** |
| 16 * This is an abstract SkPictureRecord subclass that intercepts draw calls and
computes an | 15 * This is an abstract SkPictureRecord subclass that intercepts draw calls and
computes an |
| 17 * axis-aligned bounding box for each draw that it sees, subclasses implement h
andleBBox() | 16 * axis-aligned bounding box for each draw that it sees, subclasses implement h
andleBBox() |
| 18 * which will be called every time we get a new bounding box. | 17 * which will be called every time we get a new bounding box. |
| 19 */ | 18 */ |
| 20 class SkBBoxRecord : public SkPictureRecord { | 19 class SkBBoxRecord : public SkPictureRecord { |
| 21 public: | 20 public: |
| 22 | 21 |
| 23 SkBBoxRecord(const SkISize& size, uint32_t recordFlags) | 22 SkBBoxRecord(const SkISize& size, uint32_t recordFlags) |
| 24 : INHERITED(size, recordFlags) { | 23 : INHERITED(size, recordFlags) { |
| 25 } | 24 } |
| 26 virtual ~SkBBoxRecord(); | 25 virtual ~SkBBoxRecord() { } |
| 27 | 26 |
| 28 /** | 27 /** |
| 29 * This is called each time we get a bounding box, it will be axis-aligned, | 28 * This is called each time we get a bounding box, it will be axis-aligned, |
| 30 * in device coordinates, and expanded to include stroking, shadows, etc. | 29 * in device coordinates, and expanded to include stroking, shadows, etc. |
| 31 */ | 30 */ |
| 32 virtual void handleBBox(const SkRect& bbox) = 0; | 31 virtual void handleBBox(const SkRect& bbox) = 0; |
| 33 | 32 |
| 34 virtual void drawOval(const SkRect& rect, const SkPaint& paint) SK_OVERRIDE; | 33 virtual void drawOval(const SkRect& rect, const SkPaint& paint) SK_OVERRIDE; |
| 35 virtual void drawRRect(const SkRRect& rrect, const SkPaint& paint) SK_OVERRI
DE; | 34 virtual void drawRRect(const SkRRect& rrect, const SkPaint& paint) SK_OVERRI
DE; |
| 36 virtual void drawRect(const SkRect& rect, const SkPaint& paint) SK_OVERRIDE; | 35 virtual void drawRect(const SkRect& rect, const SkPaint& paint) SK_OVERRIDE; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 60 virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK
_OVERRIDE; | 59 virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK
_OVERRIDE; |
| 61 virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, SkS
calar y, | 60 virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, SkS
calar y, |
| 62 const SkPaint&) SK_OVERRIDE; | 61 const SkPaint&) SK_OVERRIDE; |
| 63 virtual void onDrawPosText(const void* text, size_t byteLength, const SkPoin
t pos[], | 62 virtual void onDrawPosText(const void* text, size_t byteLength, const SkPoin
t pos[], |
| 64 const SkPaint&) SK_OVERRIDE; | 63 const SkPaint&) SK_OVERRIDE; |
| 65 virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkSca
lar xpos[], | 64 virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkSca
lar xpos[], |
| 66 SkScalar constY, const SkPaint&) SK_OVERRIDE; | 65 SkScalar constY, const SkPaint&) SK_OVERRIDE; |
| 67 virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkP
ath& path, | 66 virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkP
ath& path, |
| 68 const SkMatrix* matrix, const SkPaint&) SK_OVE
RRIDE; | 67 const SkMatrix* matrix, const SkPaint&) SK_OVE
RRIDE; |
| 69 virtual void onDrawPicture(const SkPicture* picture) SK_OVERRIDE; | 68 virtual void onDrawPicture(const SkPicture* picture) SK_OVERRIDE; |
| 70 virtual void willSave() SK_OVERRIDE; | |
| 71 virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveF
lags) SK_OVERRIDE; | |
| 72 virtual void willRestore() SK_OVERRIDE; | |
| 73 | 69 |
| 74 private: | 70 private: |
| 75 /** | 71 /** |
| 76 * Takes a bounding box in current canvas view space, accounts for stroking
and effects, and | 72 * Takes a bounding box in current canvas view space, accounts for stroking
and effects, and |
| 77 * computes an axis-aligned bounding box in device coordinates, then passes
it to handleBBox() | 73 * computes an axis-aligned bounding box in device coordinates, then passes
it to handleBBox() |
| 78 * returns false if the draw is completely clipped out, and may safely be ig
nored. | 74 * returns false if the draw is completely clipped out, and may safely be ig
nored. |
| 79 **/ | 75 **/ |
| 80 bool transformBounds(const SkRect& bounds, const SkPaint* paint); | 76 bool transformBounds(const SkRect& bounds, const SkPaint* paint); |
| 81 | 77 |
| 82 /** | |
| 83 * Paints from currently-active saveLayers that need to be applied to boundi
ng boxes of all | |
| 84 * primitives drawn inside them. We own these pointers. | |
| 85 **/ | |
| 86 SkTDStack<const SkPaint*> fSaveStack; | |
| 87 | |
| 88 typedef SkPictureRecord INHERITED; | 78 typedef SkPictureRecord INHERITED; |
| 89 }; | 79 }; |
| 90 | 80 |
| 91 #endif | 81 #endif |
| OLD | NEW |