Chromium Code Reviews| Index: src/gpu/GrRecordReplaceDraw.h |
| diff --git a/src/gpu/GrRecordReplaceDraw.h b/src/gpu/GrRecordReplaceDraw.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..538f82669622e624d5cb771012f10631050a03e4 |
| --- /dev/null |
| +++ b/src/gpu/GrRecordReplaceDraw.h |
| @@ -0,0 +1,65 @@ |
| +/* |
| + * Copyright 2014 Google Inc. |
| + * |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| + |
| +#ifndef GrRecordReplaceDraw_DEFINED |
| +#define GrRecordReplaceDraw_DEFINED |
| + |
| +#include "SkDrawPictureCallback.h" |
| +#include "SkRect.h" |
| +#include "SkTDArray.h" |
| + |
| +class SkBBoxHierarchy; |
| +class SkBitmap; |
| +class SkCanvas; |
| +class SkPaint; |
| +class SkRecord; |
| + |
| +// GrReplacements collects op ranges that can be replaced with |
| +// a single drawBitmap call (using a precomputed bitmap). |
| +class GrReplacements { |
| +public: |
| + // All the operations between fStart and fStop (inclusive) will be replaced with |
| + // a single drawBitmap call using fPos, fBM and fPaint. |
| + struct ReplacementInfo { |
| + unsigned fStart; |
| + unsigned fStop; |
| + SkIPoint fPos; |
| + SkBitmap* fBM; // fBM is allocated so ReplacementInfo can remain 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.
|
| + const SkPaint* fPaint; // Note: this object doesn't own the paint |
| + |
| + SkIRect fSrcRect; |
| + }; |
| + |
| + ~GrReplacements() { this->freeAll(); } |
| + |
| + // Add a new replacement range. The replacement ranges should be |
| + // sorted in increasing order and non-overlapping (esp. no nested |
| + // saveLayers). |
| + ReplacementInfo* push(); |
| + |
| + // look up a replacement range by its start offset |
| + 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
|
| + |
| +private: |
| + SkTDArray<ReplacementInfo> fReplacements; |
| + |
| + void freeAll(); |
| + |
| +#ifdef SK_DEBUG |
| + void validate() const; |
| +#endif |
| +}; |
| + |
| +// Draw an SkRecord into an SkCanvas replacing saveLayer/restore blocks with |
| +// drawBitmap calls. A convenience wrapper around SkRecords::Draw. |
| +void GrRecordReplaceDraw(const SkRecord&, |
| + SkCanvas*, |
| + const SkBBoxHierarchy*, |
| + const GrReplacements*, |
| + SkDrawPictureCallback*); |
| + |
| +#endif // GrRecordReplaceDraw_DEFINED |