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

Side by Side Diff: Source/core/html/canvas/CanvasRenderingContext2DAPITest.cpp

Issue 1084313004: Oilpan: keep ImageData on the heap by default. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Ensure timely disposal of temporary ImageData buffers Created 5 years, 7 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 6
7 #include "core/html/canvas/CanvasRenderingContext2D.h" 7 #include "core/html/canvas/CanvasRenderingContext2D.h"
8 8
9 #include "core/frame/FrameView.h" 9 #include "core/frame/FrameView.h"
10 #include "core/html/HTMLDocument.h" 10 #include "core/html/HTMLDocument.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 EXPECT_EQ(String("rgba(0, 0, 0, 0)"), context2d()->shadowColor()); 177 EXPECT_EQ(String("rgba(0, 0, 0, 0)"), context2d()->shadowColor());
178 } 178 }
179 179
180 TEST_F(CanvasRenderingContext2DAPITest, CreateImageData) 180 TEST_F(CanvasRenderingContext2DAPITest, CreateImageData)
181 { 181 {
182 createContext(NonOpaque); 182 createContext(NonOpaque);
183 183
184 NonThrowableExceptionState exceptionState; 184 NonThrowableExceptionState exceptionState;
185 185
186 // create a 100x50 imagedata and fill it with white pixels 186 // create a 100x50 imagedata and fill it with white pixels
187 RefPtrWillBeRawPtr<ImageData> imageData = context2d()->createImageData(100, 50, exceptionState); 187 ImageData* imageData = context2d()->createImageData(100, 50, exceptionState) ;
188 EXPECT_FALSE(exceptionState.hadException()); 188 EXPECT_FALSE(exceptionState.hadException());
189 EXPECT_EQ(100, imageData->width()); 189 EXPECT_EQ(100, imageData->width());
190 EXPECT_EQ(50, imageData->height()); 190 EXPECT_EQ(50, imageData->height());
191 191
192 for (unsigned i = 0; i < imageData->data()->length(); ++i) 192 for (unsigned i = 0; i < imageData->data()->length(); ++i)
193 imageData->data()->data()[i] = 255; 193 imageData->data()->data()[i] = 255;
194 194
195 EXPECT_EQ(255, imageData->data()->data()[32]); 195 EXPECT_EQ(255, imageData->data()->data()[32]);
196 196
197 // createImageData(imageData) should create a new ImageData of the same size as 'imageData' 197 // createImageData(imageData) should create a new ImageData of the same size as 'imageData'
198 // but filled with transparent black 198 // but filled with transparent black
199 199
200 RefPtrWillBeRawPtr<ImageData> sameSizeImageData = context2d()->createImageDa ta(imageData); 200 ImageData* sameSizeImageData = context2d()->createImageData(imageData);
201 EXPECT_EQ(100, sameSizeImageData->width()); 201 EXPECT_EQ(100, sameSizeImageData->width());
202 EXPECT_EQ(50, sameSizeImageData->height()); 202 EXPECT_EQ(50, sameSizeImageData->height());
203 EXPECT_EQ(0, sameSizeImageData->data()->data()[32]); 203 EXPECT_EQ(0, sameSizeImageData->data()->data()[32]);
204 204
205 // createImageData(width, height) takes the absolute magnitude of the size a rguments 205 // createImageData(width, height) takes the absolute magnitude of the size a rguments
206 206
207 RefPtrWillBeRawPtr<ImageData> imgdata1 = context2d()->createImageData(10, 20 , exceptionState); 207 ImageData* imgdata1 = context2d()->createImageData(10, 20, exceptionState);
208 EXPECT_FALSE(exceptionState.hadException()); 208 EXPECT_FALSE(exceptionState.hadException());
209 RefPtrWillBeRawPtr<ImageData> imgdata2 = context2d()->createImageData(-10, 2 0, exceptionState); 209 ImageData* imgdata2 = context2d()->createImageData(-10, 20, exceptionState);
210 EXPECT_FALSE(exceptionState.hadException()); 210 EXPECT_FALSE(exceptionState.hadException());
211 RefPtrWillBeRawPtr<ImageData> imgdata3 = context2d()->createImageData(10, -2 0, exceptionState); 211 ImageData* imgdata3 = context2d()->createImageData(10, -20, exceptionState);
212 EXPECT_FALSE(exceptionState.hadException()); 212 EXPECT_FALSE(exceptionState.hadException());
213 RefPtrWillBeRawPtr<ImageData> imgdata4 = context2d()->createImageData(-10, - 20, exceptionState); 213 ImageData* imgdata4 = context2d()->createImageData(-10, -20, exceptionState) ;
214 EXPECT_FALSE(exceptionState.hadException()); 214 EXPECT_FALSE(exceptionState.hadException());
215 215
216 EXPECT_EQ((unsigned)800, imgdata1->data()->length()); 216 EXPECT_EQ((unsigned)800, imgdata1->data()->length());
217 EXPECT_EQ((unsigned)800, imgdata2->data()->length()); 217 EXPECT_EQ((unsigned)800, imgdata2->data()->length());
218 EXPECT_EQ((unsigned)800, imgdata3->data()->length()); 218 EXPECT_EQ((unsigned)800, imgdata3->data()->length());
219 EXPECT_EQ((unsigned)800, imgdata4->data()->length()); 219 EXPECT_EQ((unsigned)800, imgdata4->data()->length());
220 } 220 }
221 221
222 } // unnamed namespace 222 } // unnamed namespace
OLDNEW
« no previous file with comments | « Source/core/html/canvas/CanvasRenderingContext2D.cpp ('k') | Source/core/html/canvas/CanvasRenderingContext2DTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698