| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 m_image2 = adoptRef(surface2->newImageSnapshot()); | 65 m_image2 = adoptRef(surface2->newImageSnapshot()); |
| 66 | 66 |
| 67 // Save the global memory cache to restore it upon teardown. | 67 // Save the global memory cache to restore it upon teardown. |
| 68 m_globalMemoryCache = replaceMemoryCacheForTesting(MemoryCache::create()
); | 68 m_globalMemoryCache = replaceMemoryCacheForTesting(MemoryCache::create()
); |
| 69 } | 69 } |
| 70 virtual void TearDown() | 70 virtual void TearDown() |
| 71 { | 71 { |
| 72 // Garbage collection is required prior to switching out the | 72 // Garbage collection is required prior to switching out the |
| 73 // test's memory cache; image resources are released, evicting | 73 // test's memory cache; image resources are released, evicting |
| 74 // them from the cache. | 74 // them from the cache. |
| 75 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GC
WithSweep, Heap::ForcedGC); | 75 Heap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSwee
p, Heap::ForcedGC); |
| 76 | 76 |
| 77 replaceMemoryCacheForTesting(m_globalMemoryCache.release()); | 77 replaceMemoryCacheForTesting(m_globalMemoryCache.release()); |
| 78 } | 78 } |
| 79 | 79 |
| 80 RefPtr<SkImage> m_image, m_image2; | 80 RefPtr<SkImage> m_image, m_image2; |
| 81 Persistent<MemoryCache> m_globalMemoryCache; | 81 Persistent<MemoryCache> m_globalMemoryCache; |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 // Verifies that the image resource held by an ImageBitmap is the same as the | 84 // Verifies that the image resource held by an ImageBitmap is the same as the |
| 85 // one held by the HTMLImageElement. | 85 // one held by the HTMLImageElement. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 | 163 |
| 164 // Images that are referenced by ImageBitmaps have CacheLiveResourcePrio
rityHigh. | 164 // Images that are referenced by ImageBitmaps have CacheLiveResourcePrio
rityHigh. |
| 165 ASSERT_EQ(memoryCache()->priority(imageNoCrop->cachedImage()), MemoryCac
heLiveResourcePriorityHigh); | 165 ASSERT_EQ(memoryCache()->priority(imageNoCrop->cachedImage()), MemoryCac
heLiveResourcePriorityHigh); |
| 166 ASSERT_EQ(memoryCache()->priority(imageInteriorCrop->cachedImage()), Mem
oryCacheLiveResourcePriorityHigh); | 166 ASSERT_EQ(memoryCache()->priority(imageInteriorCrop->cachedImage()), Mem
oryCacheLiveResourcePriorityHigh); |
| 167 ASSERT_EQ(memoryCache()->priority(imageExteriorCrop->cachedImage()), Mem
oryCacheLiveResourcePriorityHigh); | 167 ASSERT_EQ(memoryCache()->priority(imageExteriorCrop->cachedImage()), Mem
oryCacheLiveResourcePriorityHigh); |
| 168 | 168 |
| 169 // ImageBitmaps that do not contain any of the source image do not eleva
te CacheLiveResourcePriority. | 169 // ImageBitmaps that do not contain any of the source image do not eleva
te CacheLiveResourcePriority. |
| 170 ASSERT_EQ(memoryCache()->priority(imageOutsideCrop->cachedImage()), Memo
ryCacheLiveResourcePriorityLow); | 170 ASSERT_EQ(memoryCache()->priority(imageOutsideCrop->cachedImage()), Memo
ryCacheLiveResourcePriorityLow); |
| 171 } | 171 } |
| 172 // Force a garbage collection to sweep out the local ImageBitmaps. | 172 // Force a garbage collection to sweep out the local ImageBitmaps. |
| 173 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GCWith
Sweep, Heap::ForcedGC); | 173 Heap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, H
eap::ForcedGC); |
| 174 | 174 |
| 175 // CacheLiveResourcePriroity should return to CacheLiveResourcePriorityLow w
hen no ImageBitmaps reference the image. | 175 // CacheLiveResourcePriroity should return to CacheLiveResourcePriorityLow w
hen no ImageBitmaps reference the image. |
| 176 ASSERT_EQ(memoryCache()->priority(imageNoCrop->cachedImage()), MemoryCacheLi
veResourcePriorityLow); | 176 ASSERT_EQ(memoryCache()->priority(imageNoCrop->cachedImage()), MemoryCacheLi
veResourcePriorityLow); |
| 177 ASSERT_EQ(memoryCache()->priority(imageExteriorCrop->cachedImage()), MemoryC
acheLiveResourcePriorityLow); | 177 ASSERT_EQ(memoryCache()->priority(imageExteriorCrop->cachedImage()), MemoryC
acheLiveResourcePriorityLow); |
| 178 ASSERT_EQ(memoryCache()->priority(imageOutsideCrop->cachedImage()), MemoryCa
cheLiveResourcePriorityLow); | 178 ASSERT_EQ(memoryCache()->priority(imageOutsideCrop->cachedImage()), MemoryCa
cheLiveResourcePriorityLow); |
| 179 | 179 |
| 180 // There is still an ImageBitmap that references this image. | 180 // There is still an ImageBitmap that references this image. |
| 181 ASSERT_EQ(memoryCache()->priority(imageInteriorCrop->cachedImage()), MemoryC
acheLiveResourcePriorityHigh); | 181 ASSERT_EQ(memoryCache()->priority(imageInteriorCrop->cachedImage()), MemoryC
acheLiveResourcePriorityHigh); |
| 182 imageBitmapInteriorCrop = nullptr; | 182 imageBitmapInteriorCrop = nullptr; |
| 183 } | 183 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 212 ASSERT_NE(imageBitmap->bitmapImage().get(), newImageResource->image()); | 212 ASSERT_NE(imageBitmap->bitmapImage().get(), newImageResource->image()); |
| 213 RefPtr<SkImage> image1 = imageBitmap->bitmapImage()->imageForCurrentFram
e(); | 213 RefPtr<SkImage> image1 = imageBitmap->bitmapImage()->imageForCurrentFram
e(); |
| 214 ASSERT_NE(image1, nullptr); | 214 ASSERT_NE(image1, nullptr); |
| 215 RefPtr<SkImage> image2 = newImageResource->image()->imageForCurrentFrame
(); | 215 RefPtr<SkImage> image2 = newImageResource->image()->imageForCurrentFrame
(); |
| 216 ASSERT_NE(image2, nullptr); | 216 ASSERT_NE(image2, nullptr); |
| 217 ASSERT_NE(image1, image2); | 217 ASSERT_NE(image1, image2); |
| 218 } | 218 } |
| 219 } | 219 } |
| 220 | 220 |
| 221 } // namespace | 221 } // namespace |
| OLD | NEW |