Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 ALLOW_UNUSED = ImageBi tmap::create(imageNoCrop.get(), IntRect(0, 0, m_bitmap.width(), m_bitmap.height( ))); |
|
Mads Ager (chromium)
2014/05/19 14:22:47
I wonder if all the ASSERT_EQ should be EXPECT_EQ?
sof
2014/05/19 14:33:29
While ASSERT_EQ() may hide some other, later failu
Mads Ager (chromium)
2014/05/19 15:00:48
I don't really care much about the distinction on
sof
2014/05/19 15:10:10
ok, i see. The variables are unused (imageBitmapNo
Mads Ager (chromium)
2014/05/19 15:15:02
d'oh, yes, I misread that.
That raises another co
sof
2014/05/19 15:17:04
That could be, but the failure reported is outside
| |
| 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 ALLOW_UNUSED = ImageBitmap::create(imageInteriorCrop.get(), IntRect(m_bitmap.width() / 2, m_bit map.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 ALLOW_UNUSED = I mageBitmap::create(imageExteriorCrop.get(), IntRect(-m_bitmap.width() / 2, -m_bi tmap.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 ALLOW_UNUSED = Im ageBitmap::create(imageOutsideCrop.get(), IntRect(-m_bitmap.width(), -m_bitmap.h eight(), m_bitmap.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 | |
| 164 // Stub out references to the ImageBitmaps created and force a | |
| 165 // garbage collection to have the ImageBitmaps be collected and | |
| 166 // destructed. | |
| 167 imageBitmapNoCrop = nullptr; | |
| 168 imageBitmapInteriorCrop2 = nullptr; | |
| 169 imageBitmapExteriorCrop = nullptr; | |
| 170 imageBitmapOutsideCrop = nullptr; | |
| 171 Heap::collectGarbage(ThreadState::HeapPointersOnStack); | |
| 172 } | 163 } |
| 164 // Force a garbage collection to sweep out the local ImageBitmaps. | |
| 165 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); | |
| 173 | 166 |
| 174 // CacheLiveResourcePriroity should return to CacheLiveResourcePriorityLow w hen no ImageBitmaps reference the image. | 167 // CacheLiveResourcePriroity should return to CacheLiveResourcePriorityLow w hen no ImageBitmaps reference the image. |
| 175 ASSERT_EQ(memoryCache()->priority(imageNoCrop->cachedImage()), MemoryCacheLi veResourcePriorityLow); | 168 ASSERT_EQ(memoryCache()->priority(imageNoCrop->cachedImage()), MemoryCacheLi veResourcePriorityLow); |
| 176 ASSERT_EQ(memoryCache()->priority(imageExteriorCrop->cachedImage()), MemoryC acheLiveResourcePriorityLow); | 169 ASSERT_EQ(memoryCache()->priority(imageExteriorCrop->cachedImage()), MemoryC acheLiveResourcePriorityLow); |
| 177 ASSERT_EQ(memoryCache()->priority(imageOutsideCrop->cachedImage()), MemoryCa cheLiveResourcePriorityLow); | 170 ASSERT_EQ(memoryCache()->priority(imageOutsideCrop->cachedImage()), MemoryCa cheLiveResourcePriorityLow); |
| 178 | 171 |
| 179 // There is still an ImageBitmap that references this image. | 172 // There is still an ImageBitmap that references this image. |
| 180 ASSERT_EQ(memoryCache()->priority(imageInteriorCrop->cachedImage()), MemoryC acheLiveResourcePriorityHigh); | 173 ASSERT_EQ(memoryCache()->priority(imageInteriorCrop->cachedImage()), MemoryC acheLiveResourcePriorityHigh); |
| 181 imageBitmapInteriorCrop = nullptr; | 174 imageBitmapInteriorCrop = nullptr; |
| 182 } | 175 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 214 { | 207 { |
| 215 RefPtrWillBeRawPtr<ImageBitmap> imageBitmapFromCanvas = ImageBitmap::cre ate(canvasElement.get(), IntRect(0, 0, canvasElement->width(), canvasElement->he ight())); | 208 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)); | 209 imageBitmapDerived = ImageBitmap::create(imageBitmapFromCanvas.get(), In tRect(0, 0, 20, 20)); |
| 217 } | 210 } |
| 218 CanvasRenderingContext* context = canvasElement->getContext("2d"); | 211 CanvasRenderingContext* context = canvasElement->getContext("2d"); |
| 219 TrackExceptionState exceptionState; | 212 TrackExceptionState exceptionState; |
| 220 toCanvasRenderingContext2D(context)->drawImage(imageBitmapDerived.get(), 0, 0, exceptionState); | 213 toCanvasRenderingContext2D(context)->drawImage(imageBitmapDerived.get(), 0, 0, exceptionState); |
| 221 } | 214 } |
| 222 | 215 |
| 223 } // namespace | 216 } // namespace |
| OLD | NEW |