Modified: trunk/Source/Platform/chromium/public/WebFilterOperation.h (129336 => 129337)
--- trunk/Source/Platform/chromium/public/WebFilterOperation.h 2012-09-24 09:23:20 UTC (rev 129336)
+++ trunk/Source/Platform/chromium/public/WebFilterOperation.h 2012-09-24 09:38:12 UTC (rev 129337)
@@ -55,23 +55,12 @@
float amount() const
{
- WEBKIT_ASSERT(m_type == FilterTypeGrayscale
- || m_type == FilterTypeSepia
- || m_type == FilterTypeSaturate
- || m_type == FilterTypeHueRotate
- || m_type == FilterTypeInvert
- || m_type == FilterTypeBrightness
- || m_type == FilterTypeContrast
- || m_type == FilterTypeOpacity
- || m_type == FilterTypeBlur
- || m_type == FilterTypeDropShadow
- || m_type == FilterTypeZoom);
return m_amount;
}
WebPoint dropShadowOffset() const
{
WEBKIT_ASSERT(m_type == FilterTypeDropShadow);
- return m_dropShadowOffset;
+ return WebPoint(m_dropShadowOffset);
}
WebColor dropShadowColor() const
{
@@ -80,16 +69,16 @@
}
const SkScalar* matrix() const
{
- WEBKIT_ASSERT(m_type == FilterTypeColorMatrix);
return m_matrix;
}
WebRect zoomRect() const
{
WEBKIT_ASSERT(m_type == FilterTypeZoom);
- return m_zoomRect;
+ return WebRect(m_zoomRect);
}
+#define WEBKIT_HAS_NEW_WEBFILTEROPERATION_API 1
static WebFilterOperation createGrayscaleFilter(float amount) { return WebFilterOperation(FilterTypeGrayscale, amount); }
static WebFilterOperation createSepiaFilter(float amount) { return WebFilterOperation(FilterTypeSepia, amount); }
static WebFilterOperation createSaturateFilter(float amount) { return WebFilterOperation(FilterTypeSaturate, amount); }
@@ -105,46 +94,6 @@
bool equals(const WebFilterOperation& other) const;
- // Methods for restoring a WebFilterOperation.
- static WebFilterOperation createEmptyFilter() { return WebFilterOperation(FilterTypeGrayscale, 0.0); }
- void setType(FilterType type) { m_type = type; }
- void setAmount(float amount)
- {
- WEBKIT_ASSERT(m_type == FilterTypeGrayscale
- || m_type == FilterTypeSepia
- || m_type == FilterTypeSaturate
- || m_type == FilterTypeHueRotate
- || m_type == FilterTypeInvert
- || m_type == FilterTypeBrightness
- || m_type == FilterTypeContrast
- || m_type == FilterTypeOpacity
- || m_type == FilterTypeBlur
- || m_type == FilterTypeDropShadow
- || m_type == FilterTypeZoom);
- m_amount = amount;
- }
- void setDropShadowOffset(WebPoint offset)
- {
- WEBKIT_ASSERT(m_type == FilterTypeDropShadow);
- m_dropShadowOffset = offset;
- }
- void setDropShadowColor(WebColor color)
- {
- WEBKIT_ASSERT(m_type == FilterTypeDropShadow);
- m_dropShadowColor = color;
- }
- void setMatrix(const SkScalar matrix[20])
- {
- WEBKIT_ASSERT(m_type == FilterTypeColorMatrix);
- for (unsigned i = 0; i < 20; ++i)
- m_matrix[i] = matrix[i];
- }
- void setZoomRect(WebRect rect)
- {
- WEBKIT_ASSERT(m_type == FilterTypeZoom);
- m_zoomRect = rect;
- }
-
private:
FilterType m_type;
Modified: trunk/Source/WebKit/chromium/tests/FilterOperationsTest.cpp (129336 => 129337)
--- trunk/Source/WebKit/chromium/tests/FilterOperationsTest.cpp 2012-09-24 09:23:20 UTC (rev 129336)
+++ trunk/Source/WebKit/chromium/tests/FilterOperationsTest.cpp 2012-09-24 09:38:12 UTC (rev 129337)
@@ -89,108 +89,5 @@
EXPECT_EQ(54, left);
}
-#define SAVE_RESTORE_AMOUNT(Type, a) \
- { \
- WebFilterOperation op = WebFilterOperation::create##Type##Filter(a); \
- EXPECT_EQ(WebFilterOperation::FilterType##Type, op.type()); \
- EXPECT_EQ(a, op.amount()); \
- \
- WebFilterOperation op2 = WebFilterOperation::createEmptyFilter(); \
- op2.setType(WebFilterOperation::FilterType##Type); \
- \
- EXPECT_NE(a, op2.amount()); \
- \
- op2.setAmount(a); \
- \
- EXPECT_EQ(WebFilterOperation::FilterType##Type, op2.type()); \
- EXPECT_EQ(a, op2.amount()); \
- }
-
-#define SAVE_RESTORE_OFFSET_AMOUNT_COLOR(Type, a, b, c) \
- { \
- WebFilterOperation op = WebFilterOperation::create##Type##Filter(a, b, c); \
- EXPECT_EQ(WebFilterOperation::FilterType##Type, op.type()); \
- EXPECT_EQ(a, op.dropShadowOffset()); \
- EXPECT_EQ(b, op.amount()); \
- EXPECT_EQ(c, op.dropShadowColor()); \
- \
- WebFilterOperation op2 = WebFilterOperation::createEmptyFilter(); \
- op2.setType(WebFilterOperation::FilterType##Type); \
- \
- EXPECT_NE(a, op2.dropShadowOffset()); \
- EXPECT_NE(b, op2.amount()); \
- EXPECT_NE(c, op2.dropShadowColor()); \
- \
- op2.setDropShadowOffset(a); \
- op2.setAmount(b); \
- op2.setDropShadowColor(c); \
- \
- EXPECT_EQ(WebFilterOperation::FilterType##Type, op2.type()); \
- EXPECT_EQ(a, op2.dropShadowOffset()); \
- EXPECT_EQ(b, op2.amount()); \
- EXPECT_EQ(c, op2.dropShadowColor()); \
- }
-
-#define SAVE_RESTORE_MATRIX(Type, a) \
- { \
- WebFilterOperation op = WebFilterOperation::create##Type##Filter(a); \
- EXPECT_EQ(WebFilterOperation::FilterType##Type, op.type()); \
- for (unsigned i = 0; i < 20; ++i) \
- EXPECT_EQ(a[i], op.matrix()[i]); \
- \
- WebFilterOperation op2 = WebFilterOperation::createEmptyFilter(); \
- op2.setType(WebFilterOperation::FilterType##Type); \
- \
- for (unsigned i = 0; i < 20; ++i) \
- EXPECT_NE(a[i], op2.matrix()[i]); \
- \
- op2.setMatrix(a); \
- \
- EXPECT_EQ(WebFilterOperation::FilterType##Type, op2.type()); \
- for (unsigned i = 0; i < 20; ++i) \
- EXPECT_EQ(a[i], op.matrix()[i]); \
- }
-
-#define SAVE_RESTORE_ZOOMRECT_AMOUNT(Type, a, b) \
- { \
- WebFilterOperation op = WebFilterOperation::create##Type##Filter(a, b); \
- EXPECT_EQ(WebFilterOperation::FilterType##Type, op.type()); \
- EXPECT_EQ(a, op.zoomRect()); \
- EXPECT_EQ(b, op.amount()); \
- \
- WebFilterOperation op2 = WebFilterOperation::createEmptyFilter(); \
- op2.setType(WebFilterOperation::FilterType##Type); \
- \
- EXPECT_NE(a, op2.zoomRect()); \
- EXPECT_NE(b, op2.amount()); \
- \
- op2.setZoomRect(a); \
- op2.setAmount(b); \
- \
- EXPECT_EQ(WebFilterOperation::FilterType##Type, op2.type()); \
- EXPECT_EQ(a, op2.zoomRect()); \
- EXPECT_EQ(b, op2.amount()); \
- }
-
-
-TEST(WebFilterOperationsTest, saveAndRestore)
-{
- SAVE_RESTORE_AMOUNT(Grayscale, 0.6f);
- SAVE_RESTORE_AMOUNT(Sepia, 0.6f);
- SAVE_RESTORE_AMOUNT(Saturate, 0.6f);
- SAVE_RESTORE_AMOUNT(HueRotate, 0.6f);
- SAVE_RESTORE_AMOUNT(Invert, 0.6f);
- SAVE_RESTORE_AMOUNT(Brightness, 0.6f);
- SAVE_RESTORE_AMOUNT(Contrast, 0.6f);
- SAVE_RESTORE_AMOUNT(Opacity, 0.6f);
- SAVE_RESTORE_AMOUNT(Blur, 0.6f);
- SAVE_RESTORE_OFFSET_AMOUNT_COLOR(DropShadow, WebPoint(3, 4), 0.4f, 0xffffff00);
-
- SkScalar matrix[20] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 };
- SAVE_RESTORE_MATRIX(ColorMatrix, matrix);
-
- SAVE_RESTORE_ZOOMRECT_AMOUNT(Zoom, WebRect(20, 19, 18, 17), 32);
}
-}
-