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

Side by Side Diff: Source/core/frame/ImageBitmapTest.cpp

Issue 292763002: Oilpan: simplify ImageBitmapTest heap clearing. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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
« no previous file with comments | « no previous file | no next file » | 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) 2013, Google Inc. All rights reserved. 2 * Copyright (c) 2013, 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 memoryCache()->updateDecodedResource(cachedImageInteriorCrop.get(), UpdateFo rPropertyChange); 139 memoryCache()->updateDecodedResource(cachedImageInteriorCrop.get(), UpdateFo rPropertyChange);
140 memoryCache()->updateDecodedResource(cachedImageExteriorCrop.get(), UpdateFo rPropertyChange); 140 memoryCache()->updateDecodedResource(cachedImageExteriorCrop.get(), UpdateFo rPropertyChange);
141 memoryCache()->updateDecodedResource(cachedImageOutsideCrop.get(), UpdateFor PropertyChange); 141 memoryCache()->updateDecodedResource(cachedImageOutsideCrop.get(), UpdateFor PropertyChange);
142 142
143 // HTMLImageElements should default to CacheLiveResourcePriorityLow. 143 // HTMLImageElements should default to CacheLiveResourcePriorityLow.
144 ASSERT_EQ(memoryCache()->priority(imageNoCrop->cachedImage()), MemoryCacheLi veResourcePriorityLow); 144 ASSERT_EQ(memoryCache()->priority(imageNoCrop->cachedImage()), MemoryCacheLi veResourcePriorityLow);
145 ASSERT_EQ(memoryCache()->priority(imageInteriorCrop->cachedImage()), MemoryC acheLiveResourcePriorityLow); 145 ASSERT_EQ(memoryCache()->priority(imageInteriorCrop->cachedImage()), MemoryC acheLiveResourcePriorityLow);
146 ASSERT_EQ(memoryCache()->priority(imageExteriorCrop->cachedImage()), MemoryC acheLiveResourcePriorityLow); 146 ASSERT_EQ(memoryCache()->priority(imageExteriorCrop->cachedImage()), MemoryC acheLiveResourcePriorityLow);
147 ASSERT_EQ(memoryCache()->priority(imageOutsideCrop->cachedImage()), MemoryCa cheLiveResourcePriorityLow); 147 ASSERT_EQ(memoryCache()->priority(imageOutsideCrop->cachedImage()), MemoryCa cheLiveResourcePriorityLow);
148 148
149 RefPtrWillBeRawPtr<ImageBitmap> imageBitmapInteriorCrop = ImageBitmap::creat e(imageInteriorCrop.get(), IntRect(m_bitmap.width() / 2, m_bitmap.height() / 2, m_bitmap.width(), m_bitmap.height())); 149 RefPtrWillBePersistent<ImageBitmap> imageBitmapInteriorCrop = ImageBitmap::c reate(imageInteriorCrop.get(), IntRect(m_bitmap.width() / 2, m_bitmap.height() / 2, m_bitmap.width(), m_bitmap.height()));
150 { 150 {
151 RefPtrWillBeRawPtr<ImageBitmap> imageBitmapNoCrop = ImageBitmap::create( imageNoCrop.get(), IntRect(0, 0, m_bitmap.width(), m_bitmap.height())); 151 RefPtrWillBeRawPtr<ImageBitmap> imageBitmapNoCrop = ImageBitmap::create( imageNoCrop.get(), IntRect(0, 0, m_bitmap.width(), m_bitmap.height()));
152 RefPtrWillBeRawPtr<ImageBitmap> imageBitmapInteriorCrop2 = ImageBitmap:: create(imageInteriorCrop.get(), IntRect(m_bitmap.width() / 2, m_bitmap.height() / 2, m_bitmap.width(), m_bitmap.height())); 152 RefPtrWillBeRawPtr<ImageBitmap> imageBitmapInteriorCrop2 = ImageBitmap:: create(imageInteriorCrop.get(), IntRect(m_bitmap.width() / 2, m_bitmap.height() / 2, m_bitmap.width(), m_bitmap.height()));
153 RefPtrWillBeRawPtr<ImageBitmap> imageBitmapExteriorCrop = ImageBitmap::c reate(imageExteriorCrop.get(), IntRect(-m_bitmap.width() / 2, -m_bitmap.height() / 2, m_bitmap.width(), m_bitmap.height())); 153 RefPtrWillBeRawPtr<ImageBitmap> imageBitmapExteriorCrop = ImageBitmap::c reate(imageExteriorCrop.get(), IntRect(-m_bitmap.width() / 2, -m_bitmap.height() / 2, m_bitmap.width(), m_bitmap.height()));
154 RefPtrWillBeRawPtr<ImageBitmap> imageBitmapOutsideCrop = ImageBitmap::cr eate(imageOutsideCrop.get(), IntRect(-m_bitmap.width(), -m_bitmap.height(), m_bi tmap.width(), m_bitmap.height())); 154 RefPtrWillBeRawPtr<ImageBitmap> imageBitmapOutsideCrop = ImageBitmap::cr eate(imageOutsideCrop.get(), IntRect(-m_bitmap.width(), -m_bitmap.height(), m_bi tmap.width(), m_bitmap.height()));
155 155
156 // Images that are referenced by ImageBitmaps have CacheLiveResourcePrio rityHigh. 156 // Images that are referenced by ImageBitmaps have CacheLiveResourcePrio rityHigh.
157 ASSERT_EQ(memoryCache()->priority(imageNoCrop->cachedImage()), MemoryCac heLiveResourcePriorityHigh); 157 ASSERT_EQ(memoryCache()->priority(imageNoCrop->cachedImage()), MemoryCac heLiveResourcePriorityHigh);
158 ASSERT_EQ(memoryCache()->priority(imageInteriorCrop->cachedImage()), Mem oryCacheLiveResourcePriorityHigh); 158 ASSERT_EQ(memoryCache()->priority(imageInteriorCrop->cachedImage()), Mem oryCacheLiveResourcePriorityHigh);
159 ASSERT_EQ(memoryCache()->priority(imageExteriorCrop->cachedImage()), Mem oryCacheLiveResourcePriorityHigh); 159 ASSERT_EQ(memoryCache()->priority(imageExteriorCrop->cachedImage()), Mem oryCacheLiveResourcePriorityHigh);
160 160
161 // ImageBitmaps that do not contain any of the source image do not eleva te CacheLiveResourcePriority. 161 // ImageBitmaps that do not contain any of the source image do not eleva te CacheLiveResourcePriority.
162 ASSERT_EQ(memoryCache()->priority(imageOutsideCrop->cachedImage()), Memo ryCacheLiveResourcePriorityLow); 162 ASSERT_EQ(memoryCache()->priority(imageOutsideCrop->cachedImage()), Memo ryCacheLiveResourcePriorityLow);
163 163
164 // Stub out references to the ImageBitmaps created and force a 164 // Force a garbage collection to sweep out the local ImageBitmaps.
165 // garbage collection to have the ImageBitmaps be collected and 165 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack);
haraken 2014/05/19 13:28:02 hmm, I'm not quite sure if this change addresses t
sof 2014/05/19 13:31:30 The only object reference we care about is a Persi
wibling-chromium 2014/05/19 13:34:36 As I understand it the assumption was that doing a
haraken 2014/05/19 13:39:29 Sorry, you're right. It might work. I thought tha
Mads Ager (chromium) 2014/05/19 13:52:46 Consider moving this to right after the block inst
sof 2014/05/19 14:12:57 ok, done that (also had to do some ALLOW_UNUSED de
166 // destructed.
167 imageBitmapNoCrop = nullptr;
168 imageBitmapInteriorCrop2 = nullptr;
169 imageBitmapExteriorCrop = nullptr;
170 imageBitmapOutsideCrop = nullptr;
171 Heap::collectGarbage(ThreadState::HeapPointersOnStack);
172 } 166 }
173 167
174 // CacheLiveResourcePriroity should return to CacheLiveResourcePriorityLow w hen no ImageBitmaps reference the image. 168 // CacheLiveResourcePriroity should return to CacheLiveResourcePriorityLow w hen no ImageBitmaps reference the image.
175 ASSERT_EQ(memoryCache()->priority(imageNoCrop->cachedImage()), MemoryCacheLi veResourcePriorityLow); 169 ASSERT_EQ(memoryCache()->priority(imageNoCrop->cachedImage()), MemoryCacheLi veResourcePriorityLow);
176 ASSERT_EQ(memoryCache()->priority(imageExteriorCrop->cachedImage()), MemoryC acheLiveResourcePriorityLow); 170 ASSERT_EQ(memoryCache()->priority(imageExteriorCrop->cachedImage()), MemoryC acheLiveResourcePriorityLow);
177 ASSERT_EQ(memoryCache()->priority(imageOutsideCrop->cachedImage()), MemoryCa cheLiveResourcePriorityLow); 171 ASSERT_EQ(memoryCache()->priority(imageOutsideCrop->cachedImage()), MemoryCa cheLiveResourcePriorityLow);
178 172
179 // There is still an ImageBitmap that references this image. 173 // There is still an ImageBitmap that references this image.
180 ASSERT_EQ(memoryCache()->priority(imageInteriorCrop->cachedImage()), MemoryC acheLiveResourcePriorityHigh); 174 ASSERT_EQ(memoryCache()->priority(imageInteriorCrop->cachedImage()), MemoryC acheLiveResourcePriorityHigh);
181 imageBitmapInteriorCrop = nullptr; 175 imageBitmapInteriorCrop = nullptr;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 { 208 {
215 RefPtrWillBeRawPtr<ImageBitmap> imageBitmapFromCanvas = ImageBitmap::cre ate(canvasElement.get(), IntRect(0, 0, canvasElement->width(), canvasElement->he ight())); 209 RefPtrWillBeRawPtr<ImageBitmap> imageBitmapFromCanvas = ImageBitmap::cre ate(canvasElement.get(), IntRect(0, 0, canvasElement->width(), canvasElement->he ight()));
216 imageBitmapDerived = ImageBitmap::create(imageBitmapFromCanvas.get(), In tRect(0, 0, 20, 20)); 210 imageBitmapDerived = ImageBitmap::create(imageBitmapFromCanvas.get(), In tRect(0, 0, 20, 20));
217 } 211 }
218 CanvasRenderingContext* context = canvasElement->getContext("2d"); 212 CanvasRenderingContext* context = canvasElement->getContext("2d");
219 TrackExceptionState exceptionState; 213 TrackExceptionState exceptionState;
220 toCanvasRenderingContext2D(context)->drawImage(imageBitmapDerived.get(), 0, 0, exceptionState); 214 toCanvasRenderingContext2D(context)->drawImage(imageBitmapDerived.get(), 0, 0, exceptionState);
221 } 215 }
222 216
223 } // namespace 217 } // namespace
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698