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

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 for shape bug 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
« no previous file with comments | « Source/platform/graphics/GraphicsContext.cpp ('k') | Source/platform/graphics/ImageBuffer.h » ('j') | 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) 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // out a transparency layer below that is filled with the mask color. In the end this should 105 // out a transparency layer below that is filled with the mask color. In the end this should
106 // not be marked opaque. 106 // not be marked opaque.
107 107
108 context->beginLayer(); 108 context->beginLayer();
109 context->fillRect(FloatRect(10, 10, 10, 10), opaque, SkXfermode::kSrcOver_Mo de); 109 context->fillRect(FloatRect(10, 10, 10, 10), opaque, SkXfermode::kSrcOver_Mo de);
110 110
111 context->beginLayer(1, SkXfermode::kDstIn_Mode); 111 context->beginLayer(1, SkXfermode::kDstIn_Mode);
112 112
113 OwnPtr<ImageBuffer> alphaImage = ImageBuffer::create(IntSize(100, 100)); 113 OwnPtr<ImageBuffer> alphaImage = ImageBuffer::create(IntSize(100, 100));
114 EXPECT_FALSE(!alphaImage); 114 EXPECT_FALSE(!alphaImage);
115 alphaImage->context()->fillRect(IntRect(0, 0, 100, 100), alpha); 115 alphaImage->canvas()->drawColor(alpha.rgb());
116 116
117 context->drawImageBuffer(alphaImage.get(), FloatRect(10, 10, 10, 10)); 117 context->drawImageBuffer(alphaImage.get(), FloatRect(10, 10, 10, 10));
118 118
119 context->endLayer(); 119 context->endLayer();
120 context->endLayer(); 120 context->endLayer();
121 121
122 EXPECT_OPAQUE_PIXELS_ONLY_IN_RECT(bitmap, IntRect()); 122 EXPECT_OPAQUE_PIXELS_ONLY_IN_RECT(bitmap, IntRect());
123 } 123 }
124 124
125 TEST(GraphicsContextTest, trackImageMaskWithOpaqueRect) 125 TEST(GraphicsContextTest, trackImageMaskWithOpaqueRect)
(...skipping 12 matching lines...) Expand all
138 // out a transparency layer below that is filled with the mask color. In the end this should 138 // out a transparency layer below that is filled with the mask color. In the end this should
139 // not be marked opaque. 139 // not be marked opaque.
140 140
141 context->beginLayer(); 141 context->beginLayer();
142 context->fillRect(FloatRect(10, 10, 10, 10), opaque, SkXfermode::kSrcOver_Mo de); 142 context->fillRect(FloatRect(10, 10, 10, 10), opaque, SkXfermode::kSrcOver_Mo de);
143 143
144 context->beginLayer(1, SkXfermode::kDstIn_Mode); 144 context->beginLayer(1, SkXfermode::kDstIn_Mode);
145 145
146 OwnPtr<ImageBuffer> alphaImage = ImageBuffer::create(IntSize(100, 100)); 146 OwnPtr<ImageBuffer> alphaImage = ImageBuffer::create(IntSize(100, 100));
147 EXPECT_FALSE(!alphaImage); 147 EXPECT_FALSE(!alphaImage);
148 alphaImage->context()->fillRect(IntRect(0, 0, 100, 100), alpha); 148 alphaImage->canvas()->drawColor(alpha.rgb());
149 149
150 context->drawImageBuffer(alphaImage.get(), FloatRect(10, 10, 10, 10)); 150 context->drawImageBuffer(alphaImage.get(), FloatRect(10, 10, 10, 10));
151 151
152 // We can't have an opaque mask actually, but we can pretend here like it wo uld look if we did. 152 // We can't have an opaque mask actually, but we can pretend here like it wo uld look if we did.
153 context->fillRect(FloatRect(12, 12, 3, 3), opaque, SkXfermode::kSrcOver_Mode ); 153 context->fillRect(FloatRect(12, 12, 3, 3), opaque, SkXfermode::kSrcOver_Mode );
154 154
155 context->endLayer(); 155 context->endLayer();
156 context->endLayer(); 156 context->endLayer();
157 157
158 EXPECT_OPAQUE_PIXELS_ONLY_IN_RECT(bitmap, IntRect(12, 12, 3, 3)); 158 EXPECT_OPAQUE_PIXELS_ONLY_IN_RECT(bitmap, IntRect(12, 12, 3, 3));
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 EXPECT_TRUE(canvas1->unique()); 273 EXPECT_TRUE(canvas1->unique());
274 274
275 // endRecording finally makes the picture accessible 275 // endRecording finally makes the picture accessible
276 RefPtr<const SkPicture> picture = context->endRecording(); 276 RefPtr<const SkPicture> picture = context->endRecording();
277 EXPECT_TRUE(picture); 277 EXPECT_TRUE(picture);
278 278
279 context->endRecording(); 279 context->endRecording();
280 } 280 }
281 281
282 } // namespace blink 282 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/graphics/GraphicsContext.cpp ('k') | Source/platform/graphics/ImageBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698