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

Unified Diff: skia/ext/SkFutureDrawable.h

Issue 2653963002: [Experimental] Supporting OOPIF printing
Patch Set: Rename service, fix for webview, and connect to DiscardableMemoryManager Created 3 years, 9 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 | « skia/BUILD.gn ('k') | skia/ext/SkFutureDrawable.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: skia/ext/SkFutureDrawable.h
diff --git a/skia/ext/SkFutureDrawable.h b/skia/ext/SkFutureDrawable.h
new file mode 100644
index 0000000000000000000000000000000000000000..e002d4522caeec0da9c48e217507b8a6a71fd422
--- /dev/null
+++ b/skia/ext/SkFutureDrawable.h
@@ -0,0 +1,57 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SKIA_EXT_SK_FUTURE_DRAWABLE_H_
+#define SKIA_EXT_SK_FUTURE_DRAWABLE_H_
+
+#include <memory>
+#include <unordered_map>
+
+#include "third_party/skia/include/core/SkDrawable.h"
+#include "third_party/skia/include/core/SkPicture.h"
+#include "third_party/skia/include/core/SkScalar.h"
+
+class SK_API SkFutureDrawable : public SkDrawable {
+ public:
+ static const char kTypeName[];
+
+ SkFutureDrawable(const SkRect& bounds)
+ : fBounds(bounds), fDrawableRef(nullptr) {}
+ SkFutureDrawable(const SkRect& bounds, int id)
+ : fBounds(bounds), id(id), fDrawableRef(nullptr) {}
+
+ void flatten(SkWriteBuffer& buffer) const override;
+
+ Factory getFactory() const override { return CreateProc; }
+
+ int Id() const { return id; }
+
+ void setDrawableRef(SkDrawable* ref) { fDrawableRef = ref; }
+
+ static sk_sp<SkFlattenable> CreateProc(SkReadBuffer& buffer);
+
+ static void addDrawableRef(int id, std::unique_ptr<SkDrawable> ref) {
+ fDrawableRefMap[id] = std::move(ref);
+ }
+
+ static void resetDrawableRef() { fDrawableRefMap.clear(); }
+
+ protected:
+ SkRect onGetBounds() override { return fBounds; }
+
+ void onDraw(SkCanvas* canvas) override;
+
+ SkPicture* onNewPictureSnapshot() override;
+
+ const char* getTypeName() const override { return kTypeName; }
+
+ private:
+ const SkRect fBounds;
+ int id;
+ SkDrawable* fDrawableRef;
+
+ static std::unordered_map<int, std::unique_ptr<SkDrawable>> fDrawableRefMap;
+};
+
+#endif // SKIA_EXT_SK_FUTURE_DRAWABLE_H_
« no previous file with comments | « skia/BUILD.gn ('k') | skia/ext/SkFutureDrawable.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698