Remove currently unused code
authorcommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 14 Apr 2014 15:02:50 +0000 (15:02 +0000)
committercommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 14 Apr 2014 15:02:50 +0000 (15:02 +0000)
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

gyp/core.gypi
src/core/SkOffsetTable.h [deleted file]
src/core/SkPicturePlayback.cpp
src/core/SkPicturePlayback.h
src/core/SkPictureRecord.cpp
src/core/SkPictureRecord.h

index 563d1ba541b90e1b44d4e706ef868848bade2bd9..3a8dc21485b58b9c5cf932b1e08879ba5e4a09ee 100644 (file)
         '<(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 (file)
index 0596c38..0000000
+++ /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
index a942338f170989cd41bb3e2b0c2bd08a86b6017f..52ea56d5a0ed0668a55c7ef8ef27647c26ef13db 100644 (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++) {
index 4a7ca31c4754cb0fd4d40b320a5f4a10c32167f4..62bcb52692f8b8bede657e3f927a43c282730cde 100644 (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;
index c31743da8c2939b802a7f565a9c113867046b8f4..0a55e7361cbda24b1c16dc05d72e5201de69915a 100644 (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
index eca42aa57ad32eb36a81906d233a53f6ece7231b..2614496ba6314afe832aa490db2bb680738dc0e8 100644 (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