| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 // out a transparency layer below that is filled with the mask color. In the
end this should | 108 // out a transparency layer below that is filled with the mask color. In the
end this should |
| 109 // not be marked opaque. | 109 // not be marked opaque. |
| 110 | 110 |
| 111 context->beginLayer(); | 111 context->beginLayer(); |
| 112 context->fillRect(FloatRect(10, 10, 10, 10), opaque, SkXfermode::kSrcOver_Mo
de); | 112 context->fillRect(FloatRect(10, 10, 10, 10), opaque, SkXfermode::kSrcOver_Mo
de); |
| 113 | 113 |
| 114 context->beginLayer(1, SkXfermode::kDstIn_Mode); | 114 context->beginLayer(1, SkXfermode::kDstIn_Mode); |
| 115 | 115 |
| 116 OwnPtr<ImageBuffer> alphaImage = ImageBuffer::create(IntSize(100, 100)); | 116 OwnPtr<ImageBuffer> alphaImage = ImageBuffer::create(IntSize(100, 100)); |
| 117 EXPECT_FALSE(!alphaImage); | 117 EXPECT_FALSE(!alphaImage); |
| 118 alphaImage->context()->fillRect(IntRect(0, 0, 100, 100), alpha); | 118 alphaImage->canvas()->drawColor(alpha.rgb()); |
| 119 | 119 |
| 120 context->drawImageBuffer(alphaImage.get(), FloatRect(10, 10, 10, 10)); | 120 context->drawImageBuffer(alphaImage.get(), FloatRect(10, 10, 10, 10)); |
| 121 | 121 |
| 122 context->endLayer(); | 122 context->endLayer(); |
| 123 context->endLayer(); | 123 context->endLayer(); |
| 124 | 124 |
| 125 EXPECT_OPAQUE_PIXELS_ONLY_IN_RECT(bitmap, IntRect()); | 125 EXPECT_OPAQUE_PIXELS_ONLY_IN_RECT(bitmap, IntRect()); |
| 126 } | 126 } |
| 127 | 127 |
| 128 TEST(GraphicsContextTest, trackImageMaskWithOpaqueRect) | 128 TEST(GraphicsContextTest, trackImageMaskWithOpaqueRect) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 141 // out a transparency layer below that is filled with the mask color. In the
end this should | 141 // out a transparency layer below that is filled with the mask color. In the
end this should |
| 142 // not be marked opaque. | 142 // not be marked opaque. |
| 143 | 143 |
| 144 context->beginLayer(); | 144 context->beginLayer(); |
| 145 context->fillRect(FloatRect(10, 10, 10, 10), opaque, SkXfermode::kSrcOver_Mo
de); | 145 context->fillRect(FloatRect(10, 10, 10, 10), opaque, SkXfermode::kSrcOver_Mo
de); |
| 146 | 146 |
| 147 context->beginLayer(1, SkXfermode::kDstIn_Mode); | 147 context->beginLayer(1, SkXfermode::kDstIn_Mode); |
| 148 | 148 |
| 149 OwnPtr<ImageBuffer> alphaImage = ImageBuffer::create(IntSize(100, 100)); | 149 OwnPtr<ImageBuffer> alphaImage = ImageBuffer::create(IntSize(100, 100)); |
| 150 EXPECT_FALSE(!alphaImage); | 150 EXPECT_FALSE(!alphaImage); |
| 151 alphaImage->context()->fillRect(IntRect(0, 0, 100, 100), alpha); | 151 alphaImage->canvas()->drawColor(alpha.rgb()); |
| 152 | 152 |
| 153 context->drawImageBuffer(alphaImage.get(), FloatRect(10, 10, 10, 10)); | 153 context->drawImageBuffer(alphaImage.get(), FloatRect(10, 10, 10, 10)); |
| 154 | 154 |
| 155 // We can't have an opaque mask actually, but we can pretend here like it wo
uld look if we did. | 155 // We can't have an opaque mask actually, but we can pretend here like it wo
uld look if we did. |
| 156 context->fillRect(FloatRect(12, 12, 3, 3), opaque, SkXfermode::kSrcOver_Mode
); | 156 context->fillRect(FloatRect(12, 12, 3, 3), opaque, SkXfermode::kSrcOver_Mode
); |
| 157 | 157 |
| 158 context->endLayer(); | 158 context->endLayer(); |
| 159 context->endLayer(); | 159 context->endLayer(); |
| 160 | 160 |
| 161 EXPECT_OPAQUE_PIXELS_ONLY_IN_RECT(bitmap, IntRect(12, 12, 3, 3)); | 161 EXPECT_OPAQUE_PIXELS_ONLY_IN_RECT(bitmap, IntRect(12, 12, 3, 3)); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 EXPECT_TRUE(canvas1->unique()); | 265 EXPECT_TRUE(canvas1->unique()); |
| 266 | 266 |
| 267 // endRecording finally makes the picture accessible | 267 // endRecording finally makes the picture accessible |
| 268 RefPtr<const SkPicture> picture = context->endRecording(); | 268 RefPtr<const SkPicture> picture = context->endRecording(); |
| 269 EXPECT_TRUE(picture); | 269 EXPECT_TRUE(picture); |
| 270 | 270 |
| 271 context->endRecording(); | 271 context->endRecording(); |
| 272 } | 272 } |
| 273 | 273 |
| 274 } // namespace | 274 } // namespace |
| OLD | NEW |