Index: src/objects.h |
=================================================================== |
--- src/objects.h (revision 2544) |
+++ src/objects.h (working copy) |
@@ -52,6 +52,7 @@ |
// - JSValue |
// - Array |
// - ByteArray |
+// - PixelArray |
// - FixedArray |
// - DescriptorArray |
// - HashTable |
@@ -95,7 +96,6 @@ |
// HeapObject: [32 bit direct pointer] (4 byte aligned) | 01 |
// Failure: [30 bit signed int] 11 |
- |
// Ecma-262 3rd 8.6.1 |
enum PropertyAttributes { |
NONE = v8::None, |
@@ -270,6 +270,7 @@ |
V(ODDBALL_TYPE) \ |
V(PROXY_TYPE) \ |
V(BYTE_ARRAY_TYPE) \ |
+ V(PIXEL_ARRAY_TYPE) \ |
V(FILLER_TYPE) \ |
\ |
V(ACCESSOR_INFO_TYPE) \ |
@@ -659,6 +660,7 @@ |
JS_GLOBAL_PROPERTY_CELL_TYPE, |
PROXY_TYPE, |
BYTE_ARRAY_TYPE, |
+ PIXEL_ARRAY_TYPE, |
FILLER_TYPE, |
SMI_TYPE, |
@@ -760,6 +762,7 @@ |
inline bool IsNumber(); |
inline bool IsByteArray(); |
+ inline bool IsPixelArray(); |
inline bool IsFailure(); |
inline bool IsRetryAfterGC(); |
inline bool IsOutOfMemoryFailure(); |
@@ -1302,6 +1305,11 @@ |
class JSObject: public HeapObject { |
public: |
enum DeleteMode { NORMAL_DELETION, FORCE_DELETION }; |
+ enum ElementsKind { |
+ FAST_ELEMENTS, |
+ DICTIONARY_ELEMENTS, |
+ PIXEL_ELEMENTS |
+ }; |
// [properties]: Backing storage for properties. |
// properties is a FixedArray in the fast case, and a Dictionary in the |
@@ -1313,10 +1321,13 @@ |
// [elements]: The elements (properties with names that are integers). |
// elements is a FixedArray in the fast case, and a Dictionary in the slow |
- // case. |
- DECL_ACCESSORS(elements, FixedArray) // Get and set fast elements. |
+ // case or a PixelArray in a special case. |
+ DECL_ACCESSORS(elements, Array) // Get and set fast elements. |
inline void initialize_elements(); |
+ inline ElementsKind GetElementsKind(); |
inline bool HasFastElements(); |
+ inline bool HasDictionaryElements(); |
+ inline bool HasPixelElements(); |
inline NumberDictionary* element_dictionary(); // Gets slow elements. |
// Collects elements starting at index 0. |
@@ -2440,6 +2451,43 @@ |
}; |
+// PixelArray represents a fixed size byte array with special sematics used for |
+// implementing the CanvasPixelArray object. Please see the specification at: |
+// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#canvaspixelarray |
+// In particular write access clamps the values to 0 or 255 if the value |
+// used is outside this range. |
+class PixelArray: public Array { |
+ public: |
+ // [external_pointer]: The pointer to the external memory area backing this |
+ // pixel array. |
+ DECL_ACCESSORS(external_pointer, uint8_t) // Pointer to the data store. |
+ |
+ // Setter and getter. |
+ inline uint8_t get(int index); |
+ inline void set(int index, uint8_t value); |
+ |
+ // This accessor applies the correct conversion from Smi, HeapNumber and |
+ // undefined and clamps the converted value between 0 and 255. |
+ Object* SetValue(uint32_t index, Object* value); |
+ |
+ // Casting. |
+ static inline PixelArray* cast(Object* obj); |
+ |
+#ifdef DEBUG |
+ void PixelArrayPrint(); |
+ void PixelArrayVerify(); |
+#endif // DEBUG |
+ |
+ // PixelArray headers are not quadword aligned. |
+ static const int kExternalPointerOffset = Array::kAlignedSize; |
+ static const int kHeaderSize = kExternalPointerOffset + kPointerSize; |
+ static const int kAlignedSize = OBJECT_SIZE_ALIGN(kHeaderSize); |
+ |
+private: |
+ DISALLOW_IMPLICIT_CONSTRUCTORS(PixelArray); |
+}; |
+ |
+ |
// Code describes objects with on-the-fly generated machine code. |
class Code: public HeapObject { |
public: |