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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 ContextWebgl2 = 4, | 63 ContextWebgl2 = 4, |
64 ContextImageBitmap = 5, | 64 ContextImageBitmap = 5, |
65 ContextTypeCount, | 65 ContextTypeCount, |
66 }; | 66 }; |
67 | 67 |
68 static ContextType contextTypeFromId(const String& id); | 68 static ContextType contextTypeFromId(const String& id); |
69 static ContextType resolveContextTypeAliases(ContextType); | 69 static ContextType resolveContextTypeAliases(ContextType); |
70 | 70 |
71 HTMLCanvasElement* canvas() const { return m_canvas; } | 71 HTMLCanvasElement* canvas() const { return m_canvas; } |
72 | 72 |
| 73 virtual PassRefPtr<Image> getImage(SnapshotReason) const = 0; |
73 virtual ContextType getContextType() const = 0; | 74 virtual ContextType getContextType() const = 0; |
74 virtual bool isAccelerated() const { return false; } | 75 virtual bool isAccelerated() const { return false; } |
75 virtual bool shouldAntialias() const { return false; } | 76 virtual bool shouldAntialias() const { return false; } |
76 virtual bool hasAlpha() const { return true; } | 77 virtual bool hasAlpha() const { return true; } |
77 virtual void setIsHidden(bool) = 0; | 78 virtual void setIsHidden(bool) = 0; |
78 virtual bool isContextLost() const { return true; } | 79 virtual bool isContextLost() const { return true; } |
79 virtual void setCanvasGetContextResult(RenderingContext&) { NOTREACHED(); }; | 80 virtual void setCanvasGetContextResult(RenderingContext&) { NOTREACHED(); }; |
80 virtual void setOffscreenCanvasGetContextResult(OffscreenRenderingContext&)
{ NOTREACHED(); } | 81 virtual void setOffscreenCanvasGetContextResult(OffscreenRenderingContext&)
{ NOTREACHED(); } |
| 82 virtual bool isPaintable() const = 0; |
81 | 83 |
82 // Return true if the content is updated. | 84 // Return true if the content is updated. |
83 virtual bool paintRenderingResultsToCanvas(SourceDrawingBuffer) { return fal
se; } | 85 virtual bool paintRenderingResultsToCanvas(SourceDrawingBuffer) { return fal
se; } |
84 | 86 |
85 // Note: this function is strictly for OffscreenCanvas only. | |
86 virtual bool isPaintable() const = 0; | |
87 | 87 |
88 virtual WebLayer* platformLayer() const { return nullptr; } | 88 virtual WebLayer* platformLayer() const { return nullptr; } |
89 | 89 |
90 enum LostContextMode { | 90 enum LostContextMode { |
91 NotLostContext, | 91 NotLostContext, |
92 | 92 |
93 // Lost context occurred at the graphics system level. | 93 // Lost context occurred at the graphics system level. |
94 RealLostContext, | 94 RealLostContext, |
95 | 95 |
96 // Lost context provoked by WEBGL_lose_context. | 96 // Lost context provoked by WEBGL_lose_context. |
(...skipping 23 matching lines...) Expand all Loading... |
120 // WebGL-specific interface | 120 // WebGL-specific interface |
121 virtual bool is3d() const { return false; } | 121 virtual bool is3d() const { return false; } |
122 virtual void setFilterQuality(SkFilterQuality) { NOTREACHED(); } | 122 virtual void setFilterQuality(SkFilterQuality) { NOTREACHED(); } |
123 virtual void reshape(int width, int height) { NOTREACHED(); } | 123 virtual void reshape(int width, int height) { NOTREACHED(); } |
124 virtual void markLayerComposited() { NOTREACHED(); } | 124 virtual void markLayerComposited() { NOTREACHED(); } |
125 virtual ImageData* paintRenderingResultsToImageData(SourceDrawingBuffer) { N
OTREACHED(); return nullptr; } | 125 virtual ImageData* paintRenderingResultsToImageData(SourceDrawingBuffer) { N
OTREACHED(); return nullptr; } |
126 virtual int externallyAllocatedBytesPerPixel() { NOTREACHED(); return 0; } | 126 virtual int externallyAllocatedBytesPerPixel() { NOTREACHED(); return 0; } |
127 | 127 |
128 // ImageBitmap-specific interface | 128 // ImageBitmap-specific interface |
129 virtual bool paint(GraphicsContext&, const IntRect&) { return false; } | 129 virtual bool paint(GraphicsContext&, const IntRect&) { return false; } |
130 virtual PassRefPtr<Image> getImage() const { return nullptr; } | |
131 | |
132 bool wouldTaintOrigin(CanvasImageSource*, SecurityOrigin* = nullptr); | |
133 void didMoveToNewDocument(Document*); | |
134 | 130 |
135 // OffscreenCanvas-specific methods | 131 // OffscreenCanvas-specific methods |
136 OffscreenCanvas* getOffscreenCanvas() const { return m_offscreenCanvas; } | 132 OffscreenCanvas* getOffscreenCanvas() const { return m_offscreenCanvas; } |
137 virtual ImageBitmap* transferToImageBitmap(ExceptionState&) { return nullptr
; } | 133 virtual ImageBitmap* transferToImageBitmap(ExceptionState&) { return nullptr
; } |
138 | 134 |
| 135 bool wouldTaintOrigin(CanvasImageSource*, SecurityOrigin* = nullptr); |
| 136 void didMoveToNewDocument(Document*); |
| 137 |
139 void detachCanvas() { m_canvas = nullptr; } | 138 void detachCanvas() { m_canvas = nullptr; } |
140 | 139 |
141 protected: | 140 protected: |
142 CanvasRenderingContext(HTMLCanvasElement* = nullptr, OffscreenCanvas* = null
ptr); | 141 CanvasRenderingContext(HTMLCanvasElement* = nullptr, OffscreenCanvas* = null
ptr); |
143 DECLARE_VIRTUAL_TRACE(); | 142 DECLARE_VIRTUAL_TRACE(); |
144 virtual void stop() = 0; | 143 virtual void stop() = 0; |
145 | 144 |
146 private: | 145 private: |
147 void dispose(); | 146 void dispose(); |
148 | 147 |
149 Member<HTMLCanvasElement> m_canvas; | 148 Member<HTMLCanvasElement> m_canvas; |
150 Member<OffscreenCanvas> m_offscreenCanvas; | 149 Member<OffscreenCanvas> m_offscreenCanvas; |
151 HashSet<String> m_cleanURLs; | 150 HashSet<String> m_cleanURLs; |
152 HashSet<String> m_dirtyURLs; | 151 HashSet<String> m_dirtyURLs; |
153 }; | 152 }; |
154 | 153 |
155 } // namespace blink | 154 } // namespace blink |
156 | 155 |
157 #endif | 156 #endif |
OLD | NEW |