Remove currently unused code

This code is currently unused and is contrary to the way in which we seem to be moving towards accomplishing this (i.e., device-specific optimization passes).

This is a partial revert of r13704 (First version of bitmap use tracking in SkPictureRecord - https://codereview.chromium.org/187833003/)

R=reed@google.com

Author: robertphillips@google.com

Review URL: https://codereview.chromium.org/237013002

git-svn-id: http://skia.googlecode.com/svn/trunk@14179 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
commit-bot@chromium.org 2014-04-14 15:02:50 +00:00
parent 567f519b94
commit f6a5afb66b
6 changed files with 5 additions and 156 deletions

View File

@ -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',

View File

@ -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

View File

@ -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++) {

View File

@ -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;

View File

@ -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

View File

@ -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