Diff
Modified: trunk/LayoutTests/ChangeLog (136336 => 136337)
--- trunk/LayoutTests/ChangeLog 2012-12-02 12:11:00 UTC (rev 136336)
+++ trunk/LayoutTests/ChangeLog 2012-12-02 12:22:29 UTC (rev 136337)
@@ -1,3 +1,15 @@
+2012-12-02 Rik Cabanier <[email protected]>
+
+ Extend _javascript_ support for blending in canvas
+ https://bugs.webkit.org/show_bug.cgi?id=101804
+
+ Reviewed by Dirk Schulze.
+
+ Added a test that checks that all blendingmodes are supported
+
+ * canvas/philip/tests/2d.composite.globalComposite-expected.txt: Added.
+ * canvas/philip/tests/2d.composite.globalComposite.html: Added.
+
2012-12-02 Kent Tamura <[email protected]>
[Chromium] fast/forms/*-multiple-fields/*-multiple-fields-preserve-value-after-history-back.html is flaky
Added: trunk/LayoutTests/canvas/philip/tests/2d.composite.globalComposite-expected.txt (0 => 136337)
--- trunk/LayoutTests/canvas/philip/tests/2d.composite.globalComposite-expected.txt (rev 0)
+++ trunk/LayoutTests/canvas/philip/tests/2d.composite.globalComposite-expected.txt 2012-12-02 12:22:29 UTC (rev 136337)
@@ -0,0 +1,33 @@
+Test canvas globalCompositeOperator
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+PASS ctx.globalCompositeOperation is "clear"
+PASS ctx.globalCompositeOperation is "copy"
+PASS ctx.globalCompositeOperation is "source-over"
+PASS ctx.globalCompositeOperation is "destination-over"
+PASS ctx.globalCompositeOperation is "source-in"
+PASS ctx.globalCompositeOperation is "destination-in"
+PASS ctx.globalCompositeOperation is "source-out"
+PASS ctx.globalCompositeOperation is "destination-out"
+PASS ctx.globalCompositeOperation is "source-atop"
+PASS ctx.globalCompositeOperation is "destination-atop"
+PASS ctx.globalCompositeOperation is "xor"
+PASS ctx.globalCompositeOperation is "lighter"
+PASS ctx.globalCompositeOperation is "multiply"
+PASS ctx.globalCompositeOperation is "screen"
+PASS ctx.globalCompositeOperation is "overlay"
+PASS ctx.globalCompositeOperation is "darken"
+PASS ctx.globalCompositeOperation is "lighten"
+PASS ctx.globalCompositeOperation is "color-dodge"
+PASS ctx.globalCompositeOperation is "color-burn"
+PASS ctx.globalCompositeOperation is "hard-light"
+PASS ctx.globalCompositeOperation is "soft-light"
+PASS ctx.globalCompositeOperation is "difference"
+PASS ctx.globalCompositeOperation is "exclusion"
+PASS ctx.globalCompositeOperation is "hue"
+PASS ctx.globalCompositeOperation is "saturation"
+PASS ctx.globalCompositeOperation is "color"
+PASS ctx.globalCompositeOperation is "luminosity"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/canvas/philip/tests/2d.composite.globalComposite.html (0 => 136337)
--- trunk/LayoutTests/canvas/philip/tests/2d.composite.globalComposite.html (rev 0)
+++ trunk/LayoutTests/canvas/philip/tests/2d.composite.globalComposite.html 2012-12-02 12:22:29 UTC (rev 136337)
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<title>Canvas test: 2d.composite.globalAlpha.range</title>
+<script src=""
+<link rel="stylesheet" href=""
+<body>
+<p id="passtext">Pass</p>
+<p id="failtext">Fail</p>
+<p class="output">These images should be identical:</p>
+<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
+
+<ul id="d"></ul>
+<script>
+ description('Test canvas globalCompositeOperator');
+ var compModes = [ "clear", "copy", "source-over", "destination-over", "source-in", "destination-in", "source-out", "destination-out", "source-atop", "destination-atop", "xor", "lighter", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"];
+ ctx = document.getElementById("c").getContext("2d");
+ for (var i = 0; i < compModes.length; i++) {
+ ctx.globalCompositeOperation = compModes[i];
+ shouldBeEqualToString("ctx.globalCompositeOperation", compModes[i]);
+ }
+</script>
+<script src=""
Modified: trunk/Source/WebCore/ChangeLog (136336 => 136337)
--- trunk/Source/WebCore/ChangeLog 2012-12-02 12:11:00 UTC (rev 136336)
+++ trunk/Source/WebCore/ChangeLog 2012-12-02 12:22:29 UTC (rev 136337)
@@ -1,3 +1,31 @@
+2012-12-02 Rik Cabanier <[email protected]>
+
+ Extend _javascript_ support for blending in canvas
+ https://bugs.webkit.org/show_bug.cgi?id=101804
+
+ Reviewed by Dirk Schulze.
+
+ Added parsing code and variables to support additional canvas blend modes
+ see spec: https://dvcs.w3.org/hg/FXTF/rawfile/tip/compositing/index.html#canvascompositingandblending
+
+ Test: canvas/philip/tests/2d.composite.globalComposite.html
+
+ * html/HTMLImageElement.cpp:
+ (WebCore::HTMLImageElement::parseAttribute):
+ * html/canvas/CanvasRenderingContext2D.cpp:
+ (WebCore::CanvasRenderingContext2D::State::State):
+ (WebCore::CanvasRenderingContext2D::State::operator=):
+ (WebCore::CanvasRenderingContext2D::globalCompositeOperation):
+ (WebCore::CanvasRenderingContext2D::setGlobalCompositeOperation):
+ (WebCore::CanvasRenderingContext2D::drawImageFromRect):
+ * html/canvas/CanvasRenderingContext2D.h:
+ (State):
+ * platform/graphics/GraphicsTypes.cpp:
+ (WebCore):
+ (WebCore::parseCompositeAndBlendOperator):
+ (WebCore::compositeOperatorName):
+ * platform/graphics/GraphicsTypes.h:
+
2012-12-02 KyungTae Kim <[email protected]>
[EFL] Fix build warning in GraphicsContext3DEfl.cpp
Modified: trunk/Source/WebCore/html/HTMLImageElement.cpp (136336 => 136337)
--- trunk/Source/WebCore/html/HTMLImageElement.cpp 2012-12-02 12:11:00 UTC (rev 136336)
+++ trunk/Source/WebCore/html/HTMLImageElement.cpp 2012-12-02 12:22:29 UTC (rev 136337)
@@ -176,7 +176,9 @@
else if (name == onbeforeloadAttr)
setAttributeEventListener(eventNames().beforeloadEvent, createAttributeEventListener(this, name, value));
else if (name == compositeAttr) {
- if (!parseCompositeOperator(value, m_compositeOperator))
+ // FIXME: images don't support blend modes in their compositing attribute.
+ BlendMode blendOp = BlendModeNormal;
+ if (!parseCompositeAndBlendOperator(value, m_compositeOperator, blendOp))
m_compositeOperator = CompositeSourceOver;
} else
HTMLElement::parseAttribute(name, value);
Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (136336 => 136337)
--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp 2012-12-02 12:11:00 UTC (rev 136336)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp 2012-12-02 12:22:29 UTC (rev 136337)
@@ -182,6 +182,7 @@
, m_shadowColor(Color::transparent)
, m_globalAlpha(1)
, m_globalComposite(CompositeSourceOver)
+ , m_globalBlend(BlendModeNormal)
, m_invertibleCTM(true)
, m_lineDashOffset(0)
, m_imageSmoothingEnabled(true)
@@ -207,6 +208,7 @@
, m_shadowColor(other.m_shadowColor)
, m_globalAlpha(other.m_globalAlpha)
, m_globalComposite(other.m_globalComposite)
+ , m_globalBlend(other.m_globalBlend)
, m_transform(other.m_transform)
, m_invertibleCTM(other.m_invertibleCTM)
, m_lineDashOffset(other.m_lineDashOffset)
@@ -242,6 +244,7 @@
m_shadowColor = other.m_shadowColor;
m_globalAlpha = other.m_globalAlpha;
m_globalComposite = other.m_globalComposite;
+ m_globalBlend = other.m_globalBlend;
m_transform = other.m_transform;
m_invertibleCTM = other.m_invertibleCTM;
m_imageSmoothingEnabled = other.m_imageSmoothingEnabled;
@@ -605,18 +608,20 @@
String CanvasRenderingContext2D::globalCompositeOperation() const
{
- return compositeOperatorName(state().m_globalComposite);
+ return compositeOperatorName(state().m_globalComposite, state().m_globalBlend);
}
void CanvasRenderingContext2D::setGlobalCompositeOperation(const String& operation)
{
- CompositeOperator op;
- if (!parseCompositeOperator(operation, op))
+ CompositeOperator op = CompositeSourceOver;
+ BlendMode blendOp = BlendModeNormal;
+ if (!parseCompositeAndBlendOperator(operation, op, blendOp))
return;
- if (state().m_globalComposite == op)
+ if ((state().m_globalComposite == op) && (state().m_globalBlend == blendOp))
return;
realizeSaves();
modifiableState().m_globalComposite = op;
+ modifiableState().m_globalBlend = blendOp;
GraphicsContext* c = drawingContext();
if (!c)
return;
@@ -1553,7 +1558,8 @@
const String& compositeOperation)
{
CompositeOperator op;
- if (!parseCompositeOperator(compositeOperation, op))
+ BlendMode blendOp = BlendModeNormal;
+ if (!parseCompositeAndBlendOperator(compositeOperation, op, blendOp) || blendOp != BlendModeNormal)
op = CompositeSourceOver;
ExceptionCode ec;
Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h (136336 => 136337)
--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h 2012-12-02 12:11:00 UTC (rev 136336)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h 2012-12-02 12:22:29 UTC (rev 136337)
@@ -251,6 +251,7 @@
RGBA32 m_shadowColor;
float m_globalAlpha;
CompositeOperator m_globalComposite;
+ BlendMode m_globalBlend;
AffineTransform m_transform;
bool m_invertibleCTM;
Vector<float> m_lineDash;
Modified: trunk/Source/WebCore/platform/graphics/GraphicsTypes.cpp (136336 => 136337)
--- trunk/Source/WebCore/platform/graphics/GraphicsTypes.cpp 2012-12-02 12:11:00 UTC (rev 136336)
+++ trunk/Source/WebCore/platform/graphics/GraphicsTypes.cpp 2012-12-02 12:22:29 UTC (rev 136337)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2012 Rik Cabanier ([email protected])
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -46,22 +47,59 @@
"darker",
"lighter"
};
+
+static const char* const blendOperatorNames[] = {
+ "multiply",
+ "screen",
+ "overlay",
+ "darken",
+ "lighten",
+ "color-dodge",
+ "color-burn",
+ "hard-light",
+ "soft-light",
+ "difference",
+ "exclusion",
+ "hue",
+ "saturation",
+ "color",
+ "luminosity"
+};
const int numCompositeOperatorNames = WTF_ARRAY_LENGTH(compositeOperatorNames);
+const int numBlendOperatorNames = WTF_ARRAY_LENGTH(blendOperatorNames);
-bool parseCompositeOperator(const String& s, CompositeOperator& op)
+bool parseCompositeAndBlendOperator(const String& s, CompositeOperator& op, BlendMode& blendOp)
{
- for (int i = 0; i < numCompositeOperatorNames; i++)
+ for (int i = 0; i < numCompositeOperatorNames; i++) {
if (s == compositeOperatorNames[i]) {
op = static_cast<CompositeOperator>(i);
+ blendOp = BlendModeNormal;
return true;
}
+ }
+
+ for (int i = 0; i < numBlendOperatorNames; i++) {
+ if (s == blendOperatorNames[i]) {
+ blendOp = static_cast<BlendMode>(i+1);
+ // For now, blending will always assume source-over. This will be fixed in the future
+ op = CompositeSourceOver;
+ return true;
+ }
+ }
+
return false;
}
-String compositeOperatorName(CompositeOperator op)
+// FIXME: when we support blend modes in combination with compositing other than source-over
+// this routine needs to be updated.
+String compositeOperatorName(CompositeOperator op, BlendMode blendOp)
{
ASSERT(op >= 0);
ASSERT(op < numCompositeOperatorNames);
+ ASSERT(blendOp >= 0);
+ ASSERT(blendOp <= numBlendOperatorNames);
+ if (blendOp != BlendModeNormal)
+ return blendOperatorNames[blendOp-1];
return compositeOperatorNames[op];
}
Modified: trunk/Source/WebCore/platform/graphics/GraphicsTypes.h (136336 => 136337)
--- trunk/Source/WebCore/platform/graphics/GraphicsTypes.h 2012-12-02 12:11:00 UTC (rev 136336)
+++ trunk/Source/WebCore/platform/graphics/GraphicsTypes.h 2012-12-02 12:22:29 UTC (rev 136337)
@@ -82,8 +82,8 @@
enum TextAlign { StartTextAlign, EndTextAlign, LeftTextAlign, CenterTextAlign, RightTextAlign };
- String compositeOperatorName(CompositeOperator);
- bool parseCompositeOperator(const String&, CompositeOperator&);
+ String compositeOperatorName(CompositeOperator, BlendMode);
+ bool parseCompositeAndBlendOperator(const String&, CompositeOperator&, BlendMode&);
String lineCapName(LineCap);
bool parseLineCap(const String&, LineCap&);