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

Side by Side Diff: Source/platform/graphics/GraphicsContextTest.cpp

Issue 1170523002: Removing GraphicsContext from ImageBuffer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix unit test crashes Created 5 years, 6 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
OLDNEW
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
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698