| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2006, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2009, 2010 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
| 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 #include "core/html/canvas/CanvasImageSource.h" | 39 #include "core/html/canvas/CanvasImageSource.h" |
| 40 #include "core/imagebitmap/ImageBitmapSource.h" | 40 #include "core/imagebitmap/ImageBitmapSource.h" |
| 41 #include "core/page/PageLifecycleObserver.h" | 41 #include "core/page/PageLifecycleObserver.h" |
| 42 #include "platform/geometry/FloatRect.h" | 42 #include "platform/geometry/FloatRect.h" |
| 43 #include "platform/geometry/IntSize.h" | 43 #include "platform/geometry/IntSize.h" |
| 44 #include "platform/graphics/CanvasSurfaceLayerBridge.h" | 44 #include "platform/graphics/CanvasSurfaceLayerBridge.h" |
| 45 #include "platform/graphics/GraphicsTypes.h" | 45 #include "platform/graphics/GraphicsTypes.h" |
| 46 #include "platform/graphics/GraphicsTypes3D.h" | 46 #include "platform/graphics/GraphicsTypes3D.h" |
| 47 #include "platform/graphics/ImageBufferClient.h" | 47 #include "platform/graphics/ImageBufferClient.h" |
| 48 #include "platform/heap/Handle.h" | 48 #include "platform/heap/Handle.h" |
| 49 #include <memory> | |
| 50 | 49 |
| 51 #define CanvasDefaultInterpolationQuality InterpolationLow | 50 #define CanvasDefaultInterpolationQuality InterpolationLow |
| 52 | 51 |
| 53 namespace blink { | 52 namespace blink { |
| 54 | 53 |
| 55 class AffineTransform; | 54 class AffineTransform; |
| 56 class CanvasContextCreationAttributes; | 55 class CanvasContextCreationAttributes; |
| 57 class CanvasRenderingContext; | 56 class CanvasRenderingContext; |
| 58 class CanvasRenderingContextFactory; | 57 class CanvasRenderingContextFactory; |
| 59 class GraphicsContext; | 58 class GraphicsContext; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 void doDeferredPaintInvalidation(); | 178 void doDeferredPaintInvalidation(); |
| 180 | 179 |
| 181 // ImageBitmapSource implementation | 180 // ImageBitmapSource implementation |
| 182 IntSize bitmapSourceSize() const override; | 181 IntSize bitmapSourceSize() const override; |
| 183 ScriptPromise createImageBitmap(ScriptState*, EventTarget&, int sx, int sy,
int sw, int sh, const ImageBitmapOptions&, ExceptionState&) override; | 182 ScriptPromise createImageBitmap(ScriptState*, EventTarget&, int sx, int sy,
int sw, int sh, const ImageBitmapOptions&, ExceptionState&) override; |
| 184 | 183 |
| 185 DECLARE_VIRTUAL_TRACE(); | 184 DECLARE_VIRTUAL_TRACE(); |
| 186 | 185 |
| 187 DECLARE_VIRTUAL_TRACE_WRAPPERS(); | 186 DECLARE_VIRTUAL_TRACE_WRAPPERS(); |
| 188 | 187 |
| 189 void createImageBufferUsingSurfaceForTesting(std::unique_ptr<ImageBufferSurf
ace>); | 188 void createImageBufferUsingSurfaceForTesting(PassOwnPtr<ImageBufferSurface>)
; |
| 190 | 189 |
| 191 static void registerRenderingContextFactory(std::unique_ptr<CanvasRenderingC
ontextFactory>); | 190 static void registerRenderingContextFactory(PassOwnPtr<CanvasRenderingContex
tFactory>); |
| 192 void updateExternallyAllocatedMemory() const; | 191 void updateExternallyAllocatedMemory() const; |
| 193 | 192 |
| 194 void styleDidChange(const ComputedStyle* oldStyle, const ComputedStyle& newS
tyle); | 193 void styleDidChange(const ComputedStyle* oldStyle, const ComputedStyle& newS
tyle); |
| 195 | 194 |
| 196 void notifyListenersCanvasChanged(); | 195 void notifyListenersCanvasChanged(); |
| 197 | 196 |
| 198 // For Canvas HitRegions | 197 // For Canvas HitRegions |
| 199 bool isSupportedInteractiveCanvasFallback(const Element&); | 198 bool isSupportedInteractiveCanvasFallback(const Element&); |
| 200 std::pair<Element*, String> getControlAndIdIfHitRegionExists(const LayoutPoi
nt&); | 199 std::pair<Element*, String> getControlAndIdIfHitRegionExists(const LayoutPoi
nt&); |
| 201 String getIdFromControl(const Element*); | 200 String getIdFromControl(const Element*); |
| 202 | 201 |
| 203 // For OffscreenCanvas that controls this html canvas element | 202 // For OffscreenCanvas that controls this html canvas element |
| 204 CanvasSurfaceLayerBridge* surfaceLayerBridge() const { return m_surfaceLayer
Bridge.get(); } | 203 CanvasSurfaceLayerBridge* surfaceLayerBridge() const { return m_surfaceLayer
Bridge.get(); } |
| 205 void createSurfaceLayerBridge(); | 204 void createSurfaceLayerBridge(); |
| 206 | 205 |
| 207 void detachContext() { m_context = nullptr; } | 206 void detachContext() { m_context = nullptr; } |
| 208 | 207 |
| 209 protected: | 208 protected: |
| 210 void didMoveToNewDocument(Document& oldDocument) override; | 209 void didMoveToNewDocument(Document& oldDocument) override; |
| 211 | 210 |
| 212 private: | 211 private: |
| 213 explicit HTMLCanvasElement(Document&); | 212 explicit HTMLCanvasElement(Document&); |
| 214 void dispose(); | 213 void dispose(); |
| 215 | 214 |
| 216 using ContextFactoryVector = Vector<std::unique_ptr<CanvasRenderingContextFa
ctory>>; | 215 using ContextFactoryVector = Vector<OwnPtr<CanvasRenderingContextFactory>>; |
| 217 static ContextFactoryVector& renderingContextFactories(); | 216 static ContextFactoryVector& renderingContextFactories(); |
| 218 static CanvasRenderingContextFactory* getRenderingContextFactory(int); | 217 static CanvasRenderingContextFactory* getRenderingContextFactory(int); |
| 219 | 218 |
| 220 void parseAttribute(const QualifiedName&, const AtomicString&, const AtomicS
tring&) override; | 219 void parseAttribute(const QualifiedName&, const AtomicString&, const AtomicS
tring&) override; |
| 221 LayoutObject* createLayoutObject(const ComputedStyle&) override; | 220 LayoutObject* createLayoutObject(const ComputedStyle&) override; |
| 222 bool areAuthorShadowsAllowed() const override { return false; } | 221 bool areAuthorShadowsAllowed() const override { return false; } |
| 223 | 222 |
| 224 void reset(); | 223 void reset(); |
| 225 | 224 |
| 226 std::unique_ptr<ImageBufferSurface> createImageBufferSurface(const IntSize&
deviceSize, int* msaaSampleCount); | 225 PassOwnPtr<ImageBufferSurface> createImageBufferSurface(const IntSize& devic
eSize, int* msaaSampleCount); |
| 227 void createImageBuffer(); | 226 void createImageBuffer(); |
| 228 void createImageBufferInternal(std::unique_ptr<ImageBufferSurface> externalS
urface); | 227 void createImageBufferInternal(PassOwnPtr<ImageBufferSurface> externalSurfac
e); |
| 229 bool shouldUseDisplayList(const IntSize& deviceSize); | 228 bool shouldUseDisplayList(const IntSize& deviceSize); |
| 230 | 229 |
| 231 void setSurfaceSize(const IntSize&); | 230 void setSurfaceSize(const IntSize&); |
| 232 | 231 |
| 233 bool paintsIntoCanvasBuffer() const; | 232 bool paintsIntoCanvasBuffer() const; |
| 234 | 233 |
| 235 ImageData* toImageData(SourceDrawingBuffer, SnapshotReason) const; | 234 ImageData* toImageData(SourceDrawingBuffer, SnapshotReason) const; |
| 236 | 235 |
| 237 String toDataURLInternal(const String& mimeType, const double& quality, Sour
ceDrawingBuffer) const; | 236 String toDataURLInternal(const String& mimeType, const double& quality, Sour
ceDrawingBuffer) const; |
| 238 | 237 |
| 239 HeapHashSet<WeakMember<CanvasDrawListener>> m_listeners; | 238 HeapHashSet<WeakMember<CanvasDrawListener>> m_listeners; |
| 240 | 239 |
| 241 IntSize m_size; | 240 IntSize m_size; |
| 242 | 241 |
| 243 Member<CanvasRenderingContext> m_context; | 242 Member<CanvasRenderingContext> m_context; |
| 244 | 243 |
| 245 bool m_ignoreReset; | 244 bool m_ignoreReset; |
| 246 FloatRect m_dirtyRect; | 245 FloatRect m_dirtyRect; |
| 247 | 246 |
| 248 mutable intptr_t m_externallyAllocatedMemory; | 247 mutable intptr_t m_externallyAllocatedMemory; |
| 249 | 248 |
| 250 bool m_originClean; | 249 bool m_originClean; |
| 251 | 250 |
| 252 // It prevents HTMLCanvasElement::buffer() from continuously re-attempting t
o allocate an imageBuffer | 251 // It prevents HTMLCanvasElement::buffer() from continuously re-attempting t
o allocate an imageBuffer |
| 253 // after the first attempt failed. | 252 // after the first attempt failed. |
| 254 mutable bool m_didFailToCreateImageBuffer; | 253 mutable bool m_didFailToCreateImageBuffer; |
| 255 bool m_imageBufferIsClear; | 254 bool m_imageBufferIsClear; |
| 256 std::unique_ptr<ImageBuffer> m_imageBuffer; | 255 OwnPtr<ImageBuffer> m_imageBuffer; |
| 257 | 256 |
| 258 mutable RefPtr<Image> m_copiedImage; // FIXME: This is temporary for platfor
ms that have to copy the image buffer to render (and for CSSCanvasValue). | 257 mutable RefPtr<Image> m_copiedImage; // FIXME: This is temporary for platfor
ms that have to copy the image buffer to render (and for CSSCanvasValue). |
| 259 | 258 |
| 260 // Used for OffscreenCanvas that controls this HTML canvas element | 259 // Used for OffscreenCanvas that controls this HTML canvas element |
| 261 std::unique_ptr<CanvasSurfaceLayerBridge> m_surfaceLayerBridge; | 260 OwnPtr<CanvasSurfaceLayerBridge> m_surfaceLayerBridge; |
| 262 }; | 261 }; |
| 263 | 262 |
| 264 } // namespace blink | 263 } // namespace blink |
| 265 | 264 |
| 266 #endif // HTMLCanvasElement_h | 265 #endif // HTMLCanvasElement_h |
| OLD | NEW |