Commit b3a47fa2 authored by Kenneth Russell's avatar Kenneth Russell Committed by Commit Bot

Fix premultipliedAlpha:false with OpenGL renderer.

The setting of the CC layer's PremultipliedAlpha flag was (still!)
wrong in the case where the workaround was taking effect.

Added a new test to catch this. Currently Mac-specific; ChromeOS is
the only other platform that could catch it and there aren't any such
machines on the GPU waterfalls.

Bug: 804061
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: Ib71832e48d4880defba01f675806294066eb2e4f
Reviewed-on: https://chromium-review.googlesource.com/887967Reviewed-by: default avatarStéphane Marchesin <marcheu@chromium.org>
Reviewed-by: default avatarKai Ninomiya <kainino@chromium.org>
Commit-Queue: Kenneth Russell <kbr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533030}
parent fcb7a339
...@@ -51,6 +51,39 @@ def CopyPagesWithNewBrowserArgsAndPrefix(pages, browser_args, prefix): ...@@ -51,6 +51,39 @@ def CopyPagesWithNewBrowserArgsAndPrefix(pages, browser_args, prefix):
p.CopyWithNewBrowserArgsAndPrefix(browser_args, prefix) for p in pages] p.CopyWithNewBrowserArgsAndPrefix(browser_args, prefix) for p in pages]
# TODO(kbr): consider refactoring this into pixel_integration_test.py.
SCALE_FACTOR_OVERRIDES = {
"comment": "scale factor overrides",
"scale_factor_overrides": [
{
"device_type": "Nexus 5",
"scale_factor": 1.105
},
{
"device_type": "Nexus 5X",
"scale_factor": 1.105
},
{
"device_type": "Nexus 6",
"scale_factor": 1.47436
},
{
"device_type": "Nexus 6P",
"scale_factor": 1.472
},
{
"device_type": "Nexus 9",
"scale_factor": 1.566
},
{
"comment": "NVIDIA Shield",
"device_type": "sb_na_wf",
"scale_factor": 1.226
}
]
}
def DefaultPages(base_name): def DefaultPages(base_name):
return [ return [
PixelTestPage( PixelTestPage(
...@@ -160,38 +193,7 @@ def DefaultPages(base_name): ...@@ -160,38 +193,7 @@ def DefaultPages(base_name):
test_rect=[0, 0, 150, 150], test_rect=[0, 0, 150, 150],
revision=0, # This is not used. revision=0, # This is not used.
expected_colors=[ expected_colors=[
# TODO(kbr): if this works, then factor it out so it applies SCALE_FACTOR_OVERRIDES,
# to all pixel tests that use programmatic expectations.
{
"comment": "scale factor overrides",
"scale_factor_overrides": [
{
"device_type": "Nexus 5",
"scale_factor": 1.105
},
{
"device_type": "Nexus 5X",
"scale_factor": 1.105
},
{
"device_type": "Nexus 6",
"scale_factor": 1.47436
},
{
"device_type": "Nexus 6P",
"scale_factor": 1.472
},
{
"device_type": "Nexus 9",
"scale_factor": 1.566
},
{
"comment": "NVIDIA Shield",
"device_type": "sb_na_wf",
"scale_factor": 1.226
}
]
},
{ {
'comment': 'brown', 'comment': 'brown',
'location': [1, 1], 'location': [1, 1],
...@@ -211,38 +213,7 @@ def DefaultPages(base_name): ...@@ -211,38 +213,7 @@ def DefaultPages(base_name):
test_rect=[0, 0, 200, 200], test_rect=[0, 0, 200, 200],
revision=0, # This is not used. revision=0, # This is not used.
expected_colors=[ expected_colors=[
# TODO(kbr): if this works, then factor it out so it applies SCALE_FACTOR_OVERRIDES,
# to all pixel tests that use programmatic expectations.
{
"comment": "scale factor overrides",
"scale_factor_overrides": [
{
"device_type": "Nexus 5",
"scale_factor": 1.105
},
{
"device_type": "Nexus 5X",
"scale_factor": 1.105
},
{
"device_type": "Nexus 6",
"scale_factor": 1.47436
},
{
"device_type": "Nexus 6P",
"scale_factor": 1.472
},
{
"device_type": "Nexus 9",
"scale_factor": 1.566
},
{
"comment": "NVIDIA Shield",
"device_type": "sb_na_wf",
"scale_factor": 1.226
}
]
},
{ {
'comment': 'green', 'comment': 'green',
'location': [1, 1], 'location': [1, 1],
...@@ -258,38 +229,7 @@ def DefaultPages(base_name): ...@@ -258,38 +229,7 @@ def DefaultPages(base_name):
test_rect=[0, 0, 200, 200], test_rect=[0, 0, 200, 200],
revision=0, # This is not used. revision=0, # This is not used.
expected_colors=[ expected_colors=[
# TODO(kbr): if this works, then factor it out so it applies SCALE_FACTOR_OVERRIDES,
# to all pixel tests that use programmatic expectations.
{
"comment": "scale factor overrides",
"scale_factor_overrides": [
{
"device_type": "Nexus 5",
"scale_factor": 1.105
},
{
"device_type": "Nexus 5X",
"scale_factor": 1.105
},
{
"device_type": "Nexus 6",
"scale_factor": 1.47436
},
{
"device_type": "Nexus 6P",
"scale_factor": 1.472
},
{
"device_type": "Nexus 9",
"scale_factor": 1.566
},
{
"comment": "NVIDIA Shield",
"device_type": "sb_na_wf",
"scale_factor": 1.226
}
]
},
{ {
'comment': 'green', 'comment': 'green',
'location': [1, 1], 'location': [1, 1],
...@@ -652,6 +592,11 @@ def MacSpecificPages(base_name): ...@@ -652,6 +592,11 @@ def MacSpecificPages(base_name):
non_chromium_image_args = ['--disable-webgl-image-chromium'] non_chromium_image_args = ['--disable-webgl-image-chromium']
# This disables the Core Animation compositor, falling back to the
# old GLRenderer path, but continuing to allocate IOSurfaces for
# WebGL's back buffer.
no_overlays_args = ['--disable-mac-overlays']
return [ return [
# On macOS, test the IOSurface 2D Canvas compositing path. # On macOS, test the IOSurface 2D Canvas compositing path.
PixelTestPage( PixelTestPage(
...@@ -705,7 +650,29 @@ def MacSpecificPages(base_name): ...@@ -705,7 +650,29 @@ def MacSpecificPages(base_name):
test_rect=[0, 0, 300, 300], test_rect=[0, 0, 300, 300],
revision=7, revision=7,
tolerance=10, tolerance=10,
browser_args=['--disable-mac-overlays']), browser_args=no_overlays_args),
# Test WebGL's premultipliedAlpha:false without the CA compositor.
PixelTestPage(
'pixel_webgl_premultiplied_alpha_false.html',
base_name + '_WebGL_PremultipliedAlpha_False_NoOverlays',
test_rect=[0, 0, 150, 150],
revision=0, # This is not used.
browser_args=no_overlays_args,
expected_colors=[
SCALE_FACTOR_OVERRIDES,
{
'comment': 'brown',
'location': [1, 1],
'size': [148, 148],
# This is the color on an NVIDIA based MacBook Pro if the
# sRGB profile's applied correctly.
'color': [102, 77, 0],
# This is the color if it isn't.
# 'color': [101, 76, 12],
'tolerance': 3
},
]),
] ]
def DirectCompositionPages(base_name): def DirectCompositionPages(base_name):
......
...@@ -848,10 +848,17 @@ WebLayer* DrawingBuffer::PlatformLayer() { ...@@ -848,10 +848,17 @@ WebLayer* DrawingBuffer::PlatformLayer() {
layer_->SetOpaque(!want_alpha_channel_); layer_->SetOpaque(!want_alpha_channel_);
layer_->SetBlendBackgroundColor(want_alpha_channel_); layer_->SetBlendBackgroundColor(want_alpha_channel_);
// If premultiplied_alpha_false_texture_ exists, then premultiplied_alpha_ // If premultiplied_alpha_false_texture_ exists, then premultiplied_alpha_
// has already been handled via CopySubTextureCHROMIUM, and does not need // has already been handled via CopySubTextureCHROMIUM -- the alpha channel
// to be handled by the compositor. // has been multiplied into the color channels. In this case, or if
layer_->SetPremultipliedAlpha(premultiplied_alpha_ && // premultiplied_alpha_ is true, then the layer should consider its contents
!premultiplied_alpha_false_texture_); // to be premultiplied.
//
// The only situation where the layer should consider its contents
// un-premultiplied is when premultiplied_alpha_ is false, and
// premultiplied_alpha_false_texture_ does not exist.
DCHECK(!(premultiplied_alpha_ && premultiplied_alpha_false_texture_));
layer_->SetPremultipliedAlpha(premultiplied_alpha_ ||
premultiplied_alpha_false_texture_);
layer_->SetNearestNeighbor(filter_quality_ == kNone_SkFilterQuality); layer_->SetNearestNeighbor(filter_quality_ == kNone_SkFilterQuality);
GraphicsLayer::RegisterContentsLayer(layer_->Layer()); GraphicsLayer::RegisterContentsLayer(layer_->Layer());
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment