WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-64281-20110711135149.patch (text/plain), 15.25 KB, created by
Mike Reed
on 2011-07-11 10:51:51 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Mike Reed
Created:
2011-07-11 10:51:51 PDT
Size:
15.25 KB
patch
obsolete
>Index: Source/WebCore/ChangeLog >=================================================================== >--- Source/WebCore/ChangeLog (revision 90745) >+++ Source/WebCore/ChangeLog (working copy) >@@ -1,3 +1,39 @@ >+2011-07-11 Mike Reed <reed@google.com> >+ >+ [skia] remove platform helpers for gradients and patterns >+ https://bugs.webkit.org/show_bug.cgi?id=64281 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ No new tests. fixes canvas/philip/tests/2d.gradient.object.update.html >+ >+ Remove (now empty) platform helpers for fill/stroke gradients/patterns. We now pickup the platformGradient >+ and platformPattern fresh when they're needed, so we can see any edits that have occurred to them >+ 2d.gradient.object.update.html sets the fillgradient, and then edits the gradient object. This CL allows >+ us to see that edit. >+ >+ * platform/graphics/GraphicsContext.cpp: >+ (WebCore::GraphicsContext::setStrokePattern): >+ (WebCore::GraphicsContext::setFillPattern): >+ (WebCore::GraphicsContext::setStrokeGradient): >+ (WebCore::GraphicsContext::setFillGradient): >+ * platform/graphics/GraphicsContext.h: >+ * platform/graphics/skia/GraphicsContextSkia.cpp: >+ (WebCore::GraphicsContext::platformInit): >+ * platform/graphics/skia/PlatformContextSkia.cpp: >+ (WebCore::PlatformContextSkia::State::State): >+ (WebCore::PlatformContextSkia::State::~State): >+ (WebCore::PlatformContextSkia::PlatformContextSkia): >+ (WebCore::PlatformContextSkia::drawRect): >+ (WebCore::PlatformContextSkia::setupShader): >+ (WebCore::PlatformContextSkia::setupPaintForFilling): >+ (WebCore::PlatformContextSkia::setupPaintForStroking): >+ (WebCore::PlatformContextSkia::setFillColor): >+ (WebCore::PlatformContextSkia::setStrokeColor): >+ (WebCore::PlatformContextSkia::canAccelerate): >+ * platform/graphics/skia/PlatformContextSkia.h: >+ (WebCore::PlatformContextSkia::setGraphicsContext): >+ > 2011-07-11 Andrey Kosyakov <caseq@chromium.org> > > Reviewed by Pavel Feldman. >Index: Source/WebCore/platform/graphics/GraphicsContext.cpp >=================================================================== >--- Source/WebCore/platform/graphics/GraphicsContext.cpp (revision 90738) >+++ Source/WebCore/platform/graphics/GraphicsContext.cpp (working copy) >@@ -265,7 +265,6 @@ void GraphicsContext::setStrokePattern(P > } > m_state.strokeGradient.clear(); > m_state.strokePattern = pattern; >- setPlatformStrokePattern(m_state.strokePattern.get()); > } > > void GraphicsContext::setFillPattern(PassRefPtr<Pattern> pattern) >@@ -277,7 +276,6 @@ void GraphicsContext::setFillPattern(Pas > } > m_state.fillGradient.clear(); > m_state.fillPattern = pattern; >- setPlatformFillPattern(m_state.fillPattern.get()); > } > > void GraphicsContext::setStrokeGradient(PassRefPtr<Gradient> gradient) >@@ -289,7 +287,6 @@ void GraphicsContext::setStrokeGradient( > } > m_state.strokeGradient = gradient; > m_state.strokePattern.clear(); >- setPlatformStrokeGradient(m_state.strokeGradient.get()); > } > > void GraphicsContext::setFillGradient(PassRefPtr<Gradient> gradient) >@@ -301,7 +298,6 @@ void GraphicsContext::setFillGradient(Pa > } > m_state.fillGradient = gradient; > m_state.fillPattern.clear(); >- setPlatformFillGradient(m_state.fillGradient.get()); > } > > Gradient* GraphicsContext::fillGradient() const >@@ -668,24 +664,6 @@ CompositeOperator GraphicsContext::compo > return m_state.compositeOperator; > } > >-#if !USE(SKIA) >-void GraphicsContext::setPlatformFillGradient(Gradient*) >-{ >-} >- >-void GraphicsContext::setPlatformFillPattern(Pattern*) >-{ >-} >- >-void GraphicsContext::setPlatformStrokeGradient(Gradient*) >-{ >-} >- >-void GraphicsContext::setPlatformStrokePattern(Pattern*) >-{ >-} >-#endif >- > #if !USE(CG) && !USE(SKIA) > // Implement this if you want to go ahead and push the drawing mode into your native context > // immediately. >Index: Source/WebCore/platform/graphics/GraphicsContext.h >=================================================================== >--- Source/WebCore/platform/graphics/GraphicsContext.h (revision 90738) >+++ Source/WebCore/platform/graphics/GraphicsContext.h (working copy) >@@ -535,12 +535,8 @@ namespace WebCore { > void setPlatformStrokeColor(const Color&, ColorSpace); > void setPlatformStrokeStyle(StrokeStyle); > void setPlatformStrokeThickness(float); >- void setPlatformStrokeGradient(Gradient*); >- void setPlatformStrokePattern(Pattern*); > > void setPlatformFillColor(const Color&, ColorSpace); >- void setPlatformFillGradient(Gradient*); >- void setPlatformFillPattern(Pattern*); > > void setPlatformShouldAntialias(bool); > void setPlatformShouldSmoothFonts(bool); >Index: Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp >=================================================================== >--- Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp (revision 90738) >+++ Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp (working copy) >@@ -225,6 +225,9 @@ void addCornerArc(SkPath* path, const Sk > // no painting. > void GraphicsContext::platformInit(PlatformGraphicsContext* gc) > { >+ if (gc) >+ gc->setGraphicsContext(this); >+ > // the caller owns the gc > m_data = gc; > setPaintingDisabled(!gc || !gc->canvas()); >@@ -1046,22 +1049,6 @@ void GraphicsContext::setPlatformFillCol > platformContext()->setFillColor(color.rgb()); > } > >-void GraphicsContext::setPlatformFillGradient(Gradient* gradient) >-{ >- if (paintingDisabled()) >- return; >- >- platformContext()->setFillShader(gradient->platformGradient()); >-} >- >-void GraphicsContext::setPlatformFillPattern(Pattern* pattern) >-{ >- if (paintingDisabled()) >- return; >- >- platformContext()->setFillShader(pattern->platformPattern(getCTM())); >-} >- > void GraphicsContext::setPlatformShadow(const FloatSize& size, > float blurFloat, > const Color& color, >@@ -1171,22 +1158,6 @@ void GraphicsContext::setPlatformStrokeT > platformContext()->setStrokeThickness(thickness); > } > >-void GraphicsContext::setPlatformStrokeGradient(Gradient* gradient) >-{ >- if (paintingDisabled()) >- return; >- >- platformContext()->setStrokeShader(gradient->platformGradient()); >-} >- >-void GraphicsContext::setPlatformStrokePattern(Pattern* pattern) >-{ >- if (paintingDisabled()) >- return; >- >- platformContext()->setStrokeShader(pattern->platformPattern(getCTM())); >-} >- > void GraphicsContext::setPlatformTextDrawingMode(TextDrawingModeFlags mode) > { > if (paintingDisabled()) >Index: Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp >=================================================================== >--- Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp (revision 90738) >+++ Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp (working copy) >@@ -83,12 +83,10 @@ struct PlatformContextSkia::State { > > // Fill. > SkColor m_fillColor; >- SkShader* m_fillShader; > > // Stroke. > StrokeStyle m_strokeStyle; > SkColor m_strokeColor; >- SkShader* m_strokeShader; > float m_strokeThickness; > int m_dashRatio; // Ratio of the length of a dash to its width. > float m_miterLimit; >@@ -129,10 +127,8 @@ PlatformContextSkia::State::State() > , m_useAntialiasing(true) > , m_looper(0) > , m_fillColor(0xFF000000) >- , m_fillShader(0) > , m_strokeStyle(SolidStroke) > , m_strokeColor(Color::black) >- , m_strokeShader(0) > , m_strokeThickness(0) > , m_dashRatio(3) > , m_miterLimit(4) >@@ -151,10 +147,8 @@ PlatformContextSkia::State::State(const > , m_useAntialiasing(other.m_useAntialiasing) > , m_looper(other.m_looper) > , m_fillColor(other.m_fillColor) >- , m_fillShader(other.m_fillShader) > , m_strokeStyle(other.m_strokeStyle) > , m_strokeColor(other.m_strokeColor) >- , m_strokeShader(other.m_strokeShader) > , m_strokeThickness(other.m_strokeThickness) > , m_dashRatio(other.m_dashRatio) > , m_miterLimit(other.m_miterLimit) >@@ -171,16 +165,12 @@ PlatformContextSkia::State::State(const > // Up the ref count of these. SkSafeRef does nothing if its argument is 0. > SkSafeRef(m_looper); > SkSafeRef(m_dash); >- SkSafeRef(m_fillShader); >- SkSafeRef(m_strokeShader); > } > > PlatformContextSkia::State::~State() > { > SkSafeUnref(m_looper); > SkSafeUnref(m_dash); >- SkSafeUnref(m_fillShader); >- SkSafeUnref(m_strokeShader); > } > > // Returns a new State with all of this object's inherited properties copied. >@@ -218,6 +208,9 @@ PlatformContextSkia::PlatformContextSkia > { > m_stateStack.append(State()); > m_state = &m_stateStack.last(); >+ >+ // will be assigned in setGraphicsContext() >+ m_gc = 0; > } > > PlatformContextSkia::~PlatformContextSkia() >@@ -349,14 +342,11 @@ void PlatformContextSkia::drawRect(SkRec > if (m_state->m_strokeStyle != NoStroke > && (m_state->m_strokeColor & 0xFF000000)) { > // We do a fill of four rects to simulate the stroke of a border. >- SkColor oldFillColor = m_state->m_fillColor; >- >- // setFillColor() will set the shader to NULL, so save a ref to it now. >- SkShader* oldFillShader = m_state->m_fillShader; >- SkSafeRef(oldFillShader); >- setFillColor(m_state->m_strokeColor); > paint.reset(); > setupPaintForFilling(&paint); >+ // need to jam in the strokeColor >+ paint.setColor(this->effectiveStrokeColor()); >+ > SkRect topBorder = { rect.fLeft, rect.fTop, rect.fRight, rect.fTop + 1 }; > canvas()->drawRect(topBorder, paint); > SkRect bottomBorder = { rect.fLeft, rect.fBottom - 1, rect.fRight, rect.fBottom }; >@@ -365,9 +355,6 @@ void PlatformContextSkia::drawRect(SkRec > canvas()->drawRect(leftBorder, paint); > SkRect rightBorder = { rect.fRight - 1, rect.fTop + 1, rect.fRight, rect.fBottom - 1 }; > canvas()->drawRect(rightBorder, paint); >- setFillColor(oldFillColor); >- setFillShader(oldFillShader); >- SkSafeUnref(oldFillShader); > } > } > >@@ -385,20 +372,39 @@ void PlatformContextSkia::setupPaintComm > paint->setLooper(m_state->m_looper); > } > >+void PlatformContextSkia::setupShader(SkPaint* paint, Gradient* grad, Pattern* pat, SkColor color) const >+{ >+ SkShader* shader = 0; >+ >+ if (grad) { >+ shader = grad->platformGradient(); >+ color = SK_ColorBLACK; >+ } else if (pat) { >+ shader = pat->platformPattern(m_gc->getCTM()); >+ color = SK_ColorBLACK; >+ } >+ >+ paint->setColor(m_state->applyAlpha(color)); >+ paint->setShader(shader); >+} >+ > void PlatformContextSkia::setupPaintForFilling(SkPaint* paint) const > { > setupPaintCommon(paint); >- paint->setColor(m_state->applyAlpha(m_state->m_fillColor)); >- paint->setShader(m_state->m_fillShader); >+ >+ const GraphicsContextState& state = m_gc->state(); >+ setupShader(paint, state.fillGradient.get(), state.fillPattern.get(), m_state->m_fillColor); > } > > float PlatformContextSkia::setupPaintForStroking(SkPaint* paint, SkRect* rect, int length) const > { > setupPaintCommon(paint); >+ >+ const GraphicsContextState& state = m_gc->state(); >+ setupShader(paint, state.strokeGradient.get(), state.strokePattern.get(), m_state->m_strokeColor); >+ > float width = m_state->m_strokeThickness; > >- paint->setColor(m_state->applyAlpha(m_state->m_strokeColor)); >- paint->setShader(m_state->m_strokeShader); > paint->setStyle(SkPaint::kStroke_Style); > paint->setStrokeWidth(SkFloatToScalar(width)); > paint->setStrokeCap(m_state->m_lineCap); >@@ -476,7 +482,6 @@ void PlatformContextSkia::setXfermodeMod > void PlatformContextSkia::setFillColor(SkColor color) > { > m_state->m_fillColor = color; >- setFillShader(0); > } > > SkDrawLooper* PlatformContextSkia::getDrawLooper() const >@@ -497,7 +502,6 @@ void PlatformContextSkia::setStrokeStyle > void PlatformContextSkia::setStrokeColor(SkColor strokeColor) > { > m_state->m_strokeColor = strokeColor; >- setStrokeShader(0); > } > > float PlatformContextSkia::getStrokeThickness() const >@@ -510,18 +514,6 @@ void PlatformContextSkia::setStrokeThick > m_state->m_strokeThickness = thickness; > } > >-void PlatformContextSkia::setStrokeShader(SkShader* strokeShader) >-{ >- if (strokeShader) >- m_state->m_strokeColor = Color::black; >- >- if (strokeShader != m_state->m_strokeShader) { >- SkSafeUnref(m_state->m_strokeShader); >- m_state->m_strokeShader = strokeShader; >- SkSafeRef(m_state->m_strokeShader); >- } >-} >- > TextDrawingModeFlags PlatformContextSkia::getTextDrawingMode() const > { > return m_state->m_textDrawingMode; >@@ -571,18 +563,6 @@ void PlatformContextSkia::canvasClipPath > m_canvas->clipPath(path); > } > >-void PlatformContextSkia::setFillShader(SkShader* fillShader) >-{ >- if (fillShader) >- m_state->m_fillColor = Color::black; >- >- if (fillShader != m_state->m_fillShader) { >- SkSafeUnref(m_state->m_fillShader); >- m_state->m_fillShader = fillShader; >- SkSafeRef(m_state->m_fillShader); >- } >-} >- > InterpolationQuality PlatformContextSkia::interpolationQuality() const > { > return m_state->m_interpolationQuality; >@@ -696,7 +676,9 @@ void PlatformContextSkia::applyAntiAlias > > bool PlatformContextSkia::canAccelerate() const > { >- return !m_state->m_fillShader; // Can't accelerate with a fill gradient or pattern. >+ // Can't accelerate with a fill gradient or pattern. >+ const GraphicsContextState& state = m_gc->state(); >+ return !state.fillGradient.get() && !state.fillPattern.get(); > } > > bool PlatformContextSkia::canvasClipApplied() const >Index: Source/WebCore/platform/graphics/skia/PlatformContextSkia.h >=================================================================== >--- Source/WebCore/platform/graphics/skia/PlatformContextSkia.h (revision 90738) >+++ Source/WebCore/platform/graphics/skia/PlatformContextSkia.h (working copy) >@@ -81,6 +81,10 @@ public: > PlatformContextSkia(SkCanvas*); > ~PlatformContextSkia(); > >+ // Sets the graphics context associated with this context. >+ // GraphicsContextSkia calls this from its constructor. >+ void setGraphicsContext(const GraphicsContext* gc) { m_gc = gc; } >+ > // Sets the canvas associated with this context. Use when supplying NULL > // to the constructor. > void setCanvas(SkCanvas*); >@@ -126,11 +130,9 @@ public: > void setLineJoin(SkPaint::Join); > void setXfermodeMode(SkXfermode::Mode); > void setFillColor(SkColor); >- void setFillShader(SkShader*); > void setStrokeStyle(StrokeStyle); > void setStrokeColor(SkColor); > void setStrokeThickness(float thickness); >- void setStrokeShader(SkShader*); > void setTextDrawingMode(TextDrawingModeFlags mode); > void setUseAntialiasing(bool enable); > void setDashPathEffect(SkDashPathEffect*); >@@ -210,11 +212,15 @@ private: > void uploadSoftwareToHardware(CompositeOperator) const; > void readbackHardwareToSoftware() const; > >+ // common code between setupPaintFor[Filling,Stroking] >+ void setupShader(SkPaint*, Gradient*, Pattern*, SkColor) const; >+ > // Defines drawing style. > struct State; > > // NULL indicates painting is disabled. Never delete this object. > SkCanvas* m_canvas; >+ const GraphicsContext* m_gc; > > // States stack. Enables local drawing state change with save()/restore() > // calls.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 64281
:
100298
|
100301
|
100302
|
100305
| 100328