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

Unified Diff: third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DTest.cpp

Issue 2708403003: Implement canvas color space IDL format for 2D canvas (Closed)
Patch Set: Addressing GPU pixel test failures Created 3 years, 10 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: third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DTest.cpp
diff --git a/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DTest.cpp b/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DTest.cpp
index fdaa4b3c18d1683b8077f62a7d714680af2ac868..366faffe9ab932657a7535fb052456523e64c57e 100644
--- a/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DTest.cpp
+++ b/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DTest.cpp
@@ -97,6 +97,8 @@ PassRefPtr<Image> FakeImageSource::getSourceImageForCanvas(
//============================================================================
+enum LinearPixelMathState { LinearPixelMathDisabled, LinearPixelMathEnabled };
+
class CanvasRenderingContext2DTest : public ::testing::Test {
protected:
CanvasRenderingContext2DTest();
@@ -119,7 +121,9 @@ class CanvasRenderingContext2DTest : public ::testing::Test {
return canvasElement().buffer()->getGPUMemoryUsage();
}
- void createContext(OpacityMode, String colorSpace = String());
+ void createContext(OpacityMode,
+ String colorSpace = String(),
+ LinearPixelMathState = LinearPixelMathDisabled);
ScriptState* getScriptState() {
return ScriptState::forMainWorld(m_canvasElement->frame());
}
@@ -174,13 +178,20 @@ CanvasRenderingContext2DTest::CanvasRenderingContext2DTest()
m_opaqueBitmap(IntSize(10, 10), OpaqueBitmap),
m_alphaBitmap(IntSize(10, 10), TransparentBitmap) {}
-void CanvasRenderingContext2DTest::createContext(OpacityMode opacityMode,
- String colorSpace) {
+void CanvasRenderingContext2DTest::createContext(
+ OpacityMode opacityMode,
+ String colorSpace,
+ LinearPixelMathState linearPixelMathState) {
String canvasType("2d");
CanvasContextCreationAttributes attributes;
attributes.setAlpha(opacityMode == NonOpaque);
- if (!colorSpace.isEmpty())
+ if (!colorSpace.isEmpty()) {
attributes.setColorSpace(colorSpace);
+ if (linearPixelMathState == LinearPixelMathEnabled) {
+ attributes.setPixelFormat("float16");
+ attributes.setLinearPixelMath(true);
+ }
+ }
m_canvasElement->getCanvasRenderingContext(canvasType, attributes);
}
@@ -1225,7 +1236,7 @@ TEST_F(CanvasRenderingContext2DTest,
ColorBehavior::globalTargetColorSpace();
ColorBehavior::setGlobalTargetColorSpaceForTesting(AdobeRGBColorSpace());
- createContext(NonOpaque, "linear-rgb");
+ createContext(NonOpaque, "srgb", LinearPixelMathEnabled);
ColorBehavior behavior = context2d()->drawImageColorBehavior();
EXPECT_TRUE(behavior.isTransformToTargetColorSpace());
EXPECT_TRUE(gfx::ColorSpace::CreateSCRGBLinear() ==

Powered by Google App Engine
This is Rietveld 408576698