Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1227)

Unified Diff: src/gpu/GrRecordReplaceDraw.h

Issue 535953002: Replace SkPictureReplacementPlayback with GrRecordReplaceDraw (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix leak in SkImage creation (in test) Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkDrawPictureCallback.h ('k') | src/gpu/GrRecordReplaceDraw.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrRecordReplaceDraw.h
diff --git a/src/gpu/GrRecordReplaceDraw.h b/src/gpu/GrRecordReplaceDraw.h
new file mode 100644
index 0000000000000000000000000000000000000000..f59e44883e16231f9745980019d08a1c92f20ad5
--- /dev/null
+++ b/src/gpu/GrRecordReplaceDraw.h
@@ -0,0 +1,69 @@
+/*
+ * 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 SkImage;
+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;
+ SkImage* fImage; // Owns a ref
+ 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.
+ // lastLookedUp is an in/out parameter that is used to speed up the search.
+ // It should be initialized to 0 on the first call and then passed back in
+ // unmodified on subsequent calls.
+ const ReplacementInfo* lookupByStart(size_t start, int* lastLookedUp) const;
+
+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
« no previous file with comments | « include/core/SkDrawPictureCallback.h ('k') | src/gpu/GrRecordReplaceDraw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698