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

Side by Side Diff: include/core/SkWriteBuffer.h

Issue 2201323003: add pipecanvas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: no need for willSetMatrix Created 4 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 unified diff | Download patch
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #ifndef SkWriteBuffer_DEFINED 9 #ifndef SkWriteBuffer_DEFINED
10 #define SkWriteBuffer_DEFINED 10 #define SkWriteBuffer_DEFINED
11 11
12 #include "SkData.h" 12 #include "SkData.h"
13 #include "SkImage.h" 13 #include "SkImage.h"
14 #include "SkPath.h" 14 #include "SkPath.h"
15 #include "SkPicture.h" 15 #include "SkPicture.h"
16 #include "SkPixelSerializer.h" 16 #include "SkPixelSerializer.h"
17 #include "SkRefCnt.h" 17 #include "SkRefCnt.h"
18 #include "SkWriter32.h" 18 #include "SkWriter32.h"
19 #include "../private/SkTHash.h" 19 #include "../private/SkTHash.h"
20 20
21 class SkBitmap; 21 class SkBitmap;
22 class SkDeduper;
22 class SkFactorySet; 23 class SkFactorySet;
23 class SkFlattenable; 24 class SkFlattenable;
24 class SkRefCntSet; 25 class SkRefCntSet;
25 26
26 class SkWriteBuffer { 27 class SkWriteBuffer {
27 public: 28 public:
28 SkWriteBuffer() {} 29 SkWriteBuffer() {}
29 virtual ~SkWriteBuffer() {} 30 virtual ~SkWriteBuffer() {}
30 31
31 virtual bool isCrossProcess() const = 0; 32 virtual bool isCrossProcess() const = 0;
(...skipping 21 matching lines...) Expand all
53 virtual void writeMatrix(const SkMatrix& matrix) = 0; 54 virtual void writeMatrix(const SkMatrix& matrix) = 0;
54 virtual void writeIRect(const SkIRect& rect) = 0; 55 virtual void writeIRect(const SkIRect& rect) = 0;
55 virtual void writeRect(const SkRect& rect) = 0; 56 virtual void writeRect(const SkRect& rect) = 0;
56 virtual void writeRegion(const SkRegion& region) = 0; 57 virtual void writeRegion(const SkRegion& region) = 0;
57 virtual void writePath(const SkPath& path) = 0; 58 virtual void writePath(const SkPath& path) = 0;
58 virtual size_t writeStream(SkStream* stream, size_t length) = 0; 59 virtual size_t writeStream(SkStream* stream, size_t length) = 0;
59 virtual void writeBitmap(const SkBitmap& bitmap) = 0; 60 virtual void writeBitmap(const SkBitmap& bitmap) = 0;
60 virtual void writeImage(const SkImage*) = 0; 61 virtual void writeImage(const SkImage*) = 0;
61 virtual void writeTypeface(SkTypeface* typeface) = 0; 62 virtual void writeTypeface(SkTypeface* typeface) = 0;
62 virtual void writePaint(const SkPaint& paint) = 0; 63 virtual void writePaint(const SkPaint& paint) = 0;
64
65 void setDeduper(SkDeduper* deduper) { fDeduper = deduper; }
66
67 protected:
68 bool newWriteImage(const SkImage*);
69 bool newWriteTypeface(SkTypeface*);
70
71 SkDeduper* fDeduper = nullptr;
63 }; 72 };
64 73
65 /** 74 /**
66 * Concrete implementation that serializes to a flat binary blob. 75 * Concrete implementation that serializes to a flat binary blob.
67 */ 76 */
68 class SkBinaryWriteBuffer final : public SkWriteBuffer { 77 class SkBinaryWriteBuffer : public SkWriteBuffer {
69 public: 78 public:
70 enum Flags { 79 enum Flags {
71 kCrossProcess_Flag = 1 << 0, 80 kCrossProcess_Flag = 1 << 0,
72 }; 81 };
73 82
74 SkBinaryWriteBuffer(uint32_t flags = 0); 83 SkBinaryWriteBuffer(uint32_t flags = 0);
75 SkBinaryWriteBuffer(void* initialStorage, size_t storageSize, uint32_t flags = 0); 84 SkBinaryWriteBuffer(void* initialStorage, size_t storageSize, uint32_t flags = 0);
76 ~SkBinaryWriteBuffer(); 85 ~SkBinaryWriteBuffer();
77 86
78 bool isCrossProcess() const override { 87 bool isCrossProcess() const override {
79 return SkToBool(fFlags & kCrossProcess_Flag); 88 return SkToBool(fFlags & kCrossProcess_Flag);
80 } 89 }
81 90
91 void write(const void* buffer, size_t bytes) {
92 fWriter.write(buffer, bytes);
93 }
94
82 void reset(void* storage = NULL, size_t storageSize = 0) { 95 void reset(void* storage = NULL, size_t storageSize = 0) {
83 fWriter.reset(storage, storageSize); 96 fWriter.reset(storage, storageSize);
84 } 97 }
85 98
86 size_t bytesWritten() const { return fWriter.bytesWritten(); } 99 size_t bytesWritten() const { return fWriter.bytesWritten(); }
87 100
88 void writeByteArray(const void* data, size_t size) override; 101 void writeByteArray(const void* data, size_t size) override;
89 void writeBool(bool value) override; 102 void writeBool(bool value) override;
90 void writeScalar(SkScalar value) override; 103 void writeScalar(SkScalar value) override;
91 void writeScalarArray(const SkScalar* value, uint32_t count) override; 104 void writeScalarArray(const SkScalar* value, uint32_t count) override;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 147
135 SkRefCntSet* fTFSet; 148 SkRefCntSet* fTFSet;
136 149
137 SkAutoTUnref<SkPixelSerializer> fPixelSerializer; 150 SkAutoTUnref<SkPixelSerializer> fPixelSerializer;
138 151
139 // Only used if we do not have an fFactorySet 152 // Only used if we do not have an fFactorySet
140 SkTHashMap<SkString, uint32_t> fFlattenableDict; 153 SkTHashMap<SkString, uint32_t> fFlattenableDict;
141 }; 154 };
142 155
143 #endif // SkWriteBuffer_DEFINED 156 #endif // SkWriteBuffer_DEFINED
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698