| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #ifndef ImageData_h | 29 #ifndef ImageData_h |
| 30 #define ImageData_h | 30 #define ImageData_h |
| 31 | 31 |
| 32 #include "bindings/core/v8/ScriptWrappable.h" | 32 #include "bindings/core/v8/ScriptWrappable.h" |
| 33 #include "core/CoreExport.h" | 33 #include "core/CoreExport.h" |
| 34 #include "core/dom/DOMTypedArray.h" | 34 #include "core/dom/DOMTypedArray.h" |
| 35 #include "core/imagebitmap/ImageBitmapSource.h" | 35 #include "core/imagebitmap/ImageBitmapSource.h" |
| 36 #include "platform/geometry/IntRect.h" | 36 #include "platform/geometry/IntRect.h" |
| 37 #include "platform/geometry/IntSize.h" | 37 #include "platform/geometry/IntSize.h" |
| 38 #include "platform/heap/Handle.h" | 38 #include "platform/heap/Handle.h" |
| 39 #include "wtf/RefPtr.h" |
| 39 | 40 |
| 40 namespace blink { | 41 namespace blink { |
| 41 | 42 |
| 42 class ExceptionState; | 43 class ExceptionState; |
| 43 class ImageBitmapOptions; | 44 class ImageBitmapOptions; |
| 44 | 45 |
| 45 class CORE_EXPORT ImageData final : public GarbageCollectedFinalized<ImageData>,
public ScriptWrappable, public ImageBitmapSource { | 46 class CORE_EXPORT ImageData final : public GarbageCollectedFinalized<ImageData>,
public ScriptWrappable, public ImageBitmapSource { |
| 46 DEFINE_WRAPPERTYPEINFO(); | 47 DEFINE_WRAPPERTYPEINFO(); |
| 47 public: | 48 public: |
| 48 static ImageData* create(const IntSize&); | 49 static ImageData* create(const IntSize&); |
| 49 static ImageData* create(const IntSize&, DOMUint8ClampedArray*); | 50 static ImageData* create(const IntSize&, PassRefPtr<DOMUint8ClampedArray>); |
| 50 static ImageData* create(unsigned width, unsigned height, ExceptionState&); | 51 static ImageData* create(unsigned width, unsigned height, ExceptionState&); |
| 51 static ImageData* create(DOMUint8ClampedArray*, unsigned width, ExceptionSta
te&); | 52 static ImageData* create(DOMUint8ClampedArray*, unsigned width, ExceptionSta
te&); |
| 52 static ImageData* create(DOMUint8ClampedArray*, unsigned width, unsigned hei
ght, ExceptionState&); | 53 static ImageData* create(DOMUint8ClampedArray*, unsigned width, unsigned hei
ght, ExceptionState&); |
| 53 | 54 |
| 54 IntSize size() const { return m_size; } | 55 IntSize size() const { return m_size; } |
| 55 int width() const { return m_size.width(); } | 56 int width() const { return m_size.width(); } |
| 56 int height() const { return m_size.height(); } | 57 int height() const { return m_size.height(); } |
| 57 const DOMUint8ClampedArray* data() const { return m_data.get(); } | 58 const DOMUint8ClampedArray* data() const { return m_data.get(); } |
| 58 DOMUint8ClampedArray* data() { return m_data.get(); } | 59 DOMUint8ClampedArray* data() { return m_data.get(); } |
| 59 | 60 |
| 60 // ImageBitmapSource implementation | 61 // ImageBitmapSource implementation |
| 61 IntSize bitmapSourceSize() const override { return m_size; } | 62 IntSize bitmapSourceSize() const override { return m_size; } |
| 62 ScriptPromise createImageBitmap(ScriptState*, EventTarget&, int sx, int sy,
int sw, int sh, const ImageBitmapOptions&, ExceptionState&) override; | 63 ScriptPromise createImageBitmap(ScriptState*, EventTarget&, int sx, int sy,
int sw, int sh, const ImageBitmapOptions&, ExceptionState&) override; |
| 63 | 64 |
| 64 DEFINE_INLINE_TRACE() | 65 DEFINE_INLINE_TRACE() { } |
| 65 { | |
| 66 visitor->trace(m_data); | |
| 67 } | |
| 68 | 66 |
| 69 void dispose(); | 67 void dispose(); |
| 70 | 68 |
| 71 v8::Local<v8::Object> associateWithWrapper(v8::Isolate*, const WrapperTypeIn
fo*, v8::Local<v8::Object> wrapper) override WARN_UNUSED_RETURN; | 69 v8::Local<v8::Object> associateWithWrapper(v8::Isolate*, const WrapperTypeIn
fo*, v8::Local<v8::Object> wrapper) override WARN_UNUSED_RETURN; |
| 72 | 70 |
| 73 private: | 71 private: |
| 74 ImageData(const IntSize&, DOMUint8ClampedArray*); | 72 ImageData(const IntSize&, PassRefPtr<DOMUint8ClampedArray>); |
| 75 | 73 |
| 76 static bool validateConstructorArguments(DOMUint8ClampedArray*, unsigned wid
th, unsigned&, ExceptionState&); | 74 static bool validateConstructorArguments(DOMUint8ClampedArray*, unsigned wid
th, unsigned&, ExceptionState&); |
| 77 | 75 |
| 78 IntSize m_size; | 76 IntSize m_size; |
| 79 Member<DOMUint8ClampedArray> m_data; | 77 RefPtr<DOMUint8ClampedArray> m_data; |
| 80 }; | 78 }; |
| 81 | 79 |
| 82 } // namespace blink | 80 } // namespace blink |
| 83 | 81 |
| 84 #endif // ImageData_h | 82 #endif // ImageData_h |
| OLD | NEW |