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
diff --git a/src/animator/SkDisplayPost.cpp b/src/animator/SkDisplayPost.cpp
index 17e7c76..e46cdbd 100644
--- a/src/animator/SkDisplayPost.cpp
+++ b/src/animator/SkDisplayPost.cpp
@@ -51,13 +51,13 @@
 }
 
 SkPost::~SkPost() {
-    for (SkData** part = fParts.begin(); part < fParts.end();  part++)
+    for (SkDataInput** part = fParts.begin(); part < fParts.end();  part++)
         delete *part;
 }
 
 bool SkPost::add(SkAnimateMaker& , SkDisplayable* child) {
-    SkASSERT(child && child->isData());
-    SkData* part = (SkData*) child;
+    SkASSERT(child && child->isDataInput());
+    SkDataInput* part = (SkDataInput*) child;
     *fParts.append() = part;
     return true;
 }
@@ -113,8 +113,8 @@
     //for some reason the last part is id, which i don't want
     //and the parts seem to be in the reverse order from the one in which we find the 
     //data itself
-    //SkData** ptr = fParts.end();
-    //SkData* data;
+    //SkDataInput** ptr = fParts.end();
+    //SkDataInput* data;
     //const char* ID;
     while ((name = iter.next(&type, &number)) != NULL) {
         //ptr--;
@@ -190,7 +190,7 @@
             fEvent.getMetaData().reset();
             if (preserveID.size() > 0)
                 fEvent.setString("id", preserveID);
-            for (SkData** part = fParts.begin(); part < fParts.end();  part++) {
+            for (SkDataInput** part = fParts.begin(); part < fParts.end();  part++) {
                 if ((*part)->add())
                     maker.setErrorCode(SkDisplayXMLParserError::kErrorAddingDataToPost);
             }
@@ -284,7 +284,7 @@
 void SkPost::onEndElement(SkAnimateMaker& maker) {
     fTargetMaker = fMaker = &maker;
     if (fChildHasID == false) {
-        for (SkData** part = fParts.begin(); part < fParts.end();  part++)
+        for (SkDataInput** part = fParts.begin(); part < fParts.end();  part++)
             delete *part;
         fParts.reset();
     }
diff --git a/src/animator/SkDisplayPost.h b/src/animator/SkDisplayPost.h
index 4b75b07..95c4042 100644
--- a/src/animator/SkDisplayPost.h
+++ b/src/animator/SkDisplayPost.h
@@ -24,7 +24,7 @@
 #include "SkMemberInfo.h"
 #include "SkIntArray.h"
 
-class SkData;
+class SkDataInput;
 class SkAnimateMaker;
 
 class SkPost : public SkDisplayable {
@@ -60,7 +60,7 @@
     SkBool8 fDirty;
 private:
     void findSinkID();
-    friend class SkData;
+    friend class SkDataInput;
     typedef SkDisplayable INHERITED;
 };
 
diff --git a/src/animator/SkDisplayType.cpp b/src/animator/SkDisplayType.cpp
index 90fcd89..564cd3f 100644
--- a/src/animator/SkDisplayType.cpp
+++ b/src/animator/SkDisplayType.cpp
@@ -119,7 +119,7 @@
         CASE_DRAW_NEW(Color);
         CASE_NEW(CubicTo);
         CASE_NEW(Dash);
-        CASE_NEW(Data);
+        CASE_NEW(DataInput);
         CASE_NEW(Discrete);
         // displayable
         // drawable
@@ -274,7 +274,7 @@
         CASE_GET_DRAW_INFO(Color);
         CASE_GET_INFO(CubicTo);
         CASE_GET_INFO(Dash);
-        CASE_GET_INFO(Data);
+        CASE_GET_INFO(DataInput);
         CASE_GET_INFO(Discrete);
         // displayable
         // drawable
@@ -441,7 +441,7 @@
     DRAW_NAME("color", SkType_Color),
     { "cubicTo", SkType_CubicTo                 INIT_BOOL_FIELDS },
     { "dash", SkType_Dash                       INIT_BOOL_FIELDS },
-    { "data", SkType_Data                       INIT_BOOL_FIELDS },
+    { "data", SkType_DataInput                  INIT_BOOL_FIELDS },
     { "discrete", SkType_Discrete               INIT_BOOL_FIELDS },
     // displayable
     // drawable
@@ -634,7 +634,7 @@
         case SkType_Color:
         case SkType_CubicTo:
         case SkType_Dash:
-        case SkType_Data:
+        case SkType_DataInput:
         case SkType_Discrete:
         case SkType_Displayable:
         case SkType_Drawable:
diff --git a/src/animator/SkDisplayType.h b/src/animator/SkDisplayType.h
index a29b285..13ff2a1 100644
--- a/src/animator/SkDisplayType.h
+++ b/src/animator/SkDisplayType.h
@@ -75,7 +75,7 @@
     SkType_Color,
     SkType_CubicTo,
     SkType_Dash,
-    SkType_Data,
+    SkType_DataInput,
     SkType_Discrete,
     SkType_Displayable,
     SkType_Drawable,
diff --git a/src/animator/SkDisplayable.h b/src/animator/SkDisplayable.h
index cbc96de..822f70c 100644
--- a/src/animator/SkDisplayable.h
+++ b/src/animator/SkDisplayable.h
@@ -96,7 +96,7 @@
     virtual bool setProperty(int index, SkScriptValue& );
     void setReference(const SkMemberInfo* info, SkDisplayable* ref);
 #ifdef SK_DEBUG
-    bool isData() const { return getType() == SkType_Data; };
+    bool isDataInput() const { return getType() == SkType_DataInput; };
     bool isEvent() const { return getType() == SkType_Event; }
     virtual bool isMatrixPart() const { return false; }
     bool isPatch() const { return getType() == SkType_3D_Patch; }
diff --git a/src/animator/SkIntArray.h b/src/animator/SkIntArray.h
index b2a49c1..ceffa94 100644
--- a/src/animator/SkIntArray.h
+++ b/src/animator/SkIntArray.h
@@ -25,7 +25,7 @@
 
 class SkActive;
 class SkAnimateBase;
-class SkData;
+class SkDataInput;
 class SkDisplayable;
 class SkDisplayEvent;
 class SkDrawable;
@@ -46,7 +46,7 @@
 
 typedef SkLongArray(SkActive*) SkTDActiveArray; 
 typedef SkLongArray(SkAnimateBase*) SkTDAnimateArray; 
-typedef SkLongArray(SkData*) SkTDDataArray; 
+typedef SkLongArray(SkDataInput*) SkTDDataArray; 
 typedef SkLongArray(SkDisplayable*) SkTDDisplayableArray; 
 typedef SkLongArray(SkDisplayEvent*) SkTDDisplayEventArray; 
 typedef SkLongArray(SkDrawable*) SkTDDrawableArray; 
diff --git a/src/animator/SkPostParts.cpp b/src/animator/SkPostParts.cpp
index 254b17d..01eb23c 100644
--- a/src/animator/SkPostParts.cpp
+++ b/src/animator/SkPostParts.cpp
@@ -20,17 +20,17 @@
 
 #if SK_USE_CONDENSED_INFO == 0
 
-const SkMemberInfo SkData::fInfo[] = {
+const SkMemberInfo SkDataInput::fInfo[] = {
     SK_MEMBER_INHERITED
 };
 
 #endif
 
-DEFINE_GET_MEMBER(SkData);
+DEFINE_GET_MEMBER(SkDataInput);
 
-SkData::SkData() : fParent(NULL) {}
+SkDataInput::SkDataInput() : fParent(NULL) {}
 
-bool SkData::add() {
+bool SkDataInput::add() {
     SkASSERT(name.size() > 0);
     const char* dataName = name.c_str();
     if (fInt != (int) SK_NaN32)
@@ -44,22 +44,22 @@
     return false;
 }
 
-void SkData::dirty() {
+void SkDataInput::dirty() {
     fParent->dirty();
 }
 
-SkDisplayable* SkData::getParent() const {
+SkDisplayable* SkDataInput::getParent() const {
     return fParent;
 }
 
-bool SkData::setParent(SkDisplayable* displayable) {
+bool SkDataInput::setParent(SkDisplayable* displayable) {
     if (displayable->isPost() == false)
         return true;
     fParent = (SkPost*) displayable;
     return false;
 }
 
-void SkData::onEndElement(SkAnimateMaker&) {
+void SkDataInput::onEndElement(SkAnimateMaker&) {
     add();
 }
 
diff --git a/src/animator/SkPostParts.h b/src/animator/SkPostParts.h
index ef41fe5..f20be56 100644
--- a/src/animator/SkPostParts.h
+++ b/src/animator/SkPostParts.h
@@ -22,9 +22,9 @@
 
 class SkPost;
 
-class SkData: public SkInput {
-    DECLARE_MEMBER_INFO(Data);
-    SkData();
+class SkDataInput: public SkInput {
+    DECLARE_MEMBER_INFO(DataInput);
+    SkDataInput();
     bool add();
     virtual void dirty();
     virtual SkDisplayable* getParent() const;
diff --git a/src/core/SkDataRef.cpp b/src/core/SkDataRef.cpp
deleted file mode 100644
index f8f8b17..0000000
--- 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 c0a7348..eb06452 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 @@
     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);
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////////////////