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

Side by Side Diff: Source/web/tests/TransparencyWinTest.cpp

Issue 23643003: ImageBuffer-less SVG masking and clipping. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix the Win build. Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/svg/graphics/filters/SVGFEImage.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 // These coordinates are relative to the layer, whish is inset by 1x1 333 // These coordinates are relative to the layer, whish is inset by 1x1
334 // pixels from the top left. So we're actually clearing (2, 2) and 334 // pixels from the top left. So we're actually clearing (2, 2) and
335 // (13,13), which are the extreme corners of the black area (and which 335 // (13,13), which are the extreme corners of the black area (and which
336 // we check below). 336 // we check below).
337 clearTopLayerAlphaPixel(helper.context(), 1, 1); 337 clearTopLayerAlphaPixel(helper.context(), 1, 1);
338 clearTopLayerAlphaPixel(helper.context(), 12, 12); 338 clearTopLayerAlphaPixel(helper.context(), 12, 12);
339 helper.composite(); 339 helper.composite();
340 } 340 }
341 341
342 // Finish the compositing. 342 // Finish the compositing.
343 src->context()->endTransparencyLayer(); 343 src->context()->endLayer();
344 344
345 // Check that we got the right values, it should be like the rectangle was 345 // Check that we got the right values, it should be like the rectangle was
346 // drawn with half opacity even though the alpha channel got messed up. 346 // drawn with half opacity even though the alpha channel got messed up.
347 EXPECT_EQ(red, getPixelAt(src->context(), 0, 0)); 347 EXPECT_EQ(red, getPixelAt(src->context(), 0, 0));
348 EXPECT_EQ(red, getPixelAt(src->context(), 1, 1)); 348 EXPECT_EQ(red, getPixelAt(src->context(), 1, 1));
349 EXPECT_EQ(darkRed, getPixelAt(src->context(), 2, 2)); 349 EXPECT_EQ(darkRed, getPixelAt(src->context(), 2, 2));
350 350
351 // The dark result is: 351 // The dark result is:
352 // (black @ 50% atop green) @ 50% atop red = 0xFF804000 352 // (black @ 50% atop green) @ 50% atop red = 0xFF804000
353 // which is 0xFFA02000 (Skia computes 0xFFA11F00 due to rounding). 353 // which is 0xFFA02000 (Skia computes 0xFFA11F00 due to rounding).
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 TransparencyWin::Untransform, 497 TransparencyWin::Untransform,
498 IntRect(1, -15, 14, 14)); 498 IntRect(1, -15, 14, 14));
499 499
500 // Fill with red. 500 // Fill with red.
501 helper.context()->fillRect(helper.drawRect(), Color(0x7f7f0000)); 501 helper.context()->fillRect(helper.drawRect(), Color(0x7f7f0000));
502 clearTopLayerAlphaChannel(helper.context()); 502 clearTopLayerAlphaChannel(helper.context());
503 helper.composite(); 503 helper.composite();
504 } 504 }
505 505
506 // Finish the compositing. 506 // Finish the compositing.
507 src->context()->endTransparencyLayer(); 507 src->context()->endLayer();
508 508
509 // Top corner should be the original background. 509 // Top corner should be the original background.
510 EXPECT_EQ(white, getPixelAt(src->context(), 0, 0)); 510 EXPECT_EQ(white, getPixelAt(src->context(), 0, 0));
511 511
512 // Check the stripe down the middle, first at the top... 512 // Check the stripe down the middle, first at the top...
513 Color gray(0xFF808080); 513 Color gray(0xFF808080);
514 EXPECT_EQ(white, getPixelAt(src->context(), 6, 0)); 514 EXPECT_EQ(white, getPixelAt(src->context(), 6, 0));
515 EXPECT_EQ(gray, getPixelAt(src->context(), 7, 0)); 515 EXPECT_EQ(gray, getPixelAt(src->context(), 7, 0));
516 EXPECT_EQ(gray, getPixelAt(src->context(), 8, 0)); 516 EXPECT_EQ(gray, getPixelAt(src->context(), 8, 0));
517 EXPECT_EQ(white, getPixelAt(src->context(), 9, 0)); 517 EXPECT_EQ(white, getPixelAt(src->context(), 9, 0));
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 TransparencyWin::ScaleTransform, 666 TransparencyWin::ScaleTransform,
667 IntRect(1, 1, 6, 6)); 667 IntRect(1, 1, 6, 6));
668 668
669 helper.context()->fillRect(helper.drawRect(), Color(0x7f000000)); 669 helper.context()->fillRect(helper.drawRect(), Color(0x7f000000));
670 clearTopLayerAlphaChannel(helper.context()); 670 clearTopLayerAlphaChannel(helper.context());
671 helper.composite(); 671 helper.composite();
672 } 672 }
673 673
674 // Finish the layer. 674 // Finish the layer.
675 src->context()->restore(); 675 src->context()->restore();
676 src->context()->endTransparencyLayer(); 676 src->context()->endLayer();
677 677
678 Color redBackground(0xFFFF8080); // 50% red composited on white. 678 Color redBackground(0xFFFF8080); // 50% red composited on white.
679 EXPECT_EQ(redBackground, getPixelAt(src->context(), 0, 0)); 679 EXPECT_EQ(redBackground, getPixelAt(src->context(), 0, 0));
680 EXPECT_EQ(redBackground, getPixelAt(src->context(), 1, 1)); 680 EXPECT_EQ(redBackground, getPixelAt(src->context(), 1, 1));
681 681
682 // Top half (minus two pixel border) should be 50% gray atop opaque 682 // Top half (minus two pixel border) should be 50% gray atop opaque
683 // red = 0xFF804141. Then that's composited with 50% transparency on solid 683 // red = 0xFF804141. Then that's composited with 50% transparency on solid
684 // white = 0xFFC0A1A1. 684 // white = 0xFFC0A1A1.
685 Color darkRed(0xFFBF8080); 685 Color darkRed(0xFFBF8080);
686 EXPECT_EQ(darkRed, getPixelAt(src->context(), 2, 2)); 686 EXPECT_EQ(darkRed, getPixelAt(src->context(), 2, 2));
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 EXPECT_EQ(oneThirdResult, getPixelAt(src->context(), 1, 0)); 741 EXPECT_EQ(oneThirdResult, getPixelAt(src->context(), 1, 0));
742 EXPECT_EQ(oneThirdResult, getPixelAt(src->context(), 2, 0)); 742 EXPECT_EQ(oneThirdResult, getPixelAt(src->context(), 2, 0));
743 EXPECT_EQ(oneThirdResult, getPixelAt(src->context(), 3, 0)); 743 EXPECT_EQ(oneThirdResult, getPixelAt(src->context(), 3, 0));
744 EXPECT_EQ(oneThirdResult, getPixelAt(src->context(), 4, 0)); 744 EXPECT_EQ(oneThirdResult, getPixelAt(src->context(), 4, 0));
745 EXPECT_EQ(oneThirdResult, getPixelAt(src->context(), 5, 0)); 745 EXPECT_EQ(oneThirdResult, getPixelAt(src->context(), 5, 0));
746 EXPECT_EQ(fullResult, getPixelAt(src->context(), 6, 0)); 746 EXPECT_EQ(fullResult, getPixelAt(src->context(), 6, 0));
747 EXPECT_EQ(Color::transparent, getPixelAt(src->context(), 7, 0)); 747 EXPECT_EQ(Color::transparent, getPixelAt(src->context(), 7, 0));
748 } 748 }
749 749
750 } // namespace WebCore 750 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/svg/graphics/filters/SVGFEImage.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698