Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Unified Diff: third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.h

Issue 1710633002: Pull up a subset of CanvasRenderingContext2D into BaseRenderingContext2D. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixup. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.h
diff --git a/third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.h b/third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.h
new file mode 100644
index 0000000000000000000000000000000000000000..c5790fef0b63583e607132f8ee35baebe8b507a9
--- /dev/null
+++ b/third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.h
@@ -0,0 +1,195 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BaseRenderingContext2D_h
+#define BaseRenderingContext2D_h
+
+#include "bindings/core/v8/UnionTypesCore.h"
+#include "bindings/modules/v8/UnionTypesModules.h"
+#include "core/html/canvas/CanvasRenderingContext.h"
+#include "modules/ModulesExport.h"
+#include "modules/canvas2d/CanvasPathMethods.h"
+#include "modules/canvas2d/CanvasRenderingContext2DState.h"
+
+namespace blink {
+
+class CanvasImageSource;
+class Color;
+class Image;
+class ImageBuffer;
+class Path2D;
+class SVGMatrixTearOff;
+
+typedef HTMLImageElementOrHTMLVideoElementOrHTMLCanvasElementOrImageBitmap CanvasImageSourceUnion;
+
+class MODULES_EXPORT BaseRenderingContext2D : public WillBeGarbageCollectedMixin, public CanvasPathMethods {
+public:
+ ~BaseRenderingContext2D() override;
+
+ void strokeStyle(StringOrCanvasGradientOrCanvasPattern&) const;
+ void setStrokeStyle(const StringOrCanvasGradientOrCanvasPattern&);
+
+ void fillStyle(StringOrCanvasGradientOrCanvasPattern&) const;
+ void setFillStyle(const StringOrCanvasGradientOrCanvasPattern&);
+
+ double lineWidth() const;
+ void setLineWidth(double);
+
+ String lineCap() const;
+ void setLineCap(const String&);
+
+ String lineJoin() const;
+ void setLineJoin(const String&);
+
+ double miterLimit() const;
+ void setMiterLimit(double);
+
+ const Vector<double>& getLineDash() const;
+ void setLineDash(const Vector<double>&);
+
+ double lineDashOffset() const;
+ void setLineDashOffset(double);
+
+ double shadowOffsetX() const;
+ void setShadowOffsetX(double);
+
+ double shadowOffsetY() const;
+ void setShadowOffsetY(double);
+
+ double shadowBlur() const;
+ void setShadowBlur(double);
+
+ String shadowColor() const;
+ void setShadowColor(const String&);
+
+ double globalAlpha() const;
+ void setGlobalAlpha(double);
+
+ String globalCompositeOperation() const;
+ void setGlobalCompositeOperation(const String&);
+
+ String filter() const;
+ void setFilter(const String&);
+
+ void save();
+ void restore();
+
+ PassRefPtrWillBeRawPtr<SVGMatrixTearOff> currentTransform() const;
+ void setCurrentTransform(PassRefPtrWillBeRawPtr<SVGMatrixTearOff>);
+
+ void scale(double sx, double sy);
+ void rotate(double angleInRadians);
+ void translate(double tx, double ty);
+ void transform(double m11, double m12, double m21, double m22, double dx, double dy);
+ void setTransform(double m11, double m12, double m21, double m22, double dx, double dy);
+ void resetTransform();
+
+ void beginPath();
+
+ void fill(const String& winding = "nonzero");
+ void fill(Path2D*, const String& winding = "nonzero");
+ void stroke();
+ void stroke(Path2D*);
+ void clip(const String& winding = "nonzero");
+ void clip(Path2D*, const String& winding = "nonzero");
+
+ bool isPointInPath(const double x, const double y, const String& winding = "nonzero");
+ bool isPointInPath(Path2D*, const double x, const double y, const String& winding = "nonzero");
+ bool isPointInStroke(const double x, const double y);
+ bool isPointInStroke(Path2D*, const double x, const double y);
+
+ void clearRect(double x, double y, double width, double height);
+ void fillRect(double x, double y, double width, double height);
+ void strokeRect(double x, double y, double width, double height);
+
+ void drawImage(const CanvasImageSourceUnion&, double x, double y, ExceptionState&);
+ void drawImage(const CanvasImageSourceUnion&, double x, double y, double width, double height, ExceptionState&);
+ void drawImage(const CanvasImageSourceUnion&, double sx, double sy, double sw, double sh, double dx, double dy, double dw, double dh, ExceptionState&);
+ void drawImage(CanvasImageSource*, double sx, double sy, double sw, double sh, double dx, double dy, double dw, double dh, ExceptionState&);
+
+ CanvasGradient* createLinearGradient(double x0, double y0, double x1, double y1);
+ CanvasGradient* createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1, ExceptionState&);
+ CanvasPattern* createPattern(const CanvasImageSourceUnion&, const String& repetitionType, ExceptionState&);
+
+ bool imageSmoothingEnabled() const;
+ void setImageSmoothingEnabled(bool);
+ String imageSmoothingQuality() const;
+ void setImageSmoothingQuality(const String&);
+
+ virtual bool originClean() const = 0;
+ virtual void setOriginTainted() = 0;
+ virtual bool wouldTaintOrigin(CanvasImageSource*) = 0;
+
+ virtual int width() const = 0;
+ virtual int height() const = 0;
+
+ virtual bool hasImageBuffer() const = 0;
+ virtual ImageBuffer* imageBuffer() const = 0;
+
+ virtual bool parseColorOrCurrentColor(Color&, const String& colorString) const = 0;
+
+ virtual SkCanvas* drawingCanvas() const = 0;
+ virtual SkCanvas* existingDrawingCanvas() const = 0;
+ virtual void disableDeferral(DisableDeferralReason) = 0;
+
+ virtual AffineTransform baseTransform() const = 0;
+
+ virtual void didDraw(const SkIRect& dirtyRect) = 0;
+
+ virtual bool stateHasFilter() = 0;
+ virtual SkImageFilter* stateGetFilter() = 0;
+
+ virtual void validateStateStack() = 0;
+
+ virtual bool hasAlpha() const = 0;
+
+ DECLARE_VIRTUAL_TRACE();
+
+protected:
+ BaseRenderingContext2D();
+
+ CanvasRenderingContext2DState& modifiableState();
+ const CanvasRenderingContext2DState& state() const { return *m_stateStack.last(); }
+
+ bool computeDirtyRect(const FloatRect& localBounds, SkIRect*);
+ bool computeDirtyRect(const FloatRect& localBounds, const SkIRect& transformedClipBounds, SkIRect*);
+
+ void drawForText(const Font&, const TextRunPaintInfo&, const FloatPoint& location, CanvasRenderingContext2DState::PaintType);
+
+ void inflateStrokeRect(FloatRect&) const;
+
+ enum DrawType {
+ ClipFill, // Fill that is already known to cover the current clip
+ UntransformedUnclippedFill
+ };
+
+ void checkOverdraw(const SkRect&, const SkPaint*, CanvasRenderingContext2DState::ImageType, DrawType);
+
+ WillBeHeapVector<OwnPtrWillBeMember<CanvasRenderingContext2DState>> m_stateStack;
+ AntiAliasingMode m_clipAntialiasing;
+
+private:
+ void realizeSaves();
+
+ bool shouldDrawImageAntialiased(const FloatRect& destRect) const;
+
+ template<typename DrawFunc, typename ContainsFunc>
+ bool draw(const DrawFunc&, const ContainsFunc&, const SkRect& bounds, CanvasRenderingContext2DState::PaintType, CanvasRenderingContext2DState::ImageType = CanvasRenderingContext2DState::NoImage);
+ void drawPathInternal(const Path&, CanvasRenderingContext2DState::PaintType, SkPath::FillType = SkPath::kWinding_FillType);
+ void drawImageInternal(SkCanvas*, CanvasImageSource*, Image*, const FloatRect& srcRect, const FloatRect& dstRect, const SkPaint*);
+ void clipInternal(const Path&, const String& windingRuleString);
+
+ bool isPointInPathInternal(const Path&, const double x, const double y, const String& windingRuleString);
+ bool isPointInStrokeInternal(const Path&, const double x, const double y);
+
+ template<typename DrawFunc>
+ void compositedDraw(const DrawFunc&, SkCanvas*, CanvasRenderingContext2DState::PaintType, CanvasRenderingContext2DState::ImageType);
+
+ void clearCanvas();
+ bool rectContainsTransformedRect(const FloatRect&, const SkIRect&) const;
+};
+
+} // namespace blink
+
+#endif // BaseRenderingContext2D_h

Powered by Google App Engine
This is Rietveld 408576698