OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2014 Google Inc. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license that can be | |
5 * found in the LICENSE file. | |
6 */ | |
7 | |
8 #ifndef GrRecordReplaceDraw_DEFINED | |
9 #define GrRecordReplaceDraw_DEFINED | |
10 | |
11 #include "SkDrawPictureCallback.h" | |
12 #include "SkRect.h" | |
13 #include "SkTDArray.h" | |
14 | |
15 class SkBBoxHierarchy; | |
16 class SkBitmap; | |
17 class SkCanvas; | |
18 class SkPaint; | |
19 class SkRecord; | |
20 | |
21 // GrReplacements collects op ranges that can be replaced with | |
22 // a single drawBitmap call (using a precomputed bitmap). | |
23 class GrReplacements { | |
24 public: | |
25 // All the operations between fStart and fStop (inclusive) will be replaced with | |
26 // a single drawBitmap call using fPos, fBM and fPaint. | |
27 struct ReplacementInfo { | |
28 unsigned fStart; | |
29 unsigned fStop; | |
30 SkIPoint fPos; | |
31 SkBitmap* fBM; // fBM is allocated so ReplacementInfo can rema in POD | |
bsalomon
2014/09/03 15:43:50
Does it have to be an SkBitmap? Could it be an SkI
mtklein
2014/09/03 15:46:12
Is this an alternative to SkTArray<ReplacementInfo
robertphillips
2014/09/03 17:36:24
The former.
robertphillips
2014/09/03 17:36:24
Done.
| |
32 const SkPaint* fPaint; // Note: this object doesn't own the paint | |
33 | |
34 SkIRect fSrcRect; | |
35 }; | |
36 | |
37 ~GrReplacements() { this->freeAll(); } | |
38 | |
39 // Add a new replacement range. The replacement ranges should be | |
40 // sorted in increasing order and non-overlapping (esp. no nested | |
41 // saveLayers). | |
42 ReplacementInfo* push(); | |
43 | |
44 // look up a replacement range by its start offset | |
45 const ReplacementInfo* lookupByStart(size_t start, int* lastLookedUp) const; | |
mtklein
2014/09/03 15:46:12
Not clear here that lastLookedUp is both input and
robertphillips
2014/09/03 17:36:24
I've added a comment. Other then that I'm open to
| |
46 | |
47 private: | |
48 SkTDArray<ReplacementInfo> fReplacements; | |
49 | |
50 void freeAll(); | |
51 | |
52 #ifdef SK_DEBUG | |
53 void validate() const; | |
54 #endif | |
55 }; | |
56 | |
57 // Draw an SkRecord into an SkCanvas replacing saveLayer/restore blocks with | |
58 // drawBitmap calls. A convenience wrapper around SkRecords::Draw. | |
59 void GrRecordReplaceDraw(const SkRecord&, | |
60 SkCanvas*, | |
61 const SkBBoxHierarchy*, | |
62 const GrReplacements*, | |
63 SkDrawPictureCallback*); | |
64 | |
65 #endif // GrRecordReplaceDraw_DEFINED | |
OLD | NEW |