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

Unified Diff: Source/platform/graphics/GraphicsContext.h

Issue 1093673002: Removing the dependency on GraphicsContext for drawing images in 2D canvas (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix svg stuff Created 5 years, 7 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: Source/platform/graphics/GraphicsContext.h
diff --git a/Source/platform/graphics/GraphicsContext.h b/Source/platform/graphics/GraphicsContext.h
index 6e8807ae9c0c3c74d4eae749426efcc65c944e75..b114e1d025c8e98cbda5c403e79de30a11c59fb4 100644
--- a/Source/platform/graphics/GraphicsContext.h
+++ b/Source/platform/graphics/GraphicsContext.h
@@ -109,7 +109,6 @@ public:
Color strokeColor() const { return immutableState()->strokeColor(); }
void setStrokeColor(const Color& color) { mutableState()->setStrokeColor(color); }
- SkColor effectiveStrokeColor() const { return immutableState()->effectiveStrokeColor(); }
Pattern* strokePattern() const { return immutableState()->strokePattern(); }
void setStrokePattern(PassRefPtr<Pattern>, float alpha = 1);
@@ -138,33 +137,12 @@ public:
void setShouldAntialias(bool antialias) { mutableState()->setShouldAntialias(antialias); }
bool shouldAntialias() const { return immutableState()->shouldAntialias(); }
- // Disable the anti-aliasing optimization for scales/multiple-of-90-degrees
- // rotations of thin ("hairline") images.
- // Note: This will only be reliable when the device pixel scale/ratio is
- // fixed (e.g. when drawing to context backed by an ImageBuffer).
- void disableAntialiasingOptimizationForHairlineImages() { ASSERT(!isRecording()); m_antialiasHairlineImages = true; }
- bool shouldAntialiasHairlineImages() const { return m_antialiasHairlineImages; }
-
- void setShouldClampToSourceRect(bool clampToSourceRect) { mutableState()->setShouldClampToSourceRect(clampToSourceRect); }
- bool shouldClampToSourceRect() const { return immutableState()->shouldClampToSourceRect(); }
-
void setTextDrawingMode(TextDrawingModeFlags mode) { mutableState()->setTextDrawingMode(mode); }
TextDrawingModeFlags textDrawingMode() const { return immutableState()->textDrawingMode(); }
- void setAlphaAsFloat(float alpha) { mutableState()->setAlphaAsFloat(alpha);}
- int getNormalizedAlpha() const
- {
- int alpha = immutableState()->alpha();
- return alpha > 255 ? 255 : alpha;
- }
-
void setImageInterpolationQuality(InterpolationQuality quality) { mutableState()->setInterpolationQuality(quality); }
InterpolationQuality imageInterpolationQuality() const { return immutableState()->interpolationQuality(); }
- // Do not use these methods: they are deprecated/scheduled for removal.
- void setCompositeOperation(SkXfermode::Mode);
- SkXfermode::Mode compositeOperation() const;
-
// Specify the device scale factor which may change the way document markers
// and fonts are rendered.
void setDeviceScaleFactor(float factor) { m_deviceScaleFactor = factor; }
@@ -226,7 +204,6 @@ public:
// These methods write to the canvas.
// Also drawLine(const IntPoint& point1, const IntPoint& point2) and fillRoundedRect
void writePixels(const SkImageInfo&, const void* pixels, size_t rowBytes, int x, int y);
- void drawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkPaint* = 0);
void drawOval(const SkRect&, const SkPaint&);
void drawPath(const SkPath&, const SkPaint&);
void drawRect(const SkRect&, const SkPaint&);
@@ -270,14 +247,11 @@ public:
void setShadow(const FloatSize& offset, float blur, const Color&,
DrawLooperBuilder::ShadowTransformMode = DrawLooperBuilder::ShadowRespectsTransforms,
DrawLooperBuilder::ShadowAlphaMode = DrawLooperBuilder::ShadowRespectsAlpha, ShadowMode = DrawShadowAndForeground);
- void clearShadow() { clearDrawLooper(); clearDropShadowImageFilter(); }
- void setDropShadowImageFilter(PassRefPtr<SkImageFilter>);
// It is assumed that this draw looper is used only for shadows
// (i.e. a draw looper is set if and only if there is a shadow).
// The builder passed into this method will be destroyed.
void setDrawLooper(PassOwnPtr<DrawLooperBuilder>);
- void setDrawLooper(PassRefPtr<SkDrawLooper> looper) { mutableState()->setDrawLooper(looper); }
void clearDrawLooper();
void drawFocusRing(const Vector<IntRect>&, int width, int offset, const Color&);
@@ -293,6 +267,8 @@ public:
typedef unsigned Edges;
void drawInnerShadow(const FloatRoundedRect&, const Color& shadowColor, const IntSize shadowOffset, int shadowBlur, int shadowSpread, Edges clippedEdges = NoEdge);
+ const SkPaint& fillPaint() const { return immutableState()->fillPaint(); }
+
// ---------- Transformation methods -----------------
// Note that the getCTM method returns only the current transform from Blink's perspective,
// which is not the final transform used to place content on screen. It cannot be relied upon
@@ -307,6 +283,8 @@ public:
void translate(float x, float y);
// ---------- End transformation methods -----------------
+ SkFilterQuality computeFilterQuality(Image*, const FloatRect& dest, const FloatRect& src) const;
+
// URL drawing
void setURLForRect(const KURL&, const IntRect&);
void setURLFragmentForRect(const String& name, const IntRect&);
@@ -314,17 +292,6 @@ public:
static void adjustLineToPixelBoundaries(FloatPoint& p1, FloatPoint& p2, float strokeWidth, StrokeStyle);
- // This method can potentially push saves onto the canvas. It returns the initial save count,
- // and should be balanced with a call to context->canvas()->restoreToCount(initialSaveCount).
- WARN_UNUSED_RETURN int preparePaintForDrawRectToRect(
- SkPaint*,
- const SkRect& srcRect,
- const SkRect& destRect,
- SkXfermode::Mode,
- bool isBitmapWithAlpha,
- bool isLazyDecoded = false,
- bool isDataComplete = true) const;
-
static int focusRingOutsetExtent(int offset, int width)
{
return focusRingOutset(offset) + (focusRingWidth(width) + 1) / 2;
@@ -381,9 +348,6 @@ private:
void concat(const SkMatrix&);
void drawRRect(const SkRRect&, const SkPaint&);
- void clearDropShadowImageFilter();
- SkImageFilter* dropShadowImageFilter() const { return immutableState()->dropShadowImageFilter(); }
-
// Apply deferred paint state saves
void realizePaintSave()
{
@@ -443,7 +407,17 @@ private:
unsigned m_accelerated : 1;
unsigned m_printing : 1;
- unsigned m_antialiasHairlineImages : 1;
+};
+
+class GraphicsContextImageFilterQualityHelper : public ImageFilterQualityHelper {
+public:
+ GraphicsContextImageFilterQualityHelper(GraphicsContext* context) : m_context(context) { }
+ SkFilterQuality computeFilterQuality(Image*, const FloatRect& dest, const FloatRect& src) const override;
+ bool shouldClampToSourceRect() const override { return true; }
+ bool shouldDrawAntiAliased(const FloatRect&destRect) const override;
+ virtual ~GraphicsContextImageFilterQualityHelper() { }
+private:
+ GraphicsContext* m_context;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698