| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 { | 96 { |
| 97 std::ios_base::fmtflags oldFlags = out.flags(std::ios_base::hex | | 97 std::ios_base::fmtflags oldFlags = out.flags(std::ios_base::hex | |
| 98 std::ios_base::showbase); | 98 std::ios_base::showbase); |
| 99 out << c.rgb(); | 99 out << c.rgb(); |
| 100 out.flags(oldFlags); | 100 out.flags(oldFlags); |
| 101 return out; | 101 return out; |
| 102 } | 102 } |
| 103 | 103 |
| 104 TEST(TransparencyWin, NoLayer) | 104 TEST(TransparencyWin, NoLayer) |
| 105 { | 105 { |
| 106 std::auto_ptr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), false)); | 106 OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), false)); |
| 107 | 107 |
| 108 // KeepTransform | 108 // KeepTransform |
| 109 { | 109 { |
| 110 TransparencyWin helper; | 110 TransparencyWin helper; |
| 111 helper.init(src->context(), | 111 helper.init(src->context(), |
| 112 TransparencyWin::NoLayer, | 112 TransparencyWin::NoLayer, |
| 113 TransparencyWin::KeepTransform, | 113 TransparencyWin::KeepTransform, |
| 114 IntRect(1, 1, 14, 12)); | 114 IntRect(1, 1, 14, 12)); |
| 115 | 115 |
| 116 EXPECT_TRUE(src->context() == helper.context()); | 116 EXPECT_TRUE(src->context() == helper.context()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 135 // It should be post-transformed. | 135 // It should be post-transformed. |
| 136 EXPECT_TRUE(src->context() == helper.context()); | 136 EXPECT_TRUE(src->context() == helper.context()); |
| 137 EXPECT_TRUE(IntSize(12, 3) == helper.m_layerSize); | 137 EXPECT_TRUE(IntSize(12, 3) == helper.m_layerSize); |
| 138 EXPECT_TRUE(IntRect(4, 1, 12, 3) == helper.drawRect()); | 138 EXPECT_TRUE(IntRect(4, 1, 12, 3) == helper.drawRect()); |
| 139 } | 139 } |
| 140 src->context()->restore(); | 140 src->context()->restore(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 TEST(TransparencyWin, WhiteLayer) | 143 TEST(TransparencyWin, WhiteLayer) |
| 144 { | 144 { |
| 145 std::auto_ptr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), false)); | 145 OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), false)); |
| 146 | 146 |
| 147 // KeepTransform | 147 // KeepTransform |
| 148 { | 148 { |
| 149 TransparencyWin helper; | 149 TransparencyWin helper; |
| 150 helper.init(src->context(), | 150 helper.init(src->context(), |
| 151 TransparencyWin::WhiteLayer, | 151 TransparencyWin::WhiteLayer, |
| 152 TransparencyWin::KeepTransform, | 152 TransparencyWin::KeepTransform, |
| 153 IntRect(1, 1, 14, 12)); | 153 IntRect(1, 1, 14, 12)); |
| 154 helper.composite(); | 154 helper.composite(); |
| 155 | 155 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 // It should be post-transformed. | 187 // It should be post-transformed. |
| 188 EXPECT_TRUE(src->context() != helper.context()); | 188 EXPECT_TRUE(src->context() != helper.context()); |
| 189 EXPECT_TRUE(IntSize(12, 3) == helper.m_layerSize); | 189 EXPECT_TRUE(IntSize(12, 3) == helper.m_layerSize); |
| 190 EXPECT_TRUE(IntRect(0, 0, 12, 3) == helper.drawRect()); | 190 EXPECT_TRUE(IntRect(0, 0, 12, 3) == helper.drawRect()); |
| 191 } | 191 } |
| 192 src->context()->restore(); | 192 src->context()->restore(); |
| 193 } | 193 } |
| 194 | 194 |
| 195 TEST(TransparencyWin, TextComposite) | 195 TEST(TransparencyWin, TextComposite) |
| 196 { | 196 { |
| 197 std::auto_ptr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), false)); | 197 OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), false)); |
| 198 | 198 |
| 199 // KeepTransform is the only valid transform mode for TextComposite. | 199 // KeepTransform is the only valid transform mode for TextComposite. |
| 200 { | 200 { |
| 201 TransparencyWin helper; | 201 TransparencyWin helper; |
| 202 helper.init(src->context(), | 202 helper.init(src->context(), |
| 203 TransparencyWin::TextComposite, | 203 TransparencyWin::TextComposite, |
| 204 TransparencyWin::KeepTransform, | 204 TransparencyWin::KeepTransform, |
| 205 IntRect(1, 1, 14, 12)); | 205 IntRect(1, 1, 14, 12)); |
| 206 helper.composite(); | 206 helper.composite(); |
| 207 | 207 |
| 208 EXPECT_TRUE(src->context() != helper.context()); | 208 EXPECT_TRUE(src->context() != helper.context()); |
| 209 EXPECT_TRUE(IntSize(14, 12) == helper.m_layerSize); | 209 EXPECT_TRUE(IntSize(14, 12) == helper.m_layerSize); |
| 210 EXPECT_TRUE(IntRect(1, 1, 14, 12) == helper.drawRect()); | 210 EXPECT_TRUE(IntRect(1, 1, 14, 12) == helper.drawRect()); |
| 211 } | 211 } |
| 212 } | 212 } |
| 213 | 213 |
| 214 TEST(TransparencyWin, OpaqueCompositeLayer) | 214 TEST(TransparencyWin, OpaqueCompositeLayer) |
| 215 { | 215 { |
| 216 std::auto_ptr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), false)); | 216 OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), false)); |
| 217 | 217 |
| 218 // KeepTransform | 218 // KeepTransform |
| 219 { | 219 { |
| 220 TransparencyWin helper; | 220 TransparencyWin helper; |
| 221 helper.init(src->context(), | 221 helper.init(src->context(), |
| 222 TransparencyWin::OpaqueCompositeLayer, | 222 TransparencyWin::OpaqueCompositeLayer, |
| 223 TransparencyWin::KeepTransform, | 223 TransparencyWin::KeepTransform, |
| 224 IntRect(1, 1, 14, 12)); | 224 IntRect(1, 1, 14, 12)); |
| 225 helper.composite(); | 225 helper.composite(); |
| 226 | 226 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 EXPECT_TRUE(src->context() != helper.context()); | 276 EXPECT_TRUE(src->context() != helper.context()); |
| 277 EXPECT_TRUE(IntSize(12, 3) == helper.m_layerSize); | 277 EXPECT_TRUE(IntSize(12, 3) == helper.m_layerSize); |
| 278 EXPECT_TRUE(IntRect(0, 0, 12, 3) == helper.drawRect()); | 278 EXPECT_TRUE(IntRect(0, 0, 12, 3) == helper.drawRect()); |
| 279 } | 279 } |
| 280 src->context()->restore(); | 280 src->context()->restore(); |
| 281 } | 281 } |
| 282 | 282 |
| 283 TEST(TransparencyWin, WhiteLayerPixelTest) | 283 TEST(TransparencyWin, WhiteLayerPixelTest) |
| 284 { | 284 { |
| 285 // Make a total transparent buffer, and draw the white layer inset by 1 px. | 285 // Make a total transparent buffer, and draw the white layer inset by 1 px. |
| 286 std::auto_ptr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), false)); | 286 OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), false)); |
| 287 | 287 |
| 288 { | 288 { |
| 289 TransparencyWin helper; | 289 TransparencyWin helper; |
| 290 helper.init(src->context(), | 290 helper.init(src->context(), |
| 291 TransparencyWin::WhiteLayer, | 291 TransparencyWin::WhiteLayer, |
| 292 TransparencyWin::KeepTransform, | 292 TransparencyWin::KeepTransform, |
| 293 IntRect(1, 1, 14, 14)); | 293 IntRect(1, 1, 14, 14)); |
| 294 | 294 |
| 295 // Coordinates should be in the original space, not the layer. | 295 // Coordinates should be in the original space, not the layer. |
| 296 drawNativeRect(helper.context(), 3, 3, 1, 1); | 296 drawNativeRect(helper.context(), 3, 3, 1, 1); |
| 297 clearTopLayerAlphaChannel(helper.context()); | 297 clearTopLayerAlphaChannel(helper.context()); |
| 298 helper.composite(); | 298 helper.composite(); |
| 299 } | 299 } |
| 300 | 300 |
| 301 // The final image should be transparent around the edges for 1 px, white | 301 // The final image should be transparent around the edges for 1 px, white |
| 302 // in the middle, with (3,3) (what we drew above) being opaque black. | 302 // in the middle, with (3,3) (what we drew above) being opaque black. |
| 303 EXPECT_EQ(Color(Color::transparent), getPixelAt(src->context(), 0, 0)); | 303 EXPECT_EQ(Color(Color::transparent), getPixelAt(src->context(), 0, 0)); |
| 304 EXPECT_EQ(Color(Color::white), getPixelAt(src->context(), 2, 2)); | 304 EXPECT_EQ(Color(Color::white), getPixelAt(src->context(), 2, 2)); |
| 305 EXPECT_EQ(Color(Color::black), getPixelAt(src->context(), 3, 3)); | 305 EXPECT_EQ(Color(Color::black), getPixelAt(src->context(), 3, 3)); |
| 306 EXPECT_EQ(Color(Color::white), getPixelAt(src->context(), 4, 4)); | 306 EXPECT_EQ(Color(Color::white), getPixelAt(src->context(), 4, 4)); |
| 307 } | 307 } |
| 308 | 308 |
| 309 TEST(TransparencyWin, OpaqueCompositeLayerPixel) | 309 TEST(TransparencyWin, OpaqueCompositeLayerPixel) |
| 310 { | 310 { |
| 311 Color red(0xFFFF0000), darkRed(0xFFC00000); | 311 Color red(0xFFFF0000), darkRed(0xFFC00000); |
| 312 Color green(0xFF00FF00); | 312 Color green(0xFF00FF00); |
| 313 | 313 |
| 314 // Make a red bottom layer, followed by a half green next layer @ 50%. | 314 // Make a red bottom layer, followed by a half green next layer @ 50%. |
| 315 std::auto_ptr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), false)); | 315 OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), false)); |
| 316 | 316 |
| 317 FloatRect fullRect(0, 0, 16, 16); | 317 FloatRect fullRect(0, 0, 16, 16); |
| 318 src->context()->fillRect(fullRect, red); | 318 src->context()->fillRect(fullRect, red); |
| 319 src->context()->beginTransparencyLayer(0.5); | 319 src->context()->beginTransparencyLayer(0.5); |
| 320 FloatRect rightHalf(8, 0, 8, 16); | 320 FloatRect rightHalf(8, 0, 8, 16); |
| 321 src->context()->fillRect(rightHalf, green); | 321 src->context()->fillRect(rightHalf, green); |
| 322 | 322 |
| 323 // Make a transparency layer inset by one pixel, and fill it inset by | 323 // Make a transparency layer inset by one pixel, and fill it inset by |
| 324 // another pixel with 50% black. | 324 // another pixel with 50% black. |
| 325 { | 325 { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 // 50% green on top of red = FF808000 (rounded to what Skia will produce). | 358 // 50% green on top of red = FF808000 (rounded to what Skia will produce). |
| 359 Color greenRed(0xFF817E00); | 359 Color greenRed(0xFF817E00); |
| 360 EXPECT_EQ(greenRed, getPixelAt(src->context(), 14, 14)); | 360 EXPECT_EQ(greenRed, getPixelAt(src->context(), 14, 14)); |
| 361 EXPECT_EQ(greenRed, getPixelAt(src->context(), 15, 15)); | 361 EXPECT_EQ(greenRed, getPixelAt(src->context(), 15, 15)); |
| 362 } | 362 } |
| 363 | 363 |
| 364 // Tests that translations are properly handled when using KeepTransform. | 364 // Tests that translations are properly handled when using KeepTransform. |
| 365 TEST(TransparencyWin, TranslateOpaqueCompositeLayer) | 365 TEST(TransparencyWin, TranslateOpaqueCompositeLayer) |
| 366 { | 366 { |
| 367 // Fill with white. | 367 // Fill with white. |
| 368 std::auto_ptr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), false)); | 368 OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), false)); |
| 369 Color white(0xFFFFFFFF); | 369 Color white(0xFFFFFFFF); |
| 370 FloatRect fullRect(0, 0, 16, 16); | 370 FloatRect fullRect(0, 0, 16, 16); |
| 371 src->context()->fillRect(fullRect, white); | 371 src->context()->fillRect(fullRect, white); |
| 372 | 372 |
| 373 // Scroll down by 8 (coordinate system goes up). | 373 // Scroll down by 8 (coordinate system goes up). |
| 374 src->context()->save(); | 374 src->context()->save(); |
| 375 src->context()->translate(0, -8); | 375 src->context()->translate(0, -8); |
| 376 | 376 |
| 377 Color red(0xFFFF0000); | 377 Color red(0xFFFF0000); |
| 378 Color green(0xFF00FF00); | 378 Color green(0xFF00FF00); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 395 src->context()->restore(); | 395 src->context()->restore(); |
| 396 | 396 |
| 397 // Check the pixel we wrote. | 397 // Check the pixel we wrote. |
| 398 EXPECT_EQ(green, getPixelAt(src->context(), 15, 7)); | 398 EXPECT_EQ(green, getPixelAt(src->context(), 15, 7)); |
| 399 } | 399 } |
| 400 | 400 |
| 401 // Same as OpaqueCompositeLayer, but the canvas has a rotation applied. This | 401 // Same as OpaqueCompositeLayer, but the canvas has a rotation applied. This |
| 402 // tests that the propert transform is applied to the copied layer. | 402 // tests that the propert transform is applied to the copied layer. |
| 403 TEST(TransparencyWin, RotateOpaqueCompositeLayer) | 403 TEST(TransparencyWin, RotateOpaqueCompositeLayer) |
| 404 { | 404 { |
| 405 std::auto_ptr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), false)); | 405 OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), false)); |
| 406 | 406 |
| 407 // The background is white. | 407 // The background is white. |
| 408 Color white(0xFFFFFFFF); | 408 Color white(0xFFFFFFFF); |
| 409 FloatRect fullRect(0, 0, 16, 16); | 409 FloatRect fullRect(0, 0, 16, 16); |
| 410 src->context()->fillRect(fullRect, white); | 410 src->context()->fillRect(fullRect, white); |
| 411 | 411 |
| 412 // Rotate the image by 90 degrees. This matrix is the same as | 412 // Rotate the image by 90 degrees. This matrix is the same as |
| 413 // cw90.rotate(90); but avoids rounding errors. Rounding errors can cause | 413 // cw90.rotate(90); but avoids rounding errors. Rounding errors can cause |
| 414 // Skia to think that !rectStaysRect() and it will fall through to path | 414 // Skia to think that !rectStaysRect() and it will fall through to path |
| 415 // drawing mode, which in turn gives us antialiasing. We want no | 415 // drawing mode, which in turn gives us antialiasing. We want no |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 EXPECT_EQ(redwhite, getPixelAt(src->context(), 9, 1)); | 477 EXPECT_EQ(redwhite, getPixelAt(src->context(), 9, 1)); |
| 478 EXPECT_EQ(redwhite, getPixelAt(src->context(), 14, 1)); | 478 EXPECT_EQ(redwhite, getPixelAt(src->context(), 14, 1)); |
| 479 EXPECT_EQ(white, getPixelAt(src->context(), 15, 1)); | 479 EXPECT_EQ(white, getPixelAt(src->context(), 15, 1)); |
| 480 | 480 |
| 481 // Complete the 50% transparent layer. | 481 // Complete the 50% transparent layer. |
| 482 src->context()->restore(); | 482 src->context()->restore(); |
| 483 } | 483 } |
| 484 | 484 |
| 485 TEST(TransparencyWin, TranslateScaleOpaqueCompositeLayer) | 485 TEST(TransparencyWin, TranslateScaleOpaqueCompositeLayer) |
| 486 { | 486 { |
| 487 std::auto_ptr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), false)); | 487 OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), false)); |
| 488 | 488 |
| 489 // The background is white on top with red on bottom. | 489 // The background is white on top with red on bottom. |
| 490 Color white(0xFFFFFFFF); | 490 Color white(0xFFFFFFFF); |
| 491 FloatRect topRect(0, 0, 16, 8); | 491 FloatRect topRect(0, 0, 16, 8); |
| 492 src->context()->fillRect(topRect, white); | 492 src->context()->fillRect(topRect, white); |
| 493 Color red(0xFFFF0000); | 493 Color red(0xFFFF0000); |
| 494 FloatRect bottomRect(0, 8, 16, 8); | 494 FloatRect bottomRect(0, 8, 16, 8); |
| 495 src->context()->fillRect(bottomRect, red); | 495 src->context()->fillRect(bottomRect, red); |
| 496 | 496 |
| 497 src->context()->save(); | 497 src->context()->save(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 525 helper.context()->fillRect(helper.drawRect(), Color(0x7f7f0000)); | 525 helper.context()->fillRect(helper.drawRect(), Color(0x7f7f0000)); |
| 526 clearTopLayerAlphaChannel(helper.context()); | 526 clearTopLayerAlphaChannel(helper.context()); |
| 527 helper.composite(); | 527 helper.composite(); |
| 528 } | 528 } |
| 529 } | 529 } |
| 530 | 530 |
| 531 // Tests scale mode with no additional copy. | 531 // Tests scale mode with no additional copy. |
| 532 TEST(TransparencyWin, Scale) | 532 TEST(TransparencyWin, Scale) |
| 533 { | 533 { |
| 534 // Create an opaque white buffer. | 534 // Create an opaque white buffer. |
| 535 std::auto_ptr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), false)); | 535 OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), false)); |
| 536 FloatRect fullBuffer(0, 0, 16, 16); | 536 FloatRect fullBuffer(0, 0, 16, 16); |
| 537 src->context()->fillRect(fullBuffer, Color::white); | 537 src->context()->fillRect(fullBuffer, Color::white); |
| 538 | 538 |
| 539 // Scale by 2x. | 539 // Scale by 2x. |
| 540 src->context()->save(); | 540 src->context()->save(); |
| 541 TransformationMatrix scale; | 541 TransformationMatrix scale; |
| 542 scale.scale(2.0); | 542 scale.scale(2.0); |
| 543 src->context()->concatCTM(scale); | 543 src->context()->concatCTM(scale); |
| 544 | 544 |
| 545 // Start drawing a rectangle from 1->4. This should get scaled to 2->8. | 545 // Start drawing a rectangle from 1->4. This should get scaled to 2->8. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 //EXPECT_EQ(Color(Color::white), getPixelAt(src->context(), 2, 2)); | 580 //EXPECT_EQ(Color(Color::white), getPixelAt(src->context(), 2, 2)); |
| 581 } | 581 } |
| 582 | 582 |
| 583 // Tests scale mode with an additional copy for transparency. This will happen | 583 // Tests scale mode with an additional copy for transparency. This will happen |
| 584 // if we have a scaled textbox, for example. WebKit will create a new | 584 // if we have a scaled textbox, for example. WebKit will create a new |
| 585 // transparency layer, draw the text field, then draw the text into it, then | 585 // transparency layer, draw the text field, then draw the text into it, then |
| 586 // composite this down with an opacity. | 586 // composite this down with an opacity. |
| 587 TEST(TransparencyWin, ScaleTransparency) | 587 TEST(TransparencyWin, ScaleTransparency) |
| 588 { | 588 { |
| 589 // Create an opaque white buffer. | 589 // Create an opaque white buffer. |
| 590 std::auto_ptr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), false)); | 590 OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), false)); |
| 591 FloatRect fullBuffer(0, 0, 16, 16); | 591 FloatRect fullBuffer(0, 0, 16, 16); |
| 592 src->context()->fillRect(fullBuffer, Color::white); | 592 src->context()->fillRect(fullBuffer, Color::white); |
| 593 | 593 |
| 594 // Make another layer (which duplicates how WebKit will make this). We fill | 594 // Make another layer (which duplicates how WebKit will make this). We fill |
| 595 // the top half with red, and have the layer be 50% opaque. | 595 // the top half with red, and have the layer be 50% opaque. |
| 596 src->context()->beginTransparencyLayer(0.5); | 596 src->context()->beginTransparencyLayer(0.5); |
| 597 FloatRect topHalf(0, 0, 16, 8); | 597 FloatRect topHalf(0, 0, 16, 8); |
| 598 src->context()->fillRect(topHalf, Color(0xFFFF0000)); | 598 src->context()->fillRect(topHalf, Color(0xFFFF0000)); |
| 599 | 599 |
| 600 // Scale by 2x. | 600 // Scale by 2x. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 EXPECT_EQ(darkWhite, getPixelAt(src->context(), 8, 8)); | 638 EXPECT_EQ(darkWhite, getPixelAt(src->context(), 8, 8)); |
| 639 EXPECT_EQ(darkWhite, getPixelAt(src->context(), 13, 13)); | 639 EXPECT_EQ(darkWhite, getPixelAt(src->context(), 13, 13)); |
| 640 | 640 |
| 641 Color white(0xFFFFFFFF); // Background in the lower-right. | 641 Color white(0xFFFFFFFF); // Background in the lower-right. |
| 642 EXPECT_EQ(white, getPixelAt(src->context(), 14, 14)); | 642 EXPECT_EQ(white, getPixelAt(src->context(), 14, 14)); |
| 643 EXPECT_EQ(white, getPixelAt(src->context(), 15, 15)); | 643 EXPECT_EQ(white, getPixelAt(src->context(), 15, 15)); |
| 644 } | 644 } |
| 645 | 645 |
| 646 TEST(TransparencyWin, Text) | 646 TEST(TransparencyWin, Text) |
| 647 { | 647 { |
| 648 std::auto_ptr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), false)); | 648 OwnPtr<ImageBuffer> src(ImageBuffer::create(IntSize(16, 16), false)); |
| 649 | 649 |
| 650 // Our text should end up 50% transparent blue-green. | 650 // Our text should end up 50% transparent blue-green. |
| 651 Color fullResult(0x80008080); | 651 Color fullResult(0x80008080); |
| 652 | 652 |
| 653 { | 653 { |
| 654 TransparencyWin helper; | 654 TransparencyWin helper; |
| 655 helper.init(src->context(), | 655 helper.init(src->context(), |
| 656 TransparencyWin::TextComposite, | 656 TransparencyWin::TextComposite, |
| 657 TransparencyWin::KeepTransform, | 657 TransparencyWin::KeepTransform, |
| 658 IntRect(0, 0, 16, 16)); | 658 IntRect(0, 0, 16, 16)); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 687 EXPECT_EQ(oneThirdResult, getPixelAt(src->context(), 1, 0)); | 687 EXPECT_EQ(oneThirdResult, getPixelAt(src->context(), 1, 0)); |
| 688 EXPECT_EQ(oneThirdResult, getPixelAt(src->context(), 2, 0)); | 688 EXPECT_EQ(oneThirdResult, getPixelAt(src->context(), 2, 0)); |
| 689 EXPECT_EQ(oneThirdResult, getPixelAt(src->context(), 3, 0)); | 689 EXPECT_EQ(oneThirdResult, getPixelAt(src->context(), 3, 0)); |
| 690 EXPECT_EQ(oneThirdResult, getPixelAt(src->context(), 4, 0)); | 690 EXPECT_EQ(oneThirdResult, getPixelAt(src->context(), 4, 0)); |
| 691 EXPECT_EQ(oneThirdResult, getPixelAt(src->context(), 5, 0)); | 691 EXPECT_EQ(oneThirdResult, getPixelAt(src->context(), 5, 0)); |
| 692 EXPECT_EQ(fullResult, getPixelAt(src->context(), 6, 0)); | 692 EXPECT_EQ(fullResult, getPixelAt(src->context(), 6, 0)); |
| 693 EXPECT_EQ(Color::transparent, getPixelAt(src->context(), 7, 0)); | 693 EXPECT_EQ(Color::transparent, getPixelAt(src->context(), 7, 0)); |
| 694 } | 694 } |
| 695 | 695 |
| 696 } // namespace WebCore | 696 } // namespace WebCore |
| OLD | NEW |