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

Unified Diff: src/core/SkCanvasPriv.h

Issue 1992283002: Add drawBitmapLattice() API (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add implementation for SkRecorder and SkPictureRecord Created 4 years, 5 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
Index: src/core/SkCanvasPriv.h
diff --git a/src/core/SkCanvasPriv.h b/src/core/SkCanvasPriv.h
index dfae154ecb8e4910669b39a55bbf55e8c280aa0a..dd920ea249085ec8116ba73ae8a4c5e076d6c97a 100644
--- a/src/core/SkCanvasPriv.h
+++ b/src/core/SkCanvasPriv.h
@@ -9,6 +9,7 @@
#define SkCanvasPriv_DEFINED
#include "SkCanvas.h"
+#include "SkData.h"
class SkAutoCanvasMatrixPaint : SkNoncopyable {
public:
@@ -20,4 +21,30 @@ private:
int fSaveCount;
};
+/**
+ * Allows NinePatchDivs to be serialized to and from data.
+ */
+struct SkNinePatchDivs : SkCanvas::NinePatchDivs {
+
+ sk_sp<SkData> asData() const {
+ sk_sp<SkData> data = SkData::MakeUninitialized(sizeof(int32_t) * (2 + fXCount + fYCount));
+ int32_t* ptr = (int32_t*) data->writable_data();
+ ptr[0] = fXCount;
+ ptr[1] = fYCount;
+ memcpy(&ptr[2], fXDivs, sizeof(int32_t) * fXCount);
+ memcpy(&ptr[2 + fXCount], fYDivs, sizeof(int32_t) * fYCount);
+ return data;
+ }
+
+ static NinePatchDivs FromData(SkData* data) {
+ int32_t* ptr = (int32_t*) data->writable_data();
+ NinePatchDivs divs;
+ divs.fXCount = ptr[0];
+ divs.fYCount = ptr[1];
+ divs.fXDivs = &ptr[2];
+ divs.fYDivs = &ptr[2 + divs.fXCount];
+ return divs;
+ }
+};
+
#endif
« include/core/SkCanvas.h ('K') | « src/core/SkCanvas.cpp ('k') | src/core/SkDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698