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

Unified Diff: ui/compositor/layer_unittest.cc

Issue 499503002: Respect window transparency when applying window shape. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Re-add AeroGlass checks for Windows Created 6 years, 4 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
« no previous file with comments | « ui/compositor/layer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/compositor/layer_unittest.cc
diff --git a/ui/compositor/layer_unittest.cc b/ui/compositor/layer_unittest.cc
index e44f0e4908db73e92cd666d8c0908fcd1e7f2878..c59163166c8e60a335d3166e85d02c3556ad9154 100644
--- a/ui/compositor/layer_unittest.cc
+++ b/ui/compositor/layer_unittest.cc
@@ -36,6 +36,10 @@
#include "ui/gfx/gfx_paths.h"
#include "ui/gfx/skia_util.h"
+#if defined(OS_WIN)
+#include "ui/base/win/shell.h"
+#endif
+
using cc::MatchesPNGFile;
namespace ui {
@@ -885,6 +889,77 @@ TEST_F(LayerWithRealCompositorTest, DrawPixels) {
}
}
+// Checks that using the AlphaShape filter applied to a layer with
+// transparency, alpha-blends properly with the layer below.
+TEST_F(LayerWithRealCompositorTest, DrawAlphaThresholdFilterPixels) {
+ gfx::Size viewport_size = GetCompositor()->size();
+
+ int test_size = 200;
+ EXPECT_GE(viewport_size.width(), test_size);
+ EXPECT_GE(viewport_size.height(), test_size);
+
+ int blue_height = 10;
+ // Blue with a wee bit of transparency.
+ SkColor bluish = SkColorSetARGBInline(40, 0, 0, 255);
Wez 2014/08/26 01:53:39 nit: translucent_blue?
+
+ bool alpha_blend = false;
Wez 2014/08/26 01:53:39 expect_alpha_blend?
garykac 2014/09/02 19:27:06 Done.
+#if defined(USE_AURA) && !defined(OS_CHROMEOS)
+ alpha_blend = true;
+#if defined(OS_WIN)
+ if (!ui::win::IsAeroGlassEnabled()) {
Wez 2014/08/26 01:53:39 Do we need a similar test for Linux Aura, since we
+ alpha_blend = false;
+ }
+#endif // OS_WIN
+#endif // USE_AURA && !OS_CHROMEOS
+
+ SkColor blue_over_red;
+ if (alpha_blend) {
+ // Transparent blue blended with red.
+ blue_over_red = SkColorSetARGBInline(255, 143, 143, 183);
+ } else {
+ // Transparent blue overwriting lower layer.
Wez 2014/08/26 01:53:38 This is confusingly worded.
+ blue_over_red = SkColorSetARGBInline(255, 0, 0, 40);
+ }
+
+ scoped_ptr<Layer> layer(
Wez 2014/08/26 01:53:39 layer1, or background_layer
garykac 2014/09/02 19:27:07 Done.
+ CreateColorLayer(SK_ColorRED, gfx::Rect(viewport_size)));
+ scoped_ptr<Layer> layer2(
Wez 2014/08/26 01:53:38 or blue_layer or foreground_layer
garykac 2014/09/02 19:27:06 Done.
+ CreateColorLayer(bluish, gfx::Rect(viewport_size)));
+
+ SkRegion shape;
+ shape.setRect(0, 0, viewport_size.width(), blue_height);
+ layer2->SetAlphaShape(make_scoped_ptr(new SkRegion(shape)));
+
+ layer->Add(layer2.get());
+
+ DrawTree(layer.get());
+
+ SkBitmap bitmap;
+ ASSERT_TRUE(ReadPixels(&bitmap, gfx::Rect(viewport_size)));
+ ASSERT_FALSE(bitmap.empty());
+
+ SkAutoLockPixels lock(bitmap);
+ // Ignore the edge pixels since the blending can vary on some platforms.
Wez 2014/08/26 01:53:39 This only seems to ignore the top-most and left-mo
garykac 2014/09/02 19:27:06 The test size is much smaller than the window, so
+ for (int x = 1; x < test_size; x++) {
+ for (int y = 1; y < test_size; y++) {
+ SkColor actual_color = bitmap.getColor(x, y);
+ SkColor expected_color = y < blue_height ? blue_over_red : SK_ColorRED;
+ EXPECT_EQ(expected_color, actual_color)
+ << "Pixel error at x=" << x << " y=" << y << "; "
+ << "actual RGBA=("
+ << SkColorGetR(actual_color) << ","
+ << SkColorGetG(actual_color) << ","
+ << SkColorGetB(actual_color) << ","
+ << SkColorGetA(actual_color) << "); "
+ << "expected RGBA=("
+ << SkColorGetR(expected_color) << ","
+ << SkColorGetG(expected_color) << ","
+ << SkColorGetB(expected_color) << ","
+ << SkColorGetA(expected_color) << ")";
+ }
+ }
+}
+
// Checks the logic around Compositor::SetRootLayer and Layer::SetCompositor.
TEST_F(LayerWithRealCompositorTest, SetRootLayer) {
Compositor* compositor = GetCompositor();
« no previous file with comments | « ui/compositor/layer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698