summaryrefslogtreecommitdiff
path: root/Source/WebCore/html/HTMLCanvasElement.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/html/HTMLCanvasElement.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/html/HTMLCanvasElement.h')
-rw-r--r--Source/WebCore/html/HTMLCanvasElement.h119
1 files changed, 54 insertions, 65 deletions
diff --git a/Source/WebCore/html/HTMLCanvasElement.h b/Source/WebCore/html/HTMLCanvasElement.h
index 383a188e7..3b79114da 100644
--- a/Source/WebCore/html/HTMLCanvasElement.h
+++ b/Source/WebCore/html/HTMLCanvasElement.h
@@ -12,10 +12,10 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
@@ -25,31 +25,31 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef HTMLCanvasElement_h
-#define HTMLCanvasElement_h
+#pragma once
#include "FloatRect.h"
#include "HTMLElement.h"
#include "IntSize.h"
+#include <memory>
#include <wtf/Forward.h>
-#if USE(CG)
-#define DefaultInterpolationQuality InterpolationLow
-#else
-#define DefaultInterpolationQuality InterpolationDefault
+#if ENABLE(WEBGL)
+#include "WebGLContextAttributes.h"
#endif
namespace WebCore {
-class CanvasContextAttributes;
class CanvasRenderingContext;
class GraphicsContext;
class GraphicsContextStateSaver;
class HTMLCanvasElement;
class Image;
-class ImageData;
class ImageBuffer;
-class IntSize;
+class ImageData;
+
+namespace DisplayList {
+using AsTextFlags = unsigned;
+}
class CanvasObserver {
public:
@@ -62,25 +62,24 @@ public:
class HTMLCanvasElement final : public HTMLElement {
public:
- static PassRefPtr<HTMLCanvasElement> create(Document&);
- static PassRefPtr<HTMLCanvasElement> create(const QualifiedName&, Document&);
+ static Ref<HTMLCanvasElement> create(Document&);
+ static Ref<HTMLCanvasElement> create(const QualifiedName&, Document&);
virtual ~HTMLCanvasElement();
void addObserver(CanvasObserver&);
void removeObserver(CanvasObserver&);
- // Attributes and functions exposed to script
- int width() const { return size().width(); }
- int height() const { return size().height(); }
+ unsigned width() const { return size().width(); }
+ unsigned height() const { return size().height(); }
const IntSize& size() const { return m_size; }
- void setWidth(int);
- void setHeight(int);
+ WEBCORE_EXPORT void setWidth(unsigned);
+ WEBCORE_EXPORT void setHeight(unsigned);
void setSize(const IntSize& newSize)
{
- if (newSize == size() && targetDeviceScaleFactor() == m_deviceScaleFactor)
+ if (newSize == size())
return;
m_ignoreReset = true;
setWidth(newSize.width());
@@ -89,22 +88,25 @@ public:
reset();
}
- CanvasRenderingContext* getContext(const String&, CanvasContextAttributes* attributes = 0);
- bool probablySupportsContext(const String&, CanvasContextAttributes* = 0);
+ CanvasRenderingContext* getContext(const String&);
+
static bool is2dType(const String&);
+ CanvasRenderingContext* getContext2d(const String&);
+
#if ENABLE(WEBGL)
static bool is3dType(const String&);
+ CanvasRenderingContext* getContextWebGL(const String&, WebGLContextAttributes&& = { });
#endif
static String toEncodingMimeType(const String& mimeType);
- String toDataURL(const String& mimeType, const double* quality, ExceptionCode&);
- String toDataURL(const String& mimeType, ExceptionCode& ec) { return toDataURL(mimeType, 0, ec); }
+ WEBCORE_EXPORT ExceptionOr<String> toDataURL(const String& mimeType, std::optional<double> quality);
+ ExceptionOr<String> toDataURL(const String& mimeType) { return toDataURL(mimeType, std::nullopt); }
// Used for rendering
void didDraw(const FloatRect&);
void notifyObserversCanvasChanged(const FloatRect&);
- void paint(GraphicsContext*, const LayoutRect&, bool useLowQualityScale = false);
+ void paint(GraphicsContext&, const LayoutRect&);
GraphicsContext* drawingContext() const;
GraphicsContext* existingDrawingContext() const;
@@ -114,7 +116,7 @@ public:
ImageBuffer* buffer() const;
Image* copiedImage() const;
void clearCopiedImage();
- PassRefPtr<ImageData> getImageData();
+ RefPtr<ImageData> getImageData();
void makePresentationCopy();
void clearPresentationCopy();
@@ -127,78 +129,65 @@ public:
void setOriginTainted() { m_originClean = false; }
bool originClean() const { return m_originClean; }
-#if PLATFORM(IOS)
- // FIXME: Can we use unsigned data types, unsigned or size_t?
- void setMaximumDecodedImageSize(float maximumDecodedImageSize) { m_maximumDecodedImageSize = maximumDecodedImageSize; }
- float maximumDecodedImageSize() { return m_maximumDecodedImageSize; }
-#endif
-
AffineTransform baseTransform() const;
-#if ENABLE(WEBGL)
- bool is3D() const;
-#endif
-
void makeRenderingResultsAvailable();
bool hasCreatedImageBuffer() const { return m_hasCreatedImageBuffer; }
bool shouldAccelerate(const IntSize&) const;
- float deviceScaleFactor() const { return m_deviceScaleFactor; }
+ WEBCORE_EXPORT void setUsesDisplayListDrawing(bool);
+ WEBCORE_EXPORT void setTracksDisplayListReplay(bool);
+ WEBCORE_EXPORT String displayListAsText(DisplayList::AsTextFlags) const;
+ WEBCORE_EXPORT String replayDisplayListAsText(DisplayList::AsTextFlags) const;
+
+ size_t memoryCost() const;
+ size_t externalMemoryCost() const;
private:
HTMLCanvasElement(const QualifiedName&, Document&);
- virtual void parseAttribute(const QualifiedName&, const AtomicString&) override;
- virtual RenderPtr<RenderElement> createElementRenderer(PassRef<RenderStyle>) override;
- virtual void willAttachRenderers() override;
- virtual bool areAuthorShadowsAllowed() const override;
+ void parseAttribute(const QualifiedName&, const AtomicString&) final;
+ RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) final;
- virtual bool canContainRangeEndPoint() const override;
- virtual bool canStartSelection() const override;
+ bool canContainRangeEndPoint() const final;
+ bool canStartSelection() const final;
void reset();
- float targetDeviceScaleFactor() const;
-
void createImageBuffer() const;
void clearImageBuffer() const;
void setSurfaceSize(const IntSize&);
+ void setImageBuffer(std::unique_ptr<ImageBuffer>) const;
+ void releaseImageBufferAndContext();
bool paintsIntoCanvasBuffer() const;
- HashSet<CanvasObserver*> m_observers;
-
- IntSize m_size;
-
- OwnPtr<CanvasRenderingContext> m_context;
+#if ENABLE(WEBGL)
+ bool is3D() const;
+#endif
- bool m_rendererIsCanvas;
+ HashSet<CanvasObserver*> m_observers;
+ std::unique_ptr<CanvasRenderingContext> m_context;
- bool m_ignoreReset;
FloatRect m_dirtyRect;
+ IntSize m_size;
- float m_deviceScaleFactor;
- bool m_originClean;
+ bool m_originClean { true };
+ bool m_ignoreReset { false };
-#if PLATFORM(IOS)
- // FIXME: Can we use a unsigned data type, unsigned or size_t?
- float m_maximumDecodedImageSize;
-#endif
+ bool m_usesDisplayListDrawing { false };
+ bool m_tracksDisplayListReplay { false };
// m_createdImageBuffer means we tried to malloc the buffer. We didn't necessarily get it.
- mutable bool m_hasCreatedImageBuffer;
- mutable bool m_didClearImageBuffer;
+ mutable bool m_hasCreatedImageBuffer { false };
+ mutable bool m_didClearImageBuffer { false };
mutable std::unique_ptr<ImageBuffer> m_imageBuffer;
- mutable OwnPtr<GraphicsContextStateSaver> m_contextStateSaver;
+ mutable std::unique_ptr<GraphicsContextStateSaver> m_contextStateSaver;
mutable RefPtr<Image> m_presentedImage;
mutable RefPtr<Image> m_copiedImage; // FIXME: This is temporary for platforms that have to copy the image buffer to render (and for CSSCanvasValue).
};
-NODE_TYPE_CASTS(HTMLCanvasElement)
-
-} //namespace
-
-#endif
+} // namespace WebCore