| 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 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 #ifndef CanvasRenderingContext_h | 26 #ifndef CanvasRenderingContext_h |
| 27 #define CanvasRenderingContext_h | 27 #define CanvasRenderingContext_h |
| 28 | 28 |
| 29 #include "core/CoreExport.h" | 29 #include "core/CoreExport.h" |
| 30 #include "core/html/HTMLCanvasElement.h" | 30 #include "core/html/HTMLCanvasElement.h" |
| 31 #include "core/html/canvas/CanvasContextCreationAttributes.h" | 31 #include "core/html/canvas/CanvasContextCreationAttributes.h" |
| 32 #include "core/layout/HitTestCanvasResult.h" | 32 #include "core/layout/HitTestCanvasResult.h" |
| 33 #include "core/offscreencanvas/OffscreenCanvas.h" | 33 #include "core/offscreencanvas/OffscreenCanvas.h" |
| 34 #include "platform/graphics/ColorBehavior.h" | 34 #include "platform/graphics/ColorBehavior.h" |
| 35 #include "public/platform/WebThread.h" |
| 35 #include "third_party/skia/include/core/SkColorSpace.h" | 36 #include "third_party/skia/include/core/SkColorSpace.h" |
| 36 #include "third_party/skia/include/core/SkImageInfo.h" | 37 #include "third_party/skia/include/core/SkImageInfo.h" |
| 37 #include "wtf/HashSet.h" | 38 #include "wtf/HashSet.h" |
| 38 #include "wtf/Noncopyable.h" | 39 #include "wtf/Noncopyable.h" |
| 39 #include "wtf/text/StringHash.h" | 40 #include "wtf/text/StringHash.h" |
| 40 | 41 |
| 41 namespace blink { | 42 namespace blink { |
| 42 | 43 |
| 43 class CanvasImageSource; | 44 class CanvasImageSource; |
| 44 class HTMLCanvasElement; | 45 class HTMLCanvasElement; |
| 45 class ImageData; | 46 class ImageData; |
| 46 class ImageBitmap; | 47 class ImageBitmap; |
| 47 class WebLayer; | 48 class WebLayer; |
| 48 | 49 |
| 49 enum CanvasColorSpace { | 50 enum CanvasColorSpace { |
| 50 kLegacyCanvasColorSpace, | 51 kLegacyCanvasColorSpace, |
| 51 kSRGBCanvasColorSpace, | 52 kSRGBCanvasColorSpace, |
| 52 kLinearRGBCanvasColorSpace, | 53 kLinearRGBCanvasColorSpace, |
| 53 kRec2020CanvasColorSpace, | 54 kRec2020CanvasColorSpace, |
| 54 kP3CanvasColorSpace, | 55 kP3CanvasColorSpace, |
| 55 }; | 56 }; |
| 56 | 57 |
| 57 class CORE_EXPORT CanvasRenderingContext | 58 class CORE_EXPORT CanvasRenderingContext |
| 58 : public GarbageCollectedFinalized<CanvasRenderingContext>, | 59 : public GarbageCollectedFinalized<CanvasRenderingContext>, |
| 59 public ScriptWrappable { | 60 public ScriptWrappable, |
| 61 public WebThread::TaskObserver { |
| 60 WTF_MAKE_NONCOPYABLE(CanvasRenderingContext); | 62 WTF_MAKE_NONCOPYABLE(CanvasRenderingContext); |
| 61 USING_PRE_FINALIZER(CanvasRenderingContext, dispose); | 63 USING_PRE_FINALIZER(CanvasRenderingContext, dispose); |
| 62 | 64 |
| 63 public: | 65 public: |
| 64 virtual ~CanvasRenderingContext() {} | 66 virtual ~CanvasRenderingContext() {} |
| 65 | 67 |
| 66 // A Canvas can either be "2D" or "webgl" but never both. If you request a 2D | 68 // A Canvas can either be "2D" or "webgl" but never both. If you request a 2D |
| 67 // canvas and the existing context is already 2D, just return that. If the | 69 // canvas and the existing context is already 2D, just return that. If the |
| 68 // existing context is WebGL, then destroy it before creating a new 2D | 70 // existing context is WebGL, then destroy it before creating a new 2D |
| 69 // context. Vice versa when requesting a WebGL canvas. Requesting a context | 71 // context. Vice versa when requesting a WebGL canvas. Requesting a context |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 virtual ContextType getContextType() const = 0; | 104 virtual ContextType getContextType() const = 0; |
| 103 virtual bool isAccelerated() const { return false; } | 105 virtual bool isAccelerated() const { return false; } |
| 104 virtual bool shouldAntialias() const { return false; } | 106 virtual bool shouldAntialias() const { return false; } |
| 105 virtual void setIsHidden(bool) = 0; | 107 virtual void setIsHidden(bool) = 0; |
| 106 virtual bool isContextLost() const { return true; } | 108 virtual bool isContextLost() const { return true; } |
| 107 virtual void setCanvasGetContextResult(RenderingContext&) { NOTREACHED(); }; | 109 virtual void setCanvasGetContextResult(RenderingContext&) { NOTREACHED(); }; |
| 108 virtual void setOffscreenCanvasGetContextResult(OffscreenRenderingContext&) { | 110 virtual void setOffscreenCanvasGetContextResult(OffscreenRenderingContext&) { |
| 109 NOTREACHED(); | 111 NOTREACHED(); |
| 110 } | 112 } |
| 111 virtual bool isPaintable() const = 0; | 113 virtual bool isPaintable() const = 0; |
| 114 virtual void didDraw(const SkIRect& dirtyRect); |
| 112 | 115 |
| 113 // Return true if the content is updated. | 116 // Return true if the content is updated. |
| 114 virtual bool paintRenderingResultsToCanvas(SourceDrawingBuffer) { | 117 virtual bool paintRenderingResultsToCanvas(SourceDrawingBuffer) { |
| 115 return false; | 118 return false; |
| 116 } | 119 } |
| 117 | 120 |
| 118 virtual WebLayer* platformLayer() const { return nullptr; } | 121 virtual WebLayer* platformLayer() const { return nullptr; } |
| 119 | 122 |
| 120 enum LostContextMode { | 123 enum LostContextMode { |
| 121 NotLostContext, | 124 NotLostContext, |
| 122 | 125 |
| 123 // Lost context occurred at the graphics system level. | 126 // Lost context occurred at the graphics system level. |
| 124 RealLostContext, | 127 RealLostContext, |
| 125 | 128 |
| 126 // Lost context provoked by WEBGL_lose_context. | 129 // Lost context provoked by WEBGL_lose_context. |
| 127 WebGLLoseContextLostContext, | 130 WebGLLoseContextLostContext, |
| 128 | 131 |
| 129 // Lost context occurred due to internal implementation reasons. | 132 // Lost context occurred due to internal implementation reasons. |
| 130 SyntheticLostContext, | 133 SyntheticLostContext, |
| 131 }; | 134 }; |
| 132 virtual void loseContext(LostContextMode) {} | 135 virtual void loseContext(LostContextMode) {} |
| 133 | 136 |
| 137 // WebThread::TaskObserver implementation |
| 138 void didProcessTask() override; |
| 139 void willProcessTask() final {} |
| 140 |
| 134 // Canvas2D-specific interface | 141 // Canvas2D-specific interface |
| 135 virtual bool is2d() const { return false; } | 142 virtual bool is2d() const { return false; } |
| 136 virtual void restoreCanvasMatrixClipStack(PaintCanvas*) const {} | 143 virtual void restoreCanvasMatrixClipStack(PaintCanvas*) const {} |
| 137 virtual void reset() {} | 144 virtual void reset() {} |
| 138 virtual void clearRect(double x, double y, double width, double height) {} | 145 virtual void clearRect(double x, double y, double width, double height) {} |
| 139 virtual void didSetSurfaceSize() {} | 146 virtual void didSetSurfaceSize() {} |
| 140 virtual void setShouldAntialias(bool) {} | 147 virtual void setShouldAntialias(bool) {} |
| 141 virtual unsigned hitRegionsCount() const { return 0; } | 148 virtual unsigned hitRegionsCount() const { return 0; } |
| 142 virtual void setFont(const String&) {} | 149 virtual void setFont(const String&) {} |
| 143 virtual void styleDidChange(const ComputedStyle* oldStyle, | 150 virtual void styleDidChange(const ComputedStyle* oldStyle, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 | 199 |
| 193 private: | 200 private: |
| 194 void dispose(); | 201 void dispose(); |
| 195 | 202 |
| 196 Member<HTMLCanvasElement> m_canvas; | 203 Member<HTMLCanvasElement> m_canvas; |
| 197 Member<OffscreenCanvas> m_offscreenCanvas; | 204 Member<OffscreenCanvas> m_offscreenCanvas; |
| 198 HashSet<String> m_cleanURLs; | 205 HashSet<String> m_cleanURLs; |
| 199 HashSet<String> m_dirtyURLs; | 206 HashSet<String> m_dirtyURLs; |
| 200 CanvasColorSpace m_colorSpace; | 207 CanvasColorSpace m_colorSpace; |
| 201 CanvasContextCreationAttributes m_creationAttributes; | 208 CanvasContextCreationAttributes m_creationAttributes; |
| 209 bool m_finalizeFrameScheduled = false; |
| 202 }; | 210 }; |
| 203 | 211 |
| 204 } // namespace blink | 212 } // namespace blink |
| 205 | 213 |
| 206 #endif | 214 #endif |
| OLD | NEW |