- Revision
- 106274
- Author
- [email protected]
- Date
- 2012-01-30 12:01:39 -0800 (Mon, 30 Jan 2012)
Log Message
[Windows] Optionally invert colors when drawing to a WebView's backing store.
https://bugs.webkit.org/show_bug.cgi?id=77168
Reviewed by Sam Weinig.
Source/WebCore:
* css/CSSPrimitiveValueMappings.h: Assert that CompositeDifference is
not converted to a CSS value. Exposing a new compositing operation to
CSS is outside the scope of this patch.
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
* platform/graphics/GraphicsTypes.h: Add CompositeDifference as a
CompositeOperator. Also, remove an outdated comment.
* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContext::setPlatformCompositeOperation): Map
CompositeDifference to kCGBlendModeDifference.
Source/WebKit/win:
* WebView.cpp:
(WebView::WebView): Initialize m_shouldInvertColors to false.
(WebView::paintIntoBackingStore): If m_shouldInvertColors is true, draw
an opaque white quad using the CompositeDifference blend mode. This
blend operation instructs CoreGraphics to take the difference between
the source pixel (white) and the background pixel, resulting in an
inverted pixel.
* WebView.h: Define m_shouldInvertColors.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (106273 => 106274)
--- trunk/Source/WebCore/ChangeLog 2012-01-30 19:50:48 UTC (rev 106273)
+++ trunk/Source/WebCore/ChangeLog 2012-01-30 20:01:39 UTC (rev 106274)
@@ -1,3 +1,20 @@
+2012-01-26 Andy Estes <[email protected]>
+
+ [Windows] Optionally invert colors when drawing to a WebView's backing store.
+ https://bugs.webkit.org/show_bug.cgi?id=77168
+
+ Reviewed by Sam Weinig.
+
+ * css/CSSPrimitiveValueMappings.h: Assert that CompositeDifference is
+ not converted to a CSS value. Exposing a new compositing operation to
+ CSS is outside the scope of this patch.
+ (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+ * platform/graphics/GraphicsTypes.h: Add CompositeDifference as a
+ CompositeOperator. Also, remove an outdated comment.
+ * platform/graphics/cg/GraphicsContextCG.cpp:
+ (WebCore::GraphicsContext::setPlatformCompositeOperation): Map
+ CompositeDifference to kCGBlendModeDifference.
+
2012-01-28 Matthew Delaney <[email protected]>
Limit the shadow offset CG hack to just SL and Lion
Modified: trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h (106273 => 106274)
--- trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h 2012-01-30 19:50:48 UTC (rev 106273)
+++ trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h 2012-01-30 20:01:39 UTC (rev 106274)
@@ -285,6 +285,9 @@
case CompositePlusLighter:
m_value.ident = CSSValuePlusLighter;
break;
+ case CompositeDifference:
+ ASSERT_NOT_REACHED();
+ break;
}
}
Modified: trunk/Source/WebCore/platform/graphics/GraphicsTypes.h (106273 => 106274)
--- trunk/Source/WebCore/platform/graphics/GraphicsTypes.h 2012-01-30 19:50:48 UTC (rev 106273)
+++ trunk/Source/WebCore/platform/graphics/GraphicsTypes.h 2012-01-30 20:01:39 UTC (rev 106274)
@@ -30,9 +30,6 @@
namespace WebCore {
- // Note: These constants exactly match the NSCompositeOperator constants of
- // AppKit on Mac OS X Tiger. If these ever change, we'll need to change the
- // Mac OS X Tiger platform code to map one to the other.
enum CompositeOperator {
CompositeClear,
CompositeCopy,
@@ -46,7 +43,8 @@
CompositeDestinationAtop,
CompositeXOR,
CompositePlusDarker,
- CompositePlusLighter
+ CompositePlusLighter,
+ CompositeDifference
};
enum GradientSpreadMethod {
Modified: trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp (106273 => 106274)
--- trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp 2012-01-30 19:50:48 UTC (rev 106273)
+++ trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp 2012-01-30 20:01:39 UTC (rev 106274)
@@ -1603,6 +1603,9 @@
case CompositePlusLighter:
target = kCGBlendModePlusLighter;
break;
+ case CompositeDifference:
+ target = kCGBlendModeDifference;
+ break;
}
CGContextSetBlendMode(platformContext(), target);
}
Modified: trunk/Source/WebKit/win/ChangeLog (106273 => 106274)
--- trunk/Source/WebKit/win/ChangeLog 2012-01-30 19:50:48 UTC (rev 106273)
+++ trunk/Source/WebKit/win/ChangeLog 2012-01-30 20:01:39 UTC (rev 106274)
@@ -1,3 +1,19 @@
+2012-01-26 Andy Estes <[email protected]>
+
+ [Windows] Optionally invert colors when drawing to a WebView's backing store.
+ https://bugs.webkit.org/show_bug.cgi?id=77168
+
+ Reviewed by Sam Weinig.
+
+ * WebView.cpp:
+ (WebView::WebView): Initialize m_shouldInvertColors to false.
+ (WebView::paintIntoBackingStore): If m_shouldInvertColors is true, draw
+ an opaque white quad using the CompositeDifference blend mode. This
+ blend operation instructs CoreGraphics to take the difference between
+ the source pixel (white) and the background pixel, resulting in an
+ inverted pixel.
+ * WebView.h: Define m_shouldInvertColors.
+
2012-01-23 Simon Fraser <[email protected]>
Show layer borders for scrollbar layers
Modified: trunk/Source/WebKit/win/WebView.cpp (106273 => 106274)
--- trunk/Source/WebKit/win/WebView.cpp 2012-01-30 19:50:48 UTC (rev 106273)
+++ trunk/Source/WebKit/win/WebView.cpp 2012-01-30 20:01:39 UTC (rev 106274)
@@ -332,6 +332,7 @@
WebView::WebView()
: m_refCount(0)
+ , m_shouldInvertColors(false)
#if !ASSERT_DISABLED
, m_deletionHasBegun(false)
#endif
@@ -1154,6 +1155,8 @@
if (frameView && frameView->frame() && frameView->frame()->contentRenderer()) {
gc.clip(dirtyRect);
frameView->paint(&gc, dirtyRect);
+ if (m_shouldInvertColors)
+ gc.fillRect(dirtyRect, Color::white, ColorSpaceDeviceRGB, CompositeDifference);
}
gc.restore();
}
Modified: trunk/Source/WebKit/win/WebView.h (106273 => 106274)
--- trunk/Source/WebKit/win/WebView.h 2012-01-30 19:50:48 UTC (rev 106273)
+++ trunk/Source/WebKit/win/WebView.h 2012-01-30 20:01:39 UTC (rev 106274)
@@ -1001,6 +1001,8 @@
virtual void flushPendingGraphicsLayerChanges();
#endif
+ bool m_shouldInvertColors;
+
protected:
static bool registerWebViewWindowClass();
static LRESULT CALLBACK WebViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);