aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-01-30 22:16:32 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-01-30 22:16:32 +0000
commita2bd2d12ad9504583e9311404fcd82b40df49d30 (patch)
treef9543b2f185075f58c77354356728aacfa1e7f61 /src
parent0b9ada1318acf7d5fe90c57331c2a4548aad8b98 (diff)
Set write buffer flags only in SkWriteBuffer and SkFlatController constructors.
This is a baby step toward refactored (and faster in-process) typeface and flattenable factory encoding and decoding. The sooner SkWriteBuffer knows its flags, the better. Next steps will be to rearrange Sk{Read,Write}Buffer members into disjoint strategies to handle typefaces and flattenable factories: one for in-process, one for cross-process, one when validating. BUG=skia: R=reed@google.com, scroggo@google.com Author: mtklein@google.com Review URL: https://codereview.chromium.org/138803005 git-svn-id: http://skia.googlecode.com/svn/trunk@13253 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r--src/core/SkFlattenableSerialization.cpp3
-rw-r--r--src/core/SkPictureFlat.cpp4
-rw-r--r--src/core/SkPictureFlat.h14
-rw-r--r--src/core/SkPicturePlayback.cpp3
-rw-r--r--src/core/SkWriteBuffer.cpp8
-rw-r--r--src/pipe/SkGPipeWrite.cpp6
6 files changed, 16 insertions, 22 deletions
diff --git a/src/core/SkFlattenableSerialization.cpp b/src/core/SkFlattenableSerialization.cpp
index 13fbe6edbf..f34e64170c 100644
--- a/src/core/SkFlattenableSerialization.cpp
+++ b/src/core/SkFlattenableSerialization.cpp
@@ -12,8 +12,7 @@
#include "SkWriteBuffer.h"
SkData* SkValidatingSerializeFlattenable(SkFlattenable* flattenable) {
- SkWriteBuffer writer;
- writer.setFlags(SkWriteBuffer::kValidation_Flag);
+ SkWriteBuffer writer(SkWriteBuffer::kValidation_Flag);
writer.writeFlattenable(flattenable);
uint32_t size = writer.bytesWritten();
void* data = sk_malloc_throw(size);
diff --git a/src/core/SkPictureFlat.cpp b/src/core/SkPictureFlat.cpp
index e3a6f1325a..7b2e67f5ef 100644
--- a/src/core/SkPictureFlat.cpp
+++ b/src/core/SkPictureFlat.cpp
@@ -60,12 +60,12 @@ SkRefCnt* SkTypefacePlayback::set(int index, SkRefCnt* obj) {
///////////////////////////////////////////////////////////////////////////////
-SkFlatController::SkFlatController()
+SkFlatController::SkFlatController(uint32_t writeBufferFlags)
: fBitmapHeap(NULL)
, fTypefaceSet(NULL)
, fTypefacePlayback(NULL)
, fFactorySet(NULL)
-, fWriteBufferFlags(0) {}
+, fWriteBufferFlags(writeBufferFlags) {}
SkFlatController::~SkFlatController() {
SkSafeUnref(fBitmapHeap);
diff --git a/src/core/SkPictureFlat.h b/src/core/SkPictureFlat.h
index 431fa96037..7973e65398 100644
--- a/src/core/SkPictureFlat.h
+++ b/src/core/SkPictureFlat.h
@@ -168,7 +168,7 @@ class SkFlatController : public SkRefCnt {
public:
SK_DECLARE_INST_COUNT(SkFlatController)
- SkFlatController();
+ SkFlatController(uint32_t writeBufferFlags = 0);
virtual ~SkFlatController();
/**
* Return a new block of memory for the SkFlatDictionary to use.
@@ -242,17 +242,12 @@ protected:
*/
SkNamedFactorySet* setNamedFactorySet(SkNamedFactorySet*);
- /**
- * Set the flags to be used during flattening.
- */
- void setWriteBufferFlags(uint32_t flags) { fWriteBufferFlags = flags; }
-
private:
SkBitmapHeap* fBitmapHeap;
SkRefCntSet* fTypefaceSet;
SkTypefacePlayback* fTypefacePlayback;
SkNamedFactorySet* fFactorySet;
- uint32_t fWriteBufferFlags;
+ const uint32_t fWriteBufferFlags;
typedef SkRefCnt INHERITED;
};
@@ -264,12 +259,11 @@ public:
static SkFlatData* Create(SkFlatController* controller, const T& obj, int index) {
// A buffer of 256 bytes should fit most paints, regions, and matrices.
uint32_t storage[64];
- SkWriteBuffer buffer(storage, sizeof(storage));
+ SkWriteBuffer buffer(storage, sizeof(storage), controller->getWriteBufferFlags());
buffer.setBitmapHeap(controller->getBitmapHeap());
buffer.setTypefaceRecorder(controller->getTypefaceSet());
buffer.setNamedFactoryRecorder(controller->getNamedFactorySet());
- buffer.setFlags(controller->getWriteBufferFlags());
Traits::flatten(buffer, obj);
size_t size = buffer.bytesWritten();
@@ -367,6 +361,7 @@ class SkFlatDictionary {
public:
explicit SkFlatDictionary(SkFlatController* controller)
: fController(SkRef(controller))
+ , fScratch(controller->getWriteBufferFlags())
, fReady(false) {
this->reset();
}
@@ -496,7 +491,6 @@ private:
fScratch.setBitmapHeap(fController->getBitmapHeap());
fScratch.setTypefaceRecorder(fController->getTypefaceSet());
fScratch.setNamedFactoryRecorder(fController->getNamedFactorySet());
- fScratch.setFlags(fController->getWriteBufferFlags());
fReady = true;
}
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp
index 02d8828977..e71a17fda5 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -411,8 +411,7 @@ void SkPicturePlayback::serialize(SkWStream* stream,
SkRefCntSet typefaceSet;
SkFactorySet factSet;
- SkWriteBuffer buffer;
- buffer.setFlags(SkWriteBuffer::kCrossProcess_Flag);
+ SkWriteBuffer buffer(SkWriteBuffer::kCrossProcess_Flag);
buffer.setTypefaceRecorder(&typefaceSet);
buffer.setFactoryRecorder(&factSet);
buffer.setBitmapEncoder(encoder);
diff --git a/src/core/SkWriteBuffer.cpp b/src/core/SkWriteBuffer.cpp
index cbbb4c94fc..a295a8c88c 100644
--- a/src/core/SkWriteBuffer.cpp
+++ b/src/core/SkWriteBuffer.cpp
@@ -14,8 +14,8 @@
#include "SkStream.h"
#include "SkTypeface.h"
-SkWriteBuffer::SkWriteBuffer()
- : fFlags(0)
+SkWriteBuffer::SkWriteBuffer(uint32_t flags)
+ : fFlags(flags)
, fFactorySet(NULL)
, fNamedFactorySet(NULL)
, fBitmapHeap(NULL)
@@ -23,8 +23,8 @@ SkWriteBuffer::SkWriteBuffer()
, fBitmapEncoder(NULL) {
}
-SkWriteBuffer::SkWriteBuffer(void* storage, size_t storageSize)
- : fFlags(0)
+SkWriteBuffer::SkWriteBuffer(void* storage, size_t storageSize, uint32_t flags)
+ : fFlags(flags)
, fFactorySet(NULL)
, fNamedFactorySet(NULL)
, fWriter(storage, storageSize)
diff --git a/src/pipe/SkGPipeWrite.cpp b/src/pipe/SkGPipeWrite.cpp
index ce58ca6122..54e3bead69 100644
--- a/src/pipe/SkGPipeWrite.cpp
+++ b/src/pipe/SkGPipeWrite.cpp
@@ -71,11 +71,11 @@ static size_t writeTypeface(SkWriter32* writer, SkTypeface* typeface) {
class FlattenableHeap : public SkFlatController {
public:
FlattenableHeap(int numFlatsToKeep, SkNamedFactorySet* fset, bool isCrossProcess)
- : fNumFlatsToKeep(numFlatsToKeep) {
+ : INHERITED(isCrossProcess ? SkWriteBuffer::kCrossProcess_Flag : 0)
+ , fNumFlatsToKeep(numFlatsToKeep) {
SkASSERT((isCrossProcess && fset != NULL) || (!isCrossProcess && NULL == fset));
if (isCrossProcess) {
this->setNamedFactorySet(fset);
- this->setWriteBufferFlags(SkWriteBuffer::kCrossProcess_Flag);
}
}
@@ -109,6 +109,8 @@ private:
SkTDArray<int> fFlatsThatMustBeKept;
SkTDArray<void*> fPointers;
const int fNumFlatsToKeep;
+
+ typedef SkFlatController INHERITED;
};
void FlattenableHeap::unalloc(void* ptr) {