aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gyp/core.gypi1
-rw-r--r--src/core/SkOffsetTable.h115
-rw-r--r--src/core/SkPicturePlayback.cpp3
-rw-r--r--src/core/SkPicturePlayback.h2
-rw-r--r--src/core/SkPictureRecord.cpp36
-rw-r--r--src/core/SkPictureRecord.h4
6 files changed, 5 insertions, 156 deletions
diff --git a/gyp/core.gypi b/gyp/core.gypi
index 563d1ba541..3a8dc21485 100644
--- a/gyp/core.gypi
+++ b/gyp/core.gypi
@@ -115,7 +115,6 @@
'<(skia_src_path)/core/SkMessageBus.h',
'<(skia_src_path)/core/SkMetaData.cpp',
'<(skia_src_path)/core/SkMipMap.cpp',
- '<(skia_src_path)/core/SkOffsetTable.h',
'<(skia_src_path)/core/SkPackBits.cpp',
'<(skia_src_path)/core/SkPaint.cpp',
'<(skia_src_path)/core/SkPaintOptionsAndroid.cpp',
diff --git a/src/core/SkOffsetTable.h b/src/core/SkOffsetTable.h
deleted file mode 100644
index 0596c38f83..0000000000
--- a/src/core/SkOffsetTable.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright 2014 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SkOffsetTable_DEFINED
-#define SkOffsetTable_DEFINED
-
-#include "SkRefCnt.h"
-#include "SkTDArray.h"
-
-// A 2D table of skp offsets. Each row is indexed by an int. This is used
-// to store the command offsets that reference a particular bitmap using
-// the bitmap's index in the bitmap heap as the 'id' here. It has to be
-// ref-countable so SkPicturePlayback can take ownership of it.
-// Note that this class assumes that the ids are densely packed.
-
-// TODO: This needs to be sped up. We could replace the offset table with
-// a hash table.
-class SkOffsetTable : public SkRefCnt {
-public:
- SkOffsetTable() {}
- ~SkOffsetTable() {
- fOffsetArrays.deleteAll();
- }
-
- // Record that this 'id' is used by the command starting at this 'offset'.
- // Offsets for a given 'id' should always be added in increasing order.
- void add(int id, size_t offset) {
- if (id >= fOffsetArrays.count()) {
- int oldCount = fOffsetArrays.count();
- fOffsetArrays.setCount(id+1);
- for (int i = oldCount; i <= id; ++i) {
- fOffsetArrays[i] = NULL;
- }
- }
-
- if (NULL == fOffsetArrays[id]) {
- fOffsetArrays[id] = SkNEW(OffsetArray);
- }
- fOffsetArrays[id]->add(offset);
- }
-
- int numIDs() const {
- return fOffsetArrays.count();
- }
-
- // Do the offsets of any commands referencing this ID fall in the
- // range [min, max] (both inclusive)
- bool overlap(int id, size_t min, size_t max) {
- SkASSERT(id < fOffsetArrays.count());
-
- if (NULL == fOffsetArrays[id]) {
- return false;
- }
-
- // If this id has an offset array it should have at least one use
- SkASSERT(fOffsetArrays[id]->count() > 0);
- if (max < fOffsetArrays[id]->min() || min > fOffsetArrays[id]->max()) {
- return false;
- }
-
- return true;
- }
-
- bool includes(int id, size_t offset) {
- SkASSERT(id < fOffsetArrays.count());
-
- OffsetArray* array = fOffsetArrays[id];
-
- for (int i = 0; i < array->fOffsets.count(); ++i) {
- if (array->fOffsets[i] == offset) {
- return true;
- } else if (array->fOffsets[i] > offset) {
- return false;
- }
- }
-
- // Calls to 'includes' should be gaurded by an overlap() call, so we
- // should always find something.
- SkASSERT(0);
- return false;
- }
-
-protected:
- class OffsetArray {
- public:
- void add(size_t offset) {
- SkASSERT(fOffsets.count() == 0 || offset > this->max());
- *fOffsets.append() = offset;
- }
- size_t min() const {
- SkASSERT(fOffsets.count() > 0);
- return fOffsets[0];
- }
- size_t max() const {
- SkASSERT(fOffsets.count() > 0);
- return fOffsets[fOffsets.count()-1];
- }
- int count() const {
- return fOffsets.count();
- }
-
- SkTDArray<size_t> fOffsets;
- };
-
- SkTDArray<OffsetArray*> fOffsetArrays;
-
-private:
- typedef SkRefCnt INHERITED;
-};
-
-#endif
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp
index a942338f17..52ea56d5a0 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -6,7 +6,6 @@
*/
#include <new>
#include "SkBBoxHierarchy.h"
-#include "SkOffsetTable.h"
#include "SkPicturePlayback.h"
#include "SkPictureRecord.h"
#include "SkPictureStateTree.h"
@@ -98,8 +97,6 @@ SkPicturePlayback::SkPicturePlayback(const SkPictureRecord& record,
fBitmapHeap.reset(SkSafeRef(record.fBitmapHeap));
fPathHeap.reset(SkSafeRef(record.fPathHeap));
- fBitmapUseOffsets.reset(SkSafeRef(record.fBitmapUseOffsets.get()));
-
// ensure that the paths bounds are pre-computed
if (fPathHeap.get()) {
for (int i = 0; i < fPathHeap->count(); i++) {
diff --git a/src/core/SkPicturePlayback.h b/src/core/SkPicturePlayback.h
index 4a7ca31c47..62bcb52692 100644
--- a/src/core/SkPicturePlayback.h
+++ b/src/core/SkPicturePlayback.h
@@ -31,7 +31,6 @@ class SkStream;
class SkWStream;
class SkBBoxHierarchy;
class SkPictureStateTree;
-class SkOffsetTable;
struct SkPictInfo {
enum Flags {
@@ -232,7 +231,6 @@ private:
SkTRefArray<SkPaint>* fPaints;
SkData* fOpData; // opcodes and parameters
- SkAutoTUnref<SkOffsetTable> fBitmapUseOffsets;
SkPicture** fPictureRefs;
int fPictureCount;
diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp
index c31743da8c..0a55e7361c 100644
--- a/src/core/SkPictureRecord.cpp
+++ b/src/core/SkPictureRecord.cpp
@@ -11,7 +11,6 @@
#include "SkRRect.h"
#include "SkBBoxHierarchy.h"
#include "SkDevice.h"
-#include "SkOffsetTable.h"
#include "SkPictureStateTree.h"
#define HEAP_BLOCK_SIZE 4096
@@ -1098,11 +1097,10 @@ void SkPictureRecord::drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar
size_t initialOffset = this->addDraw(DRAW_BITMAP, &size);
SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP, size) == fWriter.bytesWritten());
this->addPaintPtr(paint);
- int bitmapID = this->addBitmap(bitmap);
+ this->addBitmap(bitmap);
this->addScalar(left);
this->addScalar(top);
this->validate(initialOffset, size);
- this->trackBitmapUse(bitmapID, initialOffset);
}
void SkPictureRecord::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
@@ -1126,12 +1124,11 @@ void SkPictureRecord::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect*
SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP_RECT_TO_RECT, size)
== fWriter.bytesWritten());
this->addPaintPtr(paint);
- int bitmapID = this->addBitmap(bitmap);
+ this->addBitmap(bitmap);
this->addRectPtr(src); // may be null
this->addRect(dst);
this->addInt(flags);
this->validate(initialOffset, size);
- this->trackBitmapUse(bitmapID, initialOffset);
}
void SkPictureRecord::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& matrix,
@@ -1149,10 +1146,9 @@ void SkPictureRecord::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m
size_t initialOffset = this->addDraw(DRAW_BITMAP_MATRIX, &size);
SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP_MATRIX, size) == fWriter.bytesWritten());
this->addPaintPtr(paint);
- int bitmapID = this->addBitmap(bitmap);
+ this->addBitmap(bitmap);
this->addMatrix(matrix);
this->validate(initialOffset, size);
- this->trackBitmapUse(bitmapID, initialOffset);
}
void SkPictureRecord::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
@@ -1170,11 +1166,10 @@ void SkPictureRecord::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& cent
size_t initialOffset = this->addDraw(DRAW_BITMAP_NINE, &size);
SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP_NINE, size) == fWriter.bytesWritten());
this->addPaintPtr(paint);
- int bitmapID = this->addBitmap(bitmap);
+ this->addBitmap(bitmap);
this->addIRect(center);
this->addRect(dst);
this->validate(initialOffset, size);
- this->trackBitmapUse(bitmapID, initialOffset);
}
void SkPictureRecord::drawSprite(const SkBitmap& bitmap, int left, int top,
@@ -1192,11 +1187,10 @@ void SkPictureRecord::drawSprite(const SkBitmap& bitmap, int left, int top,
size_t initialOffset = this->addDraw(DRAW_SPRITE, &size);
SkASSERT(initialOffset+getPaintOffset(DRAW_SPRITE, size) == fWriter.bytesWritten());
this->addPaintPtr(paint);
- int bitmapID = this->addBitmap(bitmap);
+ this->addBitmap(bitmap);
this->addInt(left);
this->addInt(top);
this->validate(initialOffset, size);
- this->trackBitmapUse(bitmapID, initialOffset);
}
void SkPictureRecord::ComputeFontMetricsTopBottom(const SkPaint& paint, SkScalar topbot[2]) {
@@ -1573,26 +1567,6 @@ SkSurface* SkPictureRecord::onNewSurface(const SkImageInfo& info) {
return NULL;
}
-void SkPictureRecord::trackBitmapUse(int bitmapID, size_t offset) {
-#ifndef SK_ALLOW_BITMAP_TRACKING
- return;
-#endif
-
- if (!(fRecordFlags & SkPicture::kOptimizeForClippedPlayback_RecordingFlag)) {
- return;
- }
-
- if (SkBitmapHeap::INVALID_SLOT == bitmapID) {
- return;
- }
-
- if (NULL == fBitmapUseOffsets) {
- fBitmapUseOffsets.reset(SkNEW(SkOffsetTable));
- }
-
- fBitmapUseOffsets->add(bitmapID, offset);
-}
-
int SkPictureRecord::addBitmap(const SkBitmap& bitmap) {
const int index = fBitmapHeap->insert(bitmap);
// In debug builds, a bad return value from insert() will crash, allowing for debugging. In
diff --git a/src/core/SkPictureRecord.h b/src/core/SkPictureRecord.h
index eca42aa57a..2614496ba6 100644
--- a/src/core/SkPictureRecord.h
+++ b/src/core/SkPictureRecord.h
@@ -20,7 +20,6 @@
#include "SkWriter32.h"
class SkBBoxHierarchy;
-class SkOffsetTable;
class SkPictureStateTree;
// These macros help with packing and unpacking a single byte value and
@@ -157,7 +156,6 @@ private:
}
// The command at 'offset' in the skp uses the specified bitmap
- void trackBitmapUse(int bitmapID, size_t offset);
int addBitmap(const SkBitmap& bitmap);
void addMatrix(const SkMatrix& matrix);
const SkFlatData* addPaint(const SkPaint& paint) { return this->addPaintPtr(&paint); }
@@ -298,8 +296,6 @@ private:
bool fOptsEnabled;
int fInitialSaveCount;
- SkAutoTUnref<SkOffsetTable> fBitmapUseOffsets;
-
friend class SkPicturePlayback;
friend class SkPictureTester; // for unit testing