Bug 953394 - Android imports needed for bug 953394. r=doublec, a=bajaj
authorEdwin Flores <eflores@mozilla.com>
Thu, 09 Jan 2014 14:54:57 +1300
changeset 176070 6da6f218ba170ee5f849b3a1a7a1b8386a0c9d72
parent 176069 a3f8a8d0dc9104936c7d08bc98074278cb7ef469
child 176071 e5785687c13ade03c5ce85f56be0bebfd6a85d46
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdoublec, bajaj
bugs953394
milestone28.0a2
Bug 953394 - Android imports needed for bug 953394. r=doublec, a=bajaj * Added some android::Vector, android::VectorImpl method definitions to link against. * Updated android::Vector and android::VectorImpl headers to 4.4 as using headers from 4.1 crashed 4.4 devices but not vice versa.
media/omx-plugin/include/ics/utils/Vector.h
media/omx-plugin/include/ics/utils/VectorImpl.h
media/omx-plugin/lib/ics/libstagefright/libstagefright.cpp
media/omx-plugin/lib/ics/libutils/libutils.cpp
--- a/media/omx-plugin/include/ics/utils/Vector.h
+++ b/media/omx-plugin/include/ics/utils/Vector.h
@@ -16,17 +16,18 @@
 
 #ifndef ANDROID_VECTOR_H
 #define ANDROID_VECTOR_H
 
 #include <new>
 #include <stdint.h>
 #include <sys/types.h>
 
-#include <utils/Log.h>
+#include <cutils/log.h>
+
 #include <utils/VectorImpl.h>
 #include <utils/TypeHelpers.h>
 
 // ---------------------------------------------------------------------------
 
 namespace android {
 
 template <typename TYPE>
@@ -38,118 +39,122 @@ class SortedVector;
  * This is the class users want to use.
  */
 
 template <class TYPE>
 class Vector : private VectorImpl
 {
 public:
             typedef TYPE    value_type;
-    
-    /*! 
+
+    /*!
      * Constructors and destructors
      */
-    
+
                             Vector();
                             Vector(const Vector<TYPE>& rhs);
     explicit                Vector(const SortedVector<TYPE>& rhs);
     virtual                 ~Vector();
 
     /*! copy operator */
             const Vector<TYPE>&     operator = (const Vector<TYPE>& rhs) const;
-            Vector<TYPE>&           operator = (const Vector<TYPE>& rhs);    
+            Vector<TYPE>&           operator = (const Vector<TYPE>& rhs);
 
             const Vector<TYPE>&     operator = (const SortedVector<TYPE>& rhs) const;
             Vector<TYPE>&           operator = (const SortedVector<TYPE>& rhs);
 
             /*
      * empty the vector
      */
 
     inline  void            clear()             { VectorImpl::clear(); }
 
-    /*! 
+    /*!
      * vector stats
      */
 
     //! returns number of items in the vector
     inline  size_t          size() const                { return VectorImpl::size(); }
-    //! returns wether or not the vector is empty
+    //! returns whether or not the vector is empty
     inline  bool            isEmpty() const             { return VectorImpl::isEmpty(); }
     //! returns how many items can be stored without reallocating the backing store
     inline  size_t          capacity() const            { return VectorImpl::capacity(); }
-    //! setst the capacity. capacity can never be reduced less than size()
+    //! sets the capacity. capacity can never be reduced less than size()
     inline  ssize_t         setCapacity(size_t size)    { return VectorImpl::setCapacity(size); }
 
-    /*! 
+    /*!
+     * set the size of the vector. items are appended with the default
+     * constructor, or removed from the end as needed.
+     */
+    inline  ssize_t         resize(size_t size)         { return VectorImpl::resize(size); }
+
+    /*!
      * C-style array access
      */
-     
-    //! read-only C-style access 
+
+    //! read-only C-style access
     inline  const TYPE*     array() const;
     //! read-write C-style access
             TYPE*           editArray();
-    
-    /*! 
+
+    /*!
      * accessors
      */
 
     //! read-only access to an item at a given index
     inline  const TYPE&     operator [] (size_t index) const;
     //! alternate name for operator []
     inline  const TYPE&     itemAt(size_t index) const;
     //! stack-usage of the vector. returns the top of the stack (last element)
             const TYPE&     top() const;
-    //! same as operator [], but allows to access the vector backward (from the end) with a negative index
-            const TYPE&     mirrorItemAt(ssize_t index) const;
 
     /*!
-     * modifing the array
+     * modifying the array
      */
 
     //! copy-on write support, grants write access to an item
             TYPE&           editItemAt(size_t index);
-    //! grants right acces to the top of the stack (last element)
+    //! grants right access to the top of the stack (last element)
             TYPE&           editTop();
 
-            /*! 
+            /*!
              * append/insert another vector
              */
-            
+
     //! insert another vector at a given index
             ssize_t         insertVectorAt(const Vector<TYPE>& vector, size_t index);
 
     //! append another vector at the end of this one
             ssize_t         appendVector(const Vector<TYPE>& vector);
 
 
     //! insert an array at a given index
             ssize_t         insertArrayAt(const TYPE* array, size_t index, size_t length);
 
     //! append an array at the end of this vector
             ssize_t         appendArray(const TYPE* array, size_t length);
 
-            /*! 
+            /*!
              * add/insert/replace items
              */
-             
+
     //! insert one or several items initialized with their default constructor
     inline  ssize_t         insertAt(size_t index, size_t numItems = 1);
     //! insert one or several items initialized from a prototype item
             ssize_t         insertAt(const TYPE& prototype_item, size_t index, size_t numItems = 1);
     //! pop the top of the stack (removes the last element). No-op if the stack's empty
     inline  void            pop();
     //! pushes an item initialized with its default constructor
     inline  void            push();
     //! pushes an item on the top of the stack
             void            push(const TYPE& item);
     //! same as push() but returns the index the item was added at (or an error)
     inline  ssize_t         add();
     //! same as push() but returns the index the item was added at (or an error)
-            ssize_t         add(const TYPE& item);            
+            ssize_t         add(const TYPE& item);
     //! replace an item with a new one initialized with its default constructor
     inline  ssize_t         replaceAt(size_t index);
     //! replace an item with a new one
             ssize_t         replaceAt(const TYPE& item, size_t index);
 
     /*!
      * remove items
      */
@@ -157,20 +162,20 @@ public:
     //! remove several items
     inline  ssize_t         removeItemsAt(size_t index, size_t count = 1);
     //! remove one item
     inline  ssize_t         removeAt(size_t index)  { return removeItemsAt(index); }
 
     /*!
      * sort (stable) the array
      */
-     
+
      typedef int (*compar_t)(const TYPE* lhs, const TYPE* rhs);
      typedef int (*compar_r_t)(const TYPE* lhs, const TYPE* rhs, void* state);
-     
+
      inline status_t        sort(compar_t cmp);
      inline status_t        sort(compar_r_t cmp, void* state);
 
      // for debugging only
      inline size_t getItemSize() const { return itemSize(); }
 
 
      /*
@@ -181,31 +186,35 @@ public:
      typedef TYPE const* const_iterator;
 
      inline iterator begin() { return editArray(); }
      inline iterator end()   { return editArray() + size(); }
      inline const_iterator begin() const { return array(); }
      inline const_iterator end() const   { return array() + size(); }
      inline void reserve(size_t n) { setCapacity(n); }
      inline bool empty() const{ return isEmpty(); }
-     inline void push_back(const TYPE& item)  { insertAt(item, size()); }
-     inline void push_front(const TYPE& item) { insertAt(item, 0); }
+     inline void push_back(const TYPE& item)  { insertAt(item, size(), 1); }
+     inline void push_front(const TYPE& item) { insertAt(item, 0, 1); }
      inline iterator erase(iterator pos) {
-         return begin() + removeItemsAt(pos-array());
+         ssize_t index = removeItemsAt(pos-array());
+         return begin() + index;
      }
 
 protected:
     virtual void    do_construct(void* storage, size_t num) const;
     virtual void    do_destroy(void* storage, size_t num) const;
     virtual void    do_copy(void* dest, const void* from, size_t num) const;
     virtual void    do_splat(void* dest, const void* item, size_t num) const;
     virtual void    do_move_forward(void* dest, const void* from, size_t num) const;
     virtual void    do_move_backward(void* dest, const void* from, size_t num) const;
 };
 
+// Vector<T> can be trivially moved using memcpy() because moving does not
+// require any change to the underlying SharedBuffer contents or reference count.
+template<typename T> struct trait_trivial_move<Vector<T> > { enum { value = true }; };
 
 // ---------------------------------------------------------------------------
 // No user serviceable parts from here...
 // ---------------------------------------------------------------------------
 
 template<class TYPE> inline
 Vector<TYPE>::Vector()
     : VectorImpl(sizeof(TYPE),
@@ -229,17 +238,17 @@ Vector<TYPE>::Vector(const SortedVector<
 template<class TYPE> inline
 Vector<TYPE>::~Vector() {
     finish_vector();
 }
 
 template<class TYPE> inline
 Vector<TYPE>& Vector<TYPE>::operator = (const Vector<TYPE>& rhs) {
     VectorImpl::operator = (rhs);
-    return *this; 
+    return *this;
 }
 
 template<class TYPE> inline
 const Vector<TYPE>& Vector<TYPE>::operator = (const Vector<TYPE>& rhs) const {
     VectorImpl::operator = (static_cast<const VectorImpl&>(rhs));
     return *this;
 }
 
@@ -247,51 +256,44 @@ template<class TYPE> inline
 Vector<TYPE>& Vector<TYPE>::operator = (const SortedVector<TYPE>& rhs) {
     VectorImpl::operator = (static_cast<const VectorImpl&>(rhs));
     return *this;
 }
 
 template<class TYPE> inline
 const Vector<TYPE>& Vector<TYPE>::operator = (const SortedVector<TYPE>& rhs) const {
     VectorImpl::operator = (rhs);
-    return *this; 
+    return *this;
 }
 
 template<class TYPE> inline
 const TYPE* Vector<TYPE>::array() const {
     return static_cast<const TYPE *>(arrayImpl());
 }
 
 template<class TYPE> inline
 TYPE* Vector<TYPE>::editArray() {
     return static_cast<TYPE *>(editArrayImpl());
 }
 
 
 template<class TYPE> inline
 const TYPE& Vector<TYPE>::operator[](size_t index) const {
-    LOG_FATAL_IF( index>=size(),
-                  "itemAt: index %d is past size %d", (int)index, (int)size() );
+    LOG_FATAL_IF(index>=size(),
+            "%s: index=%u out of range (%u)", __PRETTY_FUNCTION__,
+            int(index), int(size()));
     return *(array() + index);
 }
 
 template<class TYPE> inline
 const TYPE& Vector<TYPE>::itemAt(size_t index) const {
     return operator[](index);
 }
 
 template<class TYPE> inline
-const TYPE& Vector<TYPE>::mirrorItemAt(ssize_t index) const {
-    LOG_FATAL_IF( (index>0 ? index : -index)>=size(),
-                  "mirrorItemAt: index %d is past size %d",
-                  (int)index, (int)size() );
-    return *(array() + ((index<0) ? (size()-index) : index));
-}
-
-template<class TYPE> inline
 const TYPE& Vector<TYPE>::top() const {
     return *(array() + size() - 1);
 }
 
 template<class TYPE> inline
 TYPE& Vector<TYPE>::editItemAt(size_t index) {
     return *( static_cast<TYPE *>(editItemLocation(index)) );
 }
@@ -414,8 +416,9 @@ void Vector<TYPE>::do_move_backward(void
 }
 
 }; // namespace android
 
 
 // ---------------------------------------------------------------------------
 
 #endif // ANDROID_VECTOR_H
+
--- a/media/omx-plugin/include/ics/utils/VectorImpl.h
+++ b/media/omx-plugin/include/ics/utils/VectorImpl.h
@@ -48,34 +48,35 @@ public:
 
                             VectorImpl(size_t itemSize, uint32_t flags);
                             VectorImpl(const VectorImpl& rhs);
     virtual                 ~VectorImpl();
 
     /*! must be called from subclasses destructor */
             void            finish_vector();
 
-            VectorImpl&     operator = (const VectorImpl& rhs);    
-            
+            VectorImpl&     operator = (const VectorImpl& rhs);
+
     /*! C-style array access */
     inline  const void*     arrayImpl() const       { return mStorage; }
             void*           editArrayImpl();
-            
+
     /*! vector stats */
     inline  size_t          size() const        { return mCount; }
     inline  bool            isEmpty() const     { return mCount == 0; }
             size_t          capacity() const;
             ssize_t         setCapacity(size_t size);
+            ssize_t         resize(size_t size);
 
             /*! append/insert another vector or array */
             ssize_t         insertVectorAt(const VectorImpl& vector, size_t index);
             ssize_t         appendVector(const VectorImpl& vector);
             ssize_t         insertArrayAt(const void* array, size_t index, size_t length);
             ssize_t         appendArray(const void* array, size_t length);
-            
+
             /*! add/insert/replace items */
             ssize_t         insertAt(size_t where, size_t numItems = 1);
             ssize_t         insertAt(const void* item, size_t where, size_t numItems = 1);
             void            pop();
             void            push();
             void            push(const void* item);
             ssize_t         add();
             ssize_t         add(const void* item);
@@ -100,26 +101,16 @@ protected:
 
     virtual void            do_construct(void* storage, size_t num) const = 0;
     virtual void            do_destroy(void* storage, size_t num) const = 0;
     virtual void            do_copy(void* dest, const void* from, size_t num) const = 0;
     virtual void            do_splat(void* dest, const void* item, size_t num) const = 0;
     virtual void            do_move_forward(void* dest, const void* from, size_t num) const = 0;
     virtual void            do_move_backward(void* dest, const void* from, size_t num) const = 0;
 
-    // take care of FBC...
-    virtual void            reservedVectorImpl1();
-    virtual void            reservedVectorImpl2();
-    virtual void            reservedVectorImpl3();
-    virtual void            reservedVectorImpl4();
-    virtual void            reservedVectorImpl5();
-    virtual void            reservedVectorImpl6();
-    virtual void            reservedVectorImpl7();
-    virtual void            reservedVectorImpl8();
-    
 private:
         void* _grow(size_t where, size_t amount);
         void  _shrink(size_t where, size_t amount);
 
         inline void _do_construct(void* storage, size_t num) const;
         inline void _do_destroy(void* storage, size_t num) const;
         inline void _do_copy(void* dest, const void* from, size_t num) const;
         inline void _do_splat(void* dest, const void* item, size_t num) const;
@@ -138,48 +129,38 @@ private:
 
 
 class SortedVectorImpl : public VectorImpl
 {
 public:
                             SortedVectorImpl(size_t itemSize, uint32_t flags);
                             SortedVectorImpl(const VectorImpl& rhs);
     virtual                 ~SortedVectorImpl();
-    
-    SortedVectorImpl&     operator = (const SortedVectorImpl& rhs);    
+
+    SortedVectorImpl&     operator = (const SortedVectorImpl& rhs);
 
     //! finds the index of an item
             ssize_t         indexOf(const void* item) const;
 
     //! finds where this item should be inserted
             size_t          orderOf(const void* item) const;
 
     //! add an item in the right place (or replaces it if there is one)
             ssize_t         add(const void* item);
 
     //! merges a vector into this one
             ssize_t         merge(const VectorImpl& vector);
             ssize_t         merge(const SortedVectorImpl& vector);
-             
+
     //! removes an item
             ssize_t         remove(const void* item);
-        
+
 protected:
     virtual int             do_compare(const void* lhs, const void* rhs) const = 0;
 
-    // take care of FBC...
-    virtual void            reservedSortedVectorImpl1();
-    virtual void            reservedSortedVectorImpl2();
-    virtual void            reservedSortedVectorImpl3();
-    virtual void            reservedSortedVectorImpl4();
-    virtual void            reservedSortedVectorImpl5();
-    virtual void            reservedSortedVectorImpl6();
-    virtual void            reservedSortedVectorImpl7();
-    virtual void            reservedSortedVectorImpl8();
-
 private:
             ssize_t         _indexOrderOf(const void* item, size_t* order = 0) const;
 
             // these are made private, because they can't be used on a SortedVector
             // (they don't have an implementation either)
             ssize_t         add();
             void            pop();
             void            push();
@@ -195,8 +176,9 @@ private:
 };
 
 }; // namespace android
 
 
 // ---------------------------------------------------------------------------
 
 #endif // ANDROID_VECTOR_IMPL_H
+
--- a/media/omx-plugin/lib/ics/libstagefright/libstagefright.cpp
+++ b/media/omx-plugin/lib/ics/libstagefright/libstagefright.cpp
@@ -57,16 +57,22 @@ MediaBuffer::size() const
 
 MOZ_EXPORT bool
 MetaData::findInt32(uint32_t key, int32_t *value)
 {
   return false;
 }
 
 MOZ_EXPORT bool
+MetaData::setInt32(uint32_t, int32_t)
+{
+  return false;
+}
+
+MOZ_EXPORT bool
 MetaData::findInt64(uint32_t key, int64_t *value)
 {
   return false;
 }
 
 MOZ_EXPORT bool
 MetaData::findPointer(uint32_t key, void **value)
 {
@@ -171,9 +177,17 @@ ColorConverter::convert(const void *srcB
                         size_t srcCropRight, size_t srcCropBottom,
                         void *dstBits,
                         size_t dstWidth, size_t dstHeight,
                         size_t dstCropLeft, size_t dstCropTop,
                         size_t dstCropRight, size_t dstCropBottom)
 {
   return 0;
 }
+
+MOZ_EXPORT status_t QueryCodecs(const sp<IOMX> &omx,
+                                const char *mimeType, bool queryDecoders,
+                                Vector<CodecCapabilities> *results)
+{
+  return 0;
 }
+
+}
--- a/media/omx-plugin/lib/ics/libutils/libutils.cpp
+++ b/media/omx-plugin/lib/ics/libutils/libutils.cpp
@@ -2,16 +2,17 @@
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 #include "mozilla/Types.h"
 #include "utils/RefBase.h"
 #include "utils/String16.h"
 #include "utils/String8.h"
+#include "utils/Vector.h"
 
 namespace android {
 MOZ_EXPORT RefBase::RefBase() : mRefs(0)
 {
 }
 
 MOZ_EXPORT RefBase::~RefBase()
 {
@@ -49,12 +50,35 @@ MOZ_EXPORT String16::String16(char const
 MOZ_EXPORT String16::~String16()
 {
 }
 
 MOZ_EXPORT String8::String8()
 {
 }
 
+MOZ_EXPORT String8::String8(const String8 &)
+{
+}
+
 MOZ_EXPORT String8::~String8()
 {
 }
+
+MOZ_EXPORT VectorImpl::VectorImpl(size_t, uint32_t)
+  : mFlags(0), mItemSize(0)
+{
 }
+
+MOZ_EXPORT VectorImpl::VectorImpl(const VectorImpl &)
+  : mFlags(0), mItemSize(0)
+{
+}
+
+MOZ_EXPORT VectorImpl::~VectorImpl()
+{
+}
+
+MOZ_EXPORT void VectorImpl::finish_vector()
+{
+}
+
+}