aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkPathHeap.cpp
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2014-11-12 10:24:55 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-12 10:24:55 -0800
commit71a236370792416b367a7d2d6b8e471b06b331cd (patch)
treecffb97b06bce0279e7f4b62802c7559a7237a206 /src/core/SkPathHeap.cpp
parent391e318b3d31669ecef5306cb279618c121e45af (diff)
More cleanup: streamline paths and bitmaps.
SkBitmapHeap is still used---now exclusively---by pipe. BUG=skia: Review URL: https://codereview.chromium.org/715413002
Diffstat (limited to 'src/core/SkPathHeap.cpp')
-rw-r--r--src/core/SkPathHeap.cpp95
1 files changed, 0 insertions, 95 deletions
diff --git a/src/core/SkPathHeap.cpp b/src/core/SkPathHeap.cpp
deleted file mode 100644
index 84ffb04b80..0000000000
--- a/src/core/SkPathHeap.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#include "SkPathHeap.h"
-#include "SkPath.h"
-#include "SkStream.h"
-#include "SkReadBuffer.h"
-#include "SkTSearch.h"
-#include "SkWriteBuffer.h"
-#include <new>
-
-#define kPathCount 64
-
-SkPathHeap::SkPathHeap() : fHeap(kPathCount * sizeof(SkPath)) {
-}
-
-SkPathHeap::SkPathHeap(SkReadBuffer& buffer)
- : fHeap(kPathCount * sizeof(SkPath)) {
- const int count = buffer.readInt();
-
- fPaths.setCount(count);
- SkPath** ptr = fPaths.begin();
- SkPath* p = (SkPath*)fHeap.allocThrow(count * sizeof(SkPath));
-
- for (int i = 0; i < count; i++) {
- new (p) SkPath;
- buffer.readPath(p);
- *ptr++ = p; // record the pointer
- p++; // move to the next storage location
- }
-}
-
-SkPathHeap::~SkPathHeap() {
- SkPath** iter = fPaths.begin();
- SkPath** stop = fPaths.end();
- while (iter < stop) {
- (*iter)->~SkPath();
- iter++;
- }
-}
-
-int SkPathHeap::append(const SkPath& path) {
- SkPath* p = (SkPath*)fHeap.allocThrow(sizeof(SkPath));
- new (p) SkPath(path);
- *fPaths.append() = p;
- return fPaths.count();
-}
-
-SkPathHeap::LookupEntry::LookupEntry(const SkPath& path)
- : fGenerationID(path.getGenerationID()), fStorageSlot(0) {
-}
-
-SkPathHeap::LookupEntry* SkPathHeap::addIfNotPresent(const SkPath& path) {
- LookupEntry searchKey(path);
- int index = SkTSearch<const LookupEntry, LookupEntry::Less>(
- fLookupTable.begin(),
- fLookupTable.count(),
- searchKey,
- sizeof(LookupEntry));
- if (index < 0) {
- index = ~index;
- *fLookupTable.insert(index) = LookupEntry(path);
- }
-
- return &fLookupTable[index];;
-}
-
-int SkPathHeap::insert(const SkPath& path) {
- SkPathHeap::LookupEntry* entry = this->addIfNotPresent(path);
-
- if (entry->storageSlot() > 0) {
- return entry->storageSlot();
- }
-
- int newSlot = this->append(path);
- SkASSERT(newSlot > 0);
- entry->setStorageSlot(newSlot);
- return newSlot;
-}
-
-void SkPathHeap::flatten(SkWriteBuffer& buffer) const {
- int count = fPaths.count();
-
- buffer.writeInt(count);
- SkPath* const* iter = fPaths.begin();
- SkPath* const* stop = fPaths.end();
- while (iter < stop) {
- buffer.writePath(**iter);
- iter++;
- }
-}