aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-06-24 13:07:31 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-06-24 13:07:31 +0000
commit8d0b5770f8fcfdeb8ad9808e58c49116f14b6190 (patch)
treec3a33702366d7e196296960494463baa078dd175 /src/core
parentc134f394011372512f13e119df65204920f9bef6 (diff)
rename public SkDataRef to SkData
rename animator's internal SkData to SkDataInput git-svn-id: http://skia.googlecode.com/svn/trunk@1697 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkDataRef.cpp106
-rw-r--r--src/core/SkStream.cpp9
2 files changed, 5 insertions, 110 deletions
diff --git a/src/core/SkDataRef.cpp b/src/core/SkDataRef.cpp
deleted file mode 100644
index f8f8b176ea..0000000000
--- a/src/core/SkDataRef.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- Copyright 2011 Google Inc.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
-
-
-#include "SkDataRef.h"
-
-SkDataRef::SkDataRef(const void* ptr, size_t size, ReleaseProc proc, void* context) {
- fPtr = ptr;
- fSize = size;
- fReleaseProc = proc;
- fReleaseProcContext = context;
-}
-
-SkDataRef::~SkDataRef() {
- if (fReleaseProc) {
- fReleaseProc(fPtr, fSize, fReleaseProcContext);
- }
-}
-
-size_t SkDataRef::copyRange(size_t offset, size_t length, void* buffer) const {
- size_t available = fSize;
- if (offset >= available || 0 == length) {
- return 0;
- }
- available -= offset;
- if (length > available) {
- length = available;
- }
- SkASSERT(length > 0);
-
- memcpy(buffer, this->bytes() + offset, length);
- return length;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-SkDataRef* SkDataRef::NewEmpty() {
- static SkDataRef* gEmptyRef;
- if (NULL == gEmptyRef) {
- gEmptyRef = new SkDataRef(NULL, 0, NULL, NULL);
- }
- gEmptyRef->ref();
- return gEmptyRef;
-}
-
-// assumes fPtr was allocated via sk_malloc
-static void sk_malloc_releaseproc(const void* ptr, size_t, void*) {
- sk_free((void*)ptr);
-}
-
-SkDataRef* SkDataRef::NewWithCopy(const void* data, size_t length) {
- if (0 == length) {
- return SkDataRef::NewEmpty();
- }
-
- void* copy = sk_malloc_throw(length); // balanced in sk_malloc_releaseproc
- memcpy(copy, data, length);
- return new SkDataRef(copy, length, sk_malloc_releaseproc, NULL);
-}
-
-SkDataRef* SkDataRef::NewWithProc(const void* data, size_t length,
- ReleaseProc proc, void* context) {
- return new SkDataRef(data, length, proc, context);
-}
-
-// assumes context is a SkDataRef
-static void sk_dataref_releaseproc(const void*, size_t, void* context) {
- SkDataRef* src = reinterpret_cast<SkDataRef*>(context);
- src->unref();
-}
-
-SkDataRef* SkDataRef::NewSubset(const SkDataRef* src, size_t offset, size_t length) {
- /*
- We could, if we wanted/need to, just make a deep copy of src's data,
- rather than referencing it. This would duplicate the storage (of the
- subset amount) but would possibly allow src to go out of scope sooner.
- */
-
- size_t available = src->size();
- if (offset >= available || 0 == length) {
- return SkDataRef::NewEmpty();
- }
- available -= offset;
- if (length > available) {
- length = available;
- }
- SkASSERT(length > 0);
-
- src->ref(); // this will be balanced in sk_dataref_releaseproc
- return new SkDataRef(src->bytes() + offset, length, sk_dataref_releaseproc,
- const_cast<SkDataRef*>(src));
-}
-
diff --git a/src/core/SkStream.cpp b/src/core/SkStream.cpp
index c0a73485c3..eb06452fa5 100644
--- a/src/core/SkStream.cpp
+++ b/src/core/SkStream.cpp
@@ -16,7 +16,7 @@
*/
#include "SkStream.h"
-#include "SkDataRef.h"
+#include "SkData.h"
#include "SkFixed.h"
#include "SkString.h"
#include "SkOSFile.h"
@@ -729,9 +729,10 @@ static void sk_free_release_proc(const void* ptr, size_t length, void*) {
sk_free((void*)ptr);
}
-SkDataRef* SkDynamicMemoryWStream::copyToData() const {
- return SkDataRef::NewWithProc(this->detach(), fBytesWritten,
- sk_free_release_proc, NULL);
+SkData* SkDynamicMemoryWStream::copyToData() const {
+ // should rewrite when we remove detach()
+ return SkData::NewWithProc(this->detach(), fBytesWritten,
+ sk_free_release_proc, NULL);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////