| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 namespace blink { | 40 namespace blink { |
| 41 | 41 |
| 42 class CanvasImageSource; | 42 class CanvasImageSource; |
| 43 class HTMLCanvasElement; | 43 class HTMLCanvasElement; |
| 44 class ImageData; | 44 class ImageData; |
| 45 class ImageBitmap; | 45 class ImageBitmap; |
| 46 | 46 |
| 47 class CORE_EXPORT CanvasRenderingContext : public GarbageCollectedFinalized<Canv
asRenderingContext>, public ScriptWrappable { | 47 class CORE_EXPORT CanvasRenderingContext : public GarbageCollectedFinalized<Canv
asRenderingContext>, public ScriptWrappable { |
| 48 WTF_MAKE_NONCOPYABLE(CanvasRenderingContext); | 48 WTF_MAKE_NONCOPYABLE(CanvasRenderingContext); |
| 49 USING_PRE_FINALIZER(CanvasRenderingContext, dispose); |
| 49 public: | 50 public: |
| 50 virtual ~CanvasRenderingContext() { } | 51 virtual ~CanvasRenderingContext() { } |
| 51 | 52 |
| 52 // A Canvas can either be "2D" or "webgl" but never both. If you request a 2
D canvas and the existing | 53 // A Canvas can either be "2D" or "webgl" but never both. If you request a 2
D canvas and the existing |
| 53 // context is already 2D, just return that. If the existing context is WebGL
, then destroy it | 54 // context is already 2D, just return that. If the existing context is WebGL
, then destroy it |
| 54 // before creating a new 2D context. Vice versa when requesting a WebGL canv
as. Requesting a | 55 // before creating a new 2D context. Vice versa when requesting a WebGL canv
as. Requesting a |
| 55 // context with any other type string will destroy any existing context. | 56 // context with any other type string will destroy any existing context. |
| 56 enum ContextType { | 57 enum ContextType { |
| 57 // Do not change assigned numbers of existing items: add new features to
the end of the list. | 58 // Do not change assigned numbers of existing items: add new features to
the end of the list. |
| 58 Context2d = 0, | 59 Context2d = 0, |
| 59 ContextExperimentalWebgl = 2, | 60 ContextExperimentalWebgl = 2, |
| 60 ContextWebgl = 3, | 61 ContextWebgl = 3, |
| 61 ContextWebgl2 = 4, | 62 ContextWebgl2 = 4, |
| 62 ContextImageBitmap = 5, | 63 ContextImageBitmap = 5, |
| 63 ContextTypeCount, | 64 ContextTypeCount, |
| 64 }; | 65 }; |
| 65 | 66 |
| 66 static ContextType contextTypeFromId(const String& id); | 67 static ContextType contextTypeFromId(const String& id); |
| 67 static ContextType resolveContextTypeAliases(ContextType); | 68 static ContextType resolveContextTypeAliases(ContextType); |
| 68 | 69 |
| 69 HTMLCanvasElement* canvas() const { return m_canvas; } | 70 HTMLCanvasElement* canvas() const { return m_canvas; } |
| 70 | 71 |
| 71 virtual ContextType getContextType() const = 0; | 72 virtual ContextType getContextType() const = 0; |
| 72 virtual bool isAccelerated() const { return false; } | 73 virtual bool isAccelerated() const { return false; } |
| 73 virtual bool shouldAntialias() const { return false; } | 74 virtual bool shouldAntialias() const { return false; } |
| 74 virtual bool hasAlpha() const { return true; } | 75 virtual bool hasAlpha() const { return true; } |
| 75 virtual void setIsHidden(bool) = 0; | 76 virtual void setIsHidden(bool) = 0; |
| 76 virtual bool isContextLost() const { return true; } | 77 virtual bool isContextLost() const { return true; } |
| 77 virtual void setCanvasGetContextResult(RenderingContext&) { ASSERT_NOT_REACH
ED(); }; | 78 virtual void setCanvasGetContextResult(RenderingContext&) { NOTREACHED(); }; |
| 78 virtual void setOffscreenCanvasGetContextResult(OffscreenRenderingContext&)
{ ASSERT_NOT_REACHED(); } | 79 virtual void setOffscreenCanvasGetContextResult(OffscreenRenderingContext&)
{ NOTREACHED(); } |
| 79 | 80 |
| 80 // Return true if the content is updated. | 81 // Return true if the content is updated. |
| 81 virtual bool paintRenderingResultsToCanvas(SourceDrawingBuffer) { return fal
se; } | 82 virtual bool paintRenderingResultsToCanvas(SourceDrawingBuffer) { return fal
se; } |
| 82 | 83 |
| 83 virtual WebLayer* platformLayer() const { return nullptr; } | 84 virtual WebLayer* platformLayer() const { return nullptr; } |
| 84 | 85 |
| 85 enum LostContextMode { | 86 enum LostContextMode { |
| 86 NotLostContext, | 87 NotLostContext, |
| 87 | 88 |
| 88 // Lost context occurred at the graphics system level. | 89 // Lost context occurred at the graphics system level. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 99 // Canvas2D-specific interface | 100 // Canvas2D-specific interface |
| 100 virtual bool is2d() const { return false; } | 101 virtual bool is2d() const { return false; } |
| 101 virtual void restoreCanvasMatrixClipStack(SkCanvas*) const { } | 102 virtual void restoreCanvasMatrixClipStack(SkCanvas*) const { } |
| 102 virtual void reset() { } | 103 virtual void reset() { } |
| 103 virtual void clearRect(double x, double y, double width, double height) { } | 104 virtual void clearRect(double x, double y, double width, double height) { } |
| 104 virtual void didSetSurfaceSize() { } | 105 virtual void didSetSurfaceSize() { } |
| 105 virtual void setShouldAntialias(bool) { } | 106 virtual void setShouldAntialias(bool) { } |
| 106 virtual unsigned hitRegionsCount() const { return 0; } | 107 virtual unsigned hitRegionsCount() const { return 0; } |
| 107 virtual void setFont(const String&) { } | 108 virtual void setFont(const String&) { } |
| 108 virtual void styleDidChange(const ComputedStyle* oldStyle, const ComputedSty
le& newStyle) { } | 109 virtual void styleDidChange(const ComputedStyle* oldStyle, const ComputedSty
le& newStyle) { } |
| 109 virtual std::pair<Element*, String> getControlAndIdIfHitRegionExists(const L
ayoutPoint& location) { ASSERT_NOT_REACHED(); return std::make_pair(nullptr, Str
ing()); } | 110 virtual std::pair<Element*, String> getControlAndIdIfHitRegionExists(const L
ayoutPoint& location) { NOTREACHED(); return std::make_pair(nullptr, String());
} |
| 110 virtual String getIdFromControl(const Element* element) { return String(); } | 111 virtual String getIdFromControl(const Element* element) { return String(); } |
| 111 | 112 |
| 112 // WebGL-specific interface | 113 // WebGL-specific interface |
| 113 virtual bool is3d() const { return false; } | 114 virtual bool is3d() const { return false; } |
| 114 virtual void setFilterQuality(SkFilterQuality) { ASSERT_NOT_REACHED(); } | 115 virtual void setFilterQuality(SkFilterQuality) { NOTREACHED(); } |
| 115 virtual void reshape(int width, int height) { ASSERT_NOT_REACHED(); } | 116 virtual void reshape(int width, int height) { NOTREACHED(); } |
| 116 virtual void markLayerComposited() { ASSERT_NOT_REACHED(); } | 117 virtual void markLayerComposited() { NOTREACHED(); } |
| 117 virtual ImageData* paintRenderingResultsToImageData(SourceDrawingBuffer) { A
SSERT_NOT_REACHED(); return nullptr; } | 118 virtual ImageData* paintRenderingResultsToImageData(SourceDrawingBuffer) { N
OTREACHED(); return nullptr; } |
| 118 virtual int externallyAllocatedBytesPerPixel() { ASSERT_NOT_REACHED(); retur
n 0; } | 119 virtual int externallyAllocatedBytesPerPixel() { NOTREACHED(); return 0; } |
| 119 | 120 |
| 120 // ImageBitmap-specific interface | 121 // ImageBitmap-specific interface |
| 121 virtual bool paint(GraphicsContext&, const IntRect&) { return false; } | 122 virtual bool paint(GraphicsContext&, const IntRect&) { return false; } |
| 122 | 123 |
| 123 bool wouldTaintOrigin(CanvasImageSource*, SecurityOrigin* = nullptr); | 124 bool wouldTaintOrigin(CanvasImageSource*, SecurityOrigin* = nullptr); |
| 124 void didMoveToNewDocument(Document*); | 125 void didMoveToNewDocument(Document*); |
| 125 | 126 |
| 126 // OffscreenCanvas-specific methods | 127 // OffscreenCanvas-specific methods |
| 127 OffscreenCanvas* getOffscreenCanvas() const { return m_offscreenCanvas; } | 128 OffscreenCanvas* getOffscreenCanvas() const { return m_offscreenCanvas; } |
| 128 virtual ImageBitmap* transferToImageBitmap(ExceptionState&) { return nullptr
; } | 129 virtual ImageBitmap* transferToImageBitmap(ExceptionState&) { return nullptr
; } |
| 129 | 130 |
| 131 void detachCanvas() { m_canvas = nullptr; } |
| 132 |
| 130 protected: | 133 protected: |
| 131 CanvasRenderingContext(HTMLCanvasElement* = nullptr, OffscreenCanvas* = null
ptr); | 134 CanvasRenderingContext(HTMLCanvasElement* = nullptr, OffscreenCanvas* = null
ptr); |
| 132 DECLARE_VIRTUAL_TRACE(); | 135 DECLARE_VIRTUAL_TRACE(); |
| 133 virtual void stop() = 0; | 136 virtual void stop() = 0; |
| 134 | 137 |
| 135 private: | 138 private: |
| 139 void dispose(); |
| 140 |
| 136 Member<HTMLCanvasElement> m_canvas; | 141 Member<HTMLCanvasElement> m_canvas; |
| 137 Member<OffscreenCanvas> m_offscreenCanvas; | 142 Member<OffscreenCanvas> m_offscreenCanvas; |
| 138 HashSet<String> m_cleanURLs; | 143 HashSet<String> m_cleanURLs; |
| 139 HashSet<String> m_dirtyURLs; | 144 HashSet<String> m_dirtyURLs; |
| 140 }; | 145 }; |
| 141 | 146 |
| 142 } // namespace blink | 147 } // namespace blink |
| 143 | 148 |
| 144 #endif | 149 #endif |
| OLD | NEW |