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

Unified Diff: src/core/SkPictureRecord.cpp

Issue 499413002: SkTextBlob plumbing (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: review comments Created 6 years, 4 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 | « src/core/SkPictureRecord.h ('k') | src/core/SkRecorder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPictureRecord.cpp
diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp
index dd8040071f999f0eb1882b9b729d6cd43ee9cb0f..67bd9a548b5f27ac4935d8771e755577a40d6ac9 100644
--- a/src/core/SkPictureRecord.cpp
+++ b/src/core/SkPictureRecord.cpp
@@ -12,6 +12,7 @@
#include "SkPictureStateTree.h"
#include "SkPixelRef.h"
#include "SkRRect.h"
+#include "SkTextBlob.h"
#include "SkTSearch.h"
#define HEAP_BLOCK_SIZE 4096
@@ -59,6 +60,7 @@ SkPictureRecord::~SkPictureRecord() {
SkSafeUnref(fStateTree);
fFlattenableHeap.setBitmapStorage(NULL);
fPictureRefs.unrefAll();
+ fTextBlobRefs.unrefAll();
}
///////////////////////////////////////////////////////////////////////////////
@@ -114,6 +116,7 @@ static inline size_t getPaintOffset(DrawType op, size_t opSize) {
0, // POP_CULL - no paint
1, // DRAW_PATCH - right after op code
1, // DRAW_PICTURE_MATRIX_PAINT - right after op code
+ 1, // DRAW_TEXT_BLOB- right after op code
};
SK_COMPILE_ASSERT(sizeof(gPaintOffsets) == LAST_DRAWTYPE_ENUM + 1,
@@ -462,7 +465,8 @@ static bool is_drawing_op(DrawType op) {
return (op > CONCAT && op < ROTATE)
|| DRAW_DRRECT == op
|| DRAW_PATCH == op
- || DRAW_PICTURE_MATRIX_PAINT == op;
+ || DRAW_PICTURE_MATRIX_PAINT == op
+ || DRAW_TEXT_BLOB == op;
}
/*
@@ -1207,6 +1211,22 @@ void SkPictureRecord::onDrawTextOnPath(const void* text, size_t byteLength, cons
this->validate(initialOffset, size);
}
+void SkPictureRecord::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
+ const SkPaint& paint) {
+
+ // op + paint index + blob index + x/y
+ size_t size = 3 * kUInt32Size + 2 * sizeof(SkScalar);
+ size_t initialOffset = this->addDraw(DRAW_TEXT_BLOB, &size);
+ SkASSERT(initialOffset + getPaintOffset(DRAW_TEXT_BLOB, size) == fWriter.bytesWritten());
+
+ this->addPaint(paint);
+ this->addTextBlob(blob);
+ this->addScalar(x);
+ this->addScalar(y);
+
+ this->validate(initialOffset, size);
+}
+
void SkPictureRecord::onDrawPicture(const SkPicture* picture, const SkMatrix* matrix,
const SkPaint* paint) {
// op + picture index
@@ -1523,5 +1543,16 @@ void SkPictureRecord::addText(const void* text, size_t byteLength) {
fWriter.writePad(text, byteLength);
}
+void SkPictureRecord::addTextBlob(const SkTextBlob *blob) {
+ int index = fTextBlobRefs.find(blob);
+ if (index < 0) { // not found
+ index = fTextBlobRefs.count();
+ *fTextBlobRefs.append() = blob;
+ blob->ref();
+ }
+ // follow the convention of recording a 1-based index
+ this->addInt(index + 1);
+}
+
///////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « src/core/SkPictureRecord.h ('k') | src/core/SkRecorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698