| 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 26 matching lines...) Expand all Loading... |
| 37 #include "core/fileapi/BlobCallback.h" | 37 #include "core/fileapi/BlobCallback.h" |
| 38 #include "core/html/HTMLElement.h" | 38 #include "core/html/HTMLElement.h" |
| 39 #include "core/html/canvas/CanvasDrawListener.h" | 39 #include "core/html/canvas/CanvasDrawListener.h" |
| 40 #include "core/html/canvas/CanvasImageSource.h" | 40 #include "core/html/canvas/CanvasImageSource.h" |
| 41 #include "core/html/canvas/CanvasRenderingContextHost.h" | 41 #include "core/html/canvas/CanvasRenderingContextHost.h" |
| 42 #include "core/imagebitmap/ImageBitmapSource.h" | 42 #include "core/imagebitmap/ImageBitmapSource.h" |
| 43 #include "core/page/PageVisibilityObserver.h" | 43 #include "core/page/PageVisibilityObserver.h" |
| 44 #include "platform/bindings/ScriptWrappableVisitor.h" | 44 #include "platform/bindings/ScriptWrappableVisitor.h" |
| 45 #include "platform/geometry/FloatRect.h" | 45 #include "platform/geometry/FloatRect.h" |
| 46 #include "platform/geometry/IntSize.h" | 46 #include "platform/geometry/IntSize.h" |
| 47 #include "platform/graphics/CanvasSurfaceLayerBridge.h" | |
| 48 #include "platform/graphics/GraphicsTypes.h" | 47 #include "platform/graphics/GraphicsTypes.h" |
| 49 #include "platform/graphics/GraphicsTypes3D.h" | 48 #include "platform/graphics/GraphicsTypes3D.h" |
| 50 #include "platform/graphics/ImageBufferClient.h" | 49 #include "platform/graphics/ImageBufferClient.h" |
| 51 #include "platform/graphics/OffscreenCanvasPlaceholder.h" | 50 #include "platform/graphics/OffscreenCanvasPlaceholder.h" |
| 51 #include "platform/graphics/SurfaceLayerBridge.h" |
| 52 #include "platform/heap/Handle.h" | 52 #include "platform/heap/Handle.h" |
| 53 | 53 |
| 54 #define CanvasDefaultInterpolationQuality kInterpolationLow | 54 #define CanvasDefaultInterpolationQuality kInterpolationLow |
| 55 | 55 |
| 56 namespace blink { | 56 namespace blink { |
| 57 | 57 |
| 58 class AffineTransform; | 58 class AffineTransform; |
| 59 class CanvasColorParams; | 59 class CanvasColorParams; |
| 60 class CanvasContextCreationAttributes; | 60 class CanvasContextCreationAttributes; |
| 61 class CanvasRenderingContext; | 61 class CanvasRenderingContext; |
| 62 class CanvasRenderingContextFactory; | 62 class CanvasRenderingContextFactory; |
| 63 class GraphicsContext; | 63 class GraphicsContext; |
| 64 class HitTestCanvasResult; | 64 class HitTestCanvasResult; |
| 65 class HTMLCanvasElement; | 65 class HTMLCanvasElement; |
| 66 class Image; | 66 class Image; |
| 67 class ImageBitmapOptions; | 67 class ImageBitmapOptions; |
| 68 class ImageBuffer; | 68 class ImageBuffer; |
| 69 class ImageBufferSurface; | 69 class ImageBufferSurface; |
| 70 class ImageData; | 70 class ImageData; |
| 71 class IntSize; | 71 class IntSize; |
| 72 | 72 |
| 73 class | 73 class |
| 74 CanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContextOrIma
geBitmapRenderingContext; | 74 CanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContextOrIma
geBitmapRenderingContext; |
| 75 typedef CanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContextO
rImageBitmapRenderingContext | 75 typedef CanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContextO
rImageBitmapRenderingContext |
| 76 RenderingContext; | 76 RenderingContext; |
| 77 | 77 |
| 78 class CORE_EXPORT HTMLCanvasElement final | 78 class CORE_EXPORT HTMLCanvasElement final : public HTMLElement, |
| 79 : public HTMLElement, | 79 public ContextLifecycleObserver, |
| 80 public ContextLifecycleObserver, | 80 public PageVisibilityObserver, |
| 81 public PageVisibilityObserver, | 81 public CanvasImageSource, |
| 82 public CanvasImageSource, | 82 public CanvasRenderingContextHost, |
| 83 public CanvasRenderingContextHost, | 83 public SurfaceLayerBridgeObserver, |
| 84 public CanvasSurfaceLayerBridgeObserver, | 84 public ImageBufferClient, |
| 85 public ImageBufferClient, | 85 public ImageBitmapSource, |
| 86 public ImageBitmapSource, | 86 public OffscreenCanvasPlaceholder { |
| 87 public OffscreenCanvasPlaceholder { | |
| 88 DEFINE_WRAPPERTYPEINFO(); | 87 DEFINE_WRAPPERTYPEINFO(); |
| 89 USING_GARBAGE_COLLECTED_MIXIN(HTMLCanvasElement); | 88 USING_GARBAGE_COLLECTED_MIXIN(HTMLCanvasElement); |
| 90 USING_PRE_FINALIZER(HTMLCanvasElement, Dispose); | 89 USING_PRE_FINALIZER(HTMLCanvasElement, Dispose); |
| 91 | 90 |
| 92 public: | 91 public: |
| 93 using Node::GetExecutionContext; | 92 using Node::GetExecutionContext; |
| 94 | 93 |
| 95 DECLARE_NODE_FACTORY(HTMLCanvasElement); | 94 DECLARE_NODE_FACTORY(HTMLCanvasElement); |
| 96 ~HTMLCanvasElement() override; | 95 ~HTMLCanvasElement() override; |
| 97 | 96 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 SnapshotReason, | 191 SnapshotReason, |
| 193 const FloatSize&) override; | 192 const FloatSize&) override; |
| 194 bool WouldTaintOrigin(SecurityOrigin*) const override; | 193 bool WouldTaintOrigin(SecurityOrigin*) const override; |
| 195 FloatSize ElementSize(const FloatSize&) const override; | 194 FloatSize ElementSize(const FloatSize&) const override; |
| 196 bool IsCanvasElement() const override { return true; } | 195 bool IsCanvasElement() const override { return true; } |
| 197 bool IsOpaque() const override; | 196 bool IsOpaque() const override; |
| 198 bool IsAccelerated() const override; | 197 bool IsAccelerated() const override; |
| 199 int SourceWidth() override { return size_.Width(); } | 198 int SourceWidth() override { return size_.Width(); } |
| 200 int SourceHeight() override { return size_.Height(); } | 199 int SourceHeight() override { return size_.Height(); } |
| 201 | 200 |
| 202 // CanvasSurfaceLayerBridgeObserver implementation | 201 // SurfaceLayerBridgeObserver implementation |
| 203 void OnWebLayerReplaced() override; | 202 void OnWebLayerReplaced() override; |
| 204 | 203 |
| 205 // ImageBufferClient implementation | 204 // ImageBufferClient implementation |
| 206 void NotifySurfaceInvalid() override; | 205 void NotifySurfaceInvalid() override; |
| 207 void DidDisableAcceleration() override; | 206 void DidDisableAcceleration() override; |
| 208 void RestoreCanvasMatrixClipStack(PaintCanvas*) const override; | 207 void RestoreCanvasMatrixClipStack(PaintCanvas*) const override; |
| 209 void SetNeedsCompositingUpdate() override; | 208 void SetNeedsCompositingUpdate() override; |
| 210 | 209 |
| 211 // ImageBitmapSource implementation | 210 // ImageBitmapSource implementation |
| 212 IntSize BitmapSourceSize() const override; | 211 IntSize BitmapSourceSize() const override; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 236 const ComputedStyle& new_style); | 235 const ComputedStyle& new_style); |
| 237 | 236 |
| 238 void NotifyListenersCanvasChanged(); | 237 void NotifyListenersCanvasChanged(); |
| 239 | 238 |
| 240 // For Canvas HitRegions | 239 // For Canvas HitRegions |
| 241 bool IsSupportedInteractiveCanvasFallback(const Element&); | 240 bool IsSupportedInteractiveCanvasFallback(const Element&); |
| 242 HitTestCanvasResult* GetControlAndIdIfHitRegionExists(const LayoutPoint&); | 241 HitTestCanvasResult* GetControlAndIdIfHitRegionExists(const LayoutPoint&); |
| 243 String GetIdFromControl(const Element*); | 242 String GetIdFromControl(const Element*); |
| 244 | 243 |
| 245 // For OffscreenCanvas that controls this html canvas element | 244 // For OffscreenCanvas that controls this html canvas element |
| 246 CanvasSurfaceLayerBridge* SurfaceLayerBridge() const { | 245 SurfaceLayerBridge* SurfaceLayerBridge() const { |
| 247 return surface_layer_bridge_.get(); | 246 return surface_layer_bridge_.get(); |
| 248 } | 247 } |
| 249 void CreateLayer(); | 248 void CreateLayer(); |
| 250 | 249 |
| 251 void DetachContext() override { context_ = nullptr; } | 250 void DetachContext() override { context_ = nullptr; } |
| 252 | 251 |
| 253 void WillDrawImageTo2DContext(CanvasImageSource*); | 252 void WillDrawImageTo2DContext(CanvasImageSource*); |
| 254 | 253 |
| 255 ExecutionContext* GetTopExecutionContext() const override { | 254 ExecutionContext* GetTopExecutionContext() const override { |
| 256 return GetDocument().GetExecutionContext(); | 255 return GetDocument().GetExecutionContext(); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 // allocate an imageBuffer after the first attempt failed. | 329 // allocate an imageBuffer after the first attempt failed. |
| 331 mutable bool did_fail_to_create_image_buffer_; | 330 mutable bool did_fail_to_create_image_buffer_; |
| 332 bool image_buffer_is_clear_; | 331 bool image_buffer_is_clear_; |
| 333 std::unique_ptr<ImageBuffer> image_buffer_; | 332 std::unique_ptr<ImageBuffer> image_buffer_; |
| 334 | 333 |
| 335 // FIXME: This is temporary for platforms that have to copy the image buffer | 334 // FIXME: This is temporary for platforms that have to copy the image buffer |
| 336 // to render (and for CSSCanvasValue). | 335 // to render (and for CSSCanvasValue). |
| 337 mutable RefPtr<Image> copied_image_; | 336 mutable RefPtr<Image> copied_image_; |
| 338 | 337 |
| 339 // Used for OffscreenCanvas that controls this HTML canvas element | 338 // Used for OffscreenCanvas that controls this HTML canvas element |
| 340 std::unique_ptr<CanvasSurfaceLayerBridge> surface_layer_bridge_; | 339 std::unique_ptr<::blink::SurfaceLayerBridge> surface_layer_bridge_; |
| 341 | 340 |
| 342 bool did_notify_listeners_for_current_frame_ = false; | 341 bool did_notify_listeners_for_current_frame_ = false; |
| 343 }; | 342 }; |
| 344 | 343 |
| 345 } // namespace blink | 344 } // namespace blink |
| 346 | 345 |
| 347 #endif // HTMLCanvasElement_h | 346 #endif // HTMLCanvasElement_h |
| OLD | NEW |