Refactor read and write buffers.
Eliminates SkFlattenable{Read,Write}Buffer, promoting SkOrdered{Read,Write}Buffer
a step each in the hierarchy.
What used to be this:
SkFlattenableWriteBuffer -> SkOrderedWriteBuffer
SkFlattenableReadBuffer -> SkOrderedReadBuffer
SkFlattenableReadBuffer -> SkValidatingReadBuffer
is now
SkWriteBuffer
SkReadBuffer -> SkValidatingReadBuffer
Benefits:
- code is simpler, names are less wordy
- the generic SkFlattenableFooBuffer code in SkPaint was incorrect; removed
- write buffers are completely devirtualized, important for record speed
This refactoring was mostly mechanical. You aren't going to find anything
interesting in files with less than 10 lines changed.
BUG=skia:
R=reed@google.com, scroggo@google.com, djsollen@google.com, mtklein@google.com
Author: mtklein@chromium.org
Review URL: https://codereview.chromium.org/134163010
git-svn-id: http://skia.googlecode.com/svn/trunk@13245 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/pipe/SkGPipeRead.cpp b/src/pipe/SkGPipeRead.cpp
index fc5ab5a..513a34d 100644
--- a/src/pipe/SkGPipeRead.cpp
+++ b/src/pipe/SkGPipeRead.cpp
@@ -20,7 +20,7 @@
#include "SkDrawLooper.h"
#include "SkImageFilter.h"
#include "SkMaskFilter.h"
-#include "SkOrderedReadBuffer.h"
+#include "SkReadBuffer.h"
#include "SkPathEffect.h"
#include "SkRasterizer.h"
#include "SkRRect.h"
@@ -105,7 +105,7 @@
return fFlags;
}
- void setReader(SkOrderedReadBuffer* reader) {
+ void setReader(SkReadBuffer* reader) {
fReader = reader;
this->updateReader();
}
@@ -156,7 +156,7 @@
}
/**
- * Override of SkBitmapHeapReader, so that SkOrderedReadBuffer can use
+ * Override of SkBitmapHeapReader, so that SkReadBuffer can use
* these SkBitmaps for bitmap shaders. Used only in cross process mode
* without a shared heap.
*/
@@ -203,7 +203,7 @@
}
bool crossProcess = SkToBool(fFlags & SkGPipeWriter::kCrossProcess_Flag);
fReader->setFlags(SkSetClearMask(fReader->getFlags(), crossProcess,
- SkFlattenableReadBuffer::kCrossProcess_Flag));
+ SkReadBuffer::kCrossProcess_Flag));
if (crossProcess) {
fReader->setFactoryArray(&fFactoryArray);
} else {
@@ -216,7 +216,7 @@
fReader->setBitmapStorage(fSharedHeap);
}
}
- SkOrderedReadBuffer* fReader;
+ SkReadBuffer* fReader;
SkPaint fPaint;
SkTDArray<SkFlattenable*> fFlatArray;
SkTDArray<SkTypeface*> fTypefaces;
@@ -696,7 +696,7 @@
const size_t size = DrawOp_unpackData(op32);
if (size > 0) {
- SkOrderedReadBuffer buffer(reader->skip(size), size);
+ SkReadBuffer buffer(reader->skip(size), size);
p->setAnnotation(SkNEW_ARGS(SkAnnotation, (buffer)))->unref();
SkASSERT(buffer.offset() == size);
} else {
@@ -857,7 +857,7 @@
SkASSERT(SK_ARRAY_COUNT(gReadTable) == (kDone_DrawOp + 1));
const ReadProc* table = gReadTable;
- SkOrderedReadBuffer reader(data, length);
+ SkReadBuffer reader(data, length);
reader.setBitmapDecoder(fProc);
SkCanvas* canvas = fCanvas;
Status status = kEOF_Status;
diff --git a/src/pipe/SkGPipeWrite.cpp b/src/pipe/SkGPipeWrite.cpp
index 2948f25..ce58ca6 100644
--- a/src/pipe/SkGPipeWrite.cpp
+++ b/src/pipe/SkGPipeWrite.cpp
@@ -17,7 +17,7 @@
#include "SkGPipePriv.h"
#include "SkImageFilter.h"
#include "SkMaskFilter.h"
-#include "SkOrderedWriteBuffer.h"
+#include "SkWriteBuffer.h"
#include "SkPaint.h"
#include "SkPathEffect.h"
#include "SkPictureFlat.h"
@@ -75,7 +75,7 @@
SkASSERT((isCrossProcess && fset != NULL) || (!isCrossProcess && NULL == fset));
if (isCrossProcess) {
this->setNamedFactorySet(fset);
- this->setWriteBufferFlags(SkFlattenableWriteBuffer::kCrossProcess_Flag);
+ this->setWriteBufferFlags(SkWriteBuffer::kCrossProcess_Flag);
}
}
@@ -151,7 +151,7 @@
///////////////////////////////////////////////////////////////////////////////
struct SkFlattenableTraits {
- static void flatten(SkOrderedWriteBuffer& buffer, const SkFlattenable& flattenable) {
+ static void flatten(SkWriteBuffer& buffer, const SkFlattenable& flattenable) {
buffer.writeFlattenable(&flattenable);
}
// No need to define unflatten if we never call it.
@@ -370,11 +370,11 @@
bool SkGPipeCanvas::shuttleBitmap(const SkBitmap& bm, int32_t slot) {
SkASSERT(shouldFlattenBitmaps(fFlags));
- SkOrderedWriteBuffer buffer;
+ SkWriteBuffer buffer;
buffer.setNamedFactoryRecorder(fFactorySet);
buffer.writeBitmap(bm);
this->flattenFactoryNames();
- uint32_t size = buffer.size();
+ uint32_t size = buffer.bytesWritten();
if (this->needOpBytes(size)) {
this->writeOp(kDef_Bitmap_DrawOp, 0, slot);
void* dst = static_cast<void*>(fWriter.reserve(size));
@@ -1146,7 +1146,7 @@
this->writeOp(kSetAnnotation_DrawOp, 0, 0);
}
} else {
- SkOrderedWriteBuffer buffer;
+ SkWriteBuffer buffer;
paint.getAnnotation()->writeToBuffer(buffer);
const size_t size = buffer.bytesWritten();
if (this->needOpBytes(size)) {