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

Side by Side 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, 8 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 unified diff | Download patch
« no previous file with comments | « skia/BUILD.gn ('k') | skia/ext/SkFutureDrawable.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef SKIA_EXT_SK_FUTURE_DRAWABLE_H_
6 #define SKIA_EXT_SK_FUTURE_DRAWABLE_H_
7
8 #include <memory>
9 #include <unordered_map>
10
11 #include "third_party/skia/include/core/SkDrawable.h"
12 #include "third_party/skia/include/core/SkPicture.h"
13 #include "third_party/skia/include/core/SkScalar.h"
14
15 class SK_API SkFutureDrawable : public SkDrawable {
16 public:
17 static const char kTypeName[];
18
19 SkFutureDrawable(const SkRect& bounds)
20 : fBounds(bounds), fDrawableRef(nullptr) {}
21 SkFutureDrawable(const SkRect& bounds, int id)
22 : fBounds(bounds), id(id), fDrawableRef(nullptr) {}
23
24 void flatten(SkWriteBuffer& buffer) const override;
25
26 Factory getFactory() const override { return CreateProc; }
27
28 int Id() const { return id; }
29
30 void setDrawableRef(SkDrawable* ref) { fDrawableRef = ref; }
31
32 static sk_sp<SkFlattenable> CreateProc(SkReadBuffer& buffer);
33
34 static void addDrawableRef(int id, std::unique_ptr<SkDrawable> ref) {
35 fDrawableRefMap[id] = std::move(ref);
36 }
37
38 static void resetDrawableRef() { fDrawableRefMap.clear(); }
39
40 protected:
41 SkRect onGetBounds() override { return fBounds; }
42
43 void onDraw(SkCanvas* canvas) override;
44
45 SkPicture* onNewPictureSnapshot() override;
46
47 const char* getTypeName() const override { return kTypeName; }
48
49 private:
50 const SkRect fBounds;
51 int id;
52 SkDrawable* fDrawableRef;
53
54 static std::unordered_map<int, std::unique_ptr<SkDrawable>> fDrawableRefMap;
55 };
56
57 #endif // SKIA_EXT_SK_FUTURE_DRAWABLE_H_
OLDNEW
« 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