| 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 26 matching lines...) Expand all Loading... |
| 96 virtual ContextType getContextType() const = 0; | 98 virtual ContextType getContextType() const = 0; |
| 97 virtual bool isAccelerated() const { return false; } | 99 virtual bool isAccelerated() const { return false; } |
| 98 virtual bool shouldAntialias() const { return false; } | 100 virtual bool shouldAntialias() const { return false; } |
| 99 virtual void setIsHidden(bool) = 0; | 101 virtual void setIsHidden(bool) = 0; |
| 100 virtual bool isContextLost() const { return true; } | 102 virtual bool isContextLost() const { return true; } |
| 101 virtual void setCanvasGetContextResult(RenderingContext&) { NOTREACHED(); }; | 103 virtual void setCanvasGetContextResult(RenderingContext&) { NOTREACHED(); }; |
| 102 virtual void setOffscreenCanvasGetContextResult(OffscreenRenderingContext&) { | 104 virtual void setOffscreenCanvasGetContextResult(OffscreenRenderingContext&) { |
| 103 NOTREACHED(); | 105 NOTREACHED(); |
| 104 } | 106 } |
| 105 virtual bool isPaintable() const = 0; | 107 virtual bool isPaintable() const = 0; |
| 108 virtual void didDraw(const SkIRect& dirtyRect); |
| 106 | 109 |
| 107 // Return true if the content is updated. | 110 // Return true if the content is updated. |
| 108 virtual bool paintRenderingResultsToCanvas(SourceDrawingBuffer) { | 111 virtual bool paintRenderingResultsToCanvas(SourceDrawingBuffer) { |
| 109 return false; | 112 return false; |
| 110 } | 113 } |
| 111 | 114 |
| 112 virtual WebLayer* platformLayer() const { return nullptr; } | 115 virtual WebLayer* platformLayer() const { return nullptr; } |
| 113 | 116 |
| 114 enum LostContextMode { | 117 enum LostContextMode { |
| 115 NotLostContext, | 118 NotLostContext, |
| 116 | 119 |
| 117 // Lost context occurred at the graphics system level. | 120 // Lost context occurred at the graphics system level. |
| 118 RealLostContext, | 121 RealLostContext, |
| 119 | 122 |
| 120 // Lost context provoked by WEBGL_lose_context. | 123 // Lost context provoked by WEBGL_lose_context. |
| 121 WebGLLoseContextLostContext, | 124 WebGLLoseContextLostContext, |
| 122 | 125 |
| 123 // Lost context occurred due to internal implementation reasons. | 126 // Lost context occurred due to internal implementation reasons. |
| 124 SyntheticLostContext, | 127 SyntheticLostContext, |
| 125 }; | 128 }; |
| 126 virtual void loseContext(LostContextMode) {} | 129 virtual void loseContext(LostContextMode) {} |
| 127 | 130 |
| 131 // WebThread::TaskObserver implementation |
| 132 void didProcessTask() override; |
| 133 void willProcessTask() final {} |
| 134 |
| 128 // Canvas2D-specific interface | 135 // Canvas2D-specific interface |
| 129 virtual bool is2d() const { return false; } | 136 virtual bool is2d() const { return false; } |
| 130 virtual void restoreCanvasMatrixClipStack(PaintCanvas*) const {} | 137 virtual void restoreCanvasMatrixClipStack(PaintCanvas*) const {} |
| 131 virtual void reset() {} | 138 virtual void reset() {} |
| 132 virtual void clearRect(double x, double y, double width, double height) {} | 139 virtual void clearRect(double x, double y, double width, double height) {} |
| 133 virtual void didSetSurfaceSize() {} | 140 virtual void didSetSurfaceSize() {} |
| 134 virtual void setShouldAntialias(bool) {} | 141 virtual void setShouldAntialias(bool) {} |
| 135 virtual unsigned hitRegionsCount() const { return 0; } | 142 virtual unsigned hitRegionsCount() const { return 0; } |
| 136 virtual void setFont(const String&) {} | 143 virtual void setFont(const String&) {} |
| 137 virtual void styleDidChange(const ComputedStyle* oldStyle, | 144 virtual void styleDidChange(const ComputedStyle* oldStyle, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 | 193 |
| 187 private: | 194 private: |
| 188 void dispose(); | 195 void dispose(); |
| 189 | 196 |
| 190 Member<HTMLCanvasElement> m_canvas; | 197 Member<HTMLCanvasElement> m_canvas; |
| 191 Member<OffscreenCanvas> m_offscreenCanvas; | 198 Member<OffscreenCanvas> m_offscreenCanvas; |
| 192 HashSet<String> m_cleanURLs; | 199 HashSet<String> m_cleanURLs; |
| 193 HashSet<String> m_dirtyURLs; | 200 HashSet<String> m_dirtyURLs; |
| 194 CanvasColorSpace m_colorSpace; | 201 CanvasColorSpace m_colorSpace; |
| 195 CanvasContextCreationAttributes m_creationAttributes; | 202 CanvasContextCreationAttributes m_creationAttributes; |
| 203 bool m_finalizeFrameScheduled = false; |
| 196 }; | 204 }; |
| 197 | 205 |
| 198 } // namespace blink | 206 } // namespace blink |
| 199 | 207 |
| 200 #endif | 208 #endif |
| OLD | NEW |