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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 m_bitmap2.eraseColor(0xAAAAAAAA); | 63 m_bitmap2.eraseColor(0xAAAAAAAA); |
64 | 64 |
65 // Save the global memory cache to restore it upon teardown. | 65 // Save the global memory cache to restore it upon teardown. |
66 m_globalMemoryCache = replaceMemoryCacheForTesting(MemoryCache::create()
); | 66 m_globalMemoryCache = replaceMemoryCacheForTesting(MemoryCache::create()
); |
67 } | 67 } |
68 virtual void TearDown() | 68 virtual void TearDown() |
69 { | 69 { |
70 // Garbage collection is required prior to switching out the | 70 // Garbage collection is required prior to switching out the |
71 // test's memory cache; image resources are released, evicting | 71 // test's memory cache; image resources are released, evicting |
72 // them from the cache. | 72 // them from the cache. |
73 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GC
WithSweep, Heap::ForcedGCForTesting); | 73 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GC
WithSweep, Heap::ForcedGC); |
74 | 74 |
75 replaceMemoryCacheForTesting(m_globalMemoryCache.release()); | 75 replaceMemoryCacheForTesting(m_globalMemoryCache.release()); |
76 } | 76 } |
77 | 77 |
78 SkBitmap m_bitmap, m_bitmap2; | 78 SkBitmap m_bitmap, m_bitmap2; |
79 OwnPtrWillBePersistent<MemoryCache> m_globalMemoryCache; | 79 OwnPtrWillBePersistent<MemoryCache> m_globalMemoryCache; |
80 }; | 80 }; |
81 | 81 |
82 // Verifies that the image resource held by an ImageBitmap is the same as the | 82 // Verifies that the image resource held by an ImageBitmap is the same as the |
83 // one held by the HTMLImageElement. | 83 // one held by the HTMLImageElement. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 | 149 |
150 // Images that are referenced by ImageBitmaps have CacheLiveResourcePrio
rityHigh. | 150 // Images that are referenced by ImageBitmaps have CacheLiveResourcePrio
rityHigh. |
151 ASSERT_EQ(memoryCache()->priority(imageNoCrop->cachedImage()), MemoryCac
heLiveResourcePriorityHigh); | 151 ASSERT_EQ(memoryCache()->priority(imageNoCrop->cachedImage()), MemoryCac
heLiveResourcePriorityHigh); |
152 ASSERT_EQ(memoryCache()->priority(imageInteriorCrop->cachedImage()), Mem
oryCacheLiveResourcePriorityHigh); | 152 ASSERT_EQ(memoryCache()->priority(imageInteriorCrop->cachedImage()), Mem
oryCacheLiveResourcePriorityHigh); |
153 ASSERT_EQ(memoryCache()->priority(imageExteriorCrop->cachedImage()), Mem
oryCacheLiveResourcePriorityHigh); | 153 ASSERT_EQ(memoryCache()->priority(imageExteriorCrop->cachedImage()), Mem
oryCacheLiveResourcePriorityHigh); |
154 | 154 |
155 // ImageBitmaps that do not contain any of the source image do not eleva
te CacheLiveResourcePriority. | 155 // ImageBitmaps that do not contain any of the source image do not eleva
te CacheLiveResourcePriority. |
156 ASSERT_EQ(memoryCache()->priority(imageOutsideCrop->cachedImage()), Memo
ryCacheLiveResourcePriorityLow); | 156 ASSERT_EQ(memoryCache()->priority(imageOutsideCrop->cachedImage()), Memo
ryCacheLiveResourcePriorityLow); |
157 } | 157 } |
158 // Force a garbage collection to sweep out the local ImageBitmaps. | 158 // Force a garbage collection to sweep out the local ImageBitmaps. |
159 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GCWith
Sweep, Heap::ForcedGCForTesting); | 159 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GCWith
Sweep, Heap::ForcedGC); |
160 | 160 |
161 // CacheLiveResourcePriroity should return to CacheLiveResourcePriorityLow w
hen no ImageBitmaps reference the image. | 161 // CacheLiveResourcePriroity should return to CacheLiveResourcePriorityLow w
hen no ImageBitmaps reference the image. |
162 ASSERT_EQ(memoryCache()->priority(imageNoCrop->cachedImage()), MemoryCacheLi
veResourcePriorityLow); | 162 ASSERT_EQ(memoryCache()->priority(imageNoCrop->cachedImage()), MemoryCacheLi
veResourcePriorityLow); |
163 ASSERT_EQ(memoryCache()->priority(imageExteriorCrop->cachedImage()), MemoryC
acheLiveResourcePriorityLow); | 163 ASSERT_EQ(memoryCache()->priority(imageExteriorCrop->cachedImage()), MemoryC
acheLiveResourcePriorityLow); |
164 ASSERT_EQ(memoryCache()->priority(imageOutsideCrop->cachedImage()), MemoryCa
cheLiveResourcePriorityLow); | 164 ASSERT_EQ(memoryCache()->priority(imageOutsideCrop->cachedImage()), MemoryCa
cheLiveResourcePriorityLow); |
165 | 165 |
166 // There is still an ImageBitmap that references this image. | 166 // There is still an ImageBitmap that references this image. |
167 ASSERT_EQ(memoryCache()->priority(imageInteriorCrop->cachedImage()), MemoryC
acheLiveResourcePriorityHigh); | 167 ASSERT_EQ(memoryCache()->priority(imageInteriorCrop->cachedImage()), MemoryC
acheLiveResourcePriorityHigh); |
168 imageBitmapInteriorCrop = nullptr; | 168 imageBitmapInteriorCrop = nullptr; |
169 | 169 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 CanvasContextCreationAttributes attributes; | 213 CanvasContextCreationAttributes attributes; |
214 CanvasRenderingContext2DOrWebGLRenderingContext context; | 214 CanvasRenderingContext2DOrWebGLRenderingContext context; |
215 canvasElement->getContext("2d", attributes, context); | 215 canvasElement->getContext("2d", attributes, context); |
216 TrackExceptionState exceptionState; | 216 TrackExceptionState exceptionState; |
217 CanvasImageSourceUnion imageSource; | 217 CanvasImageSourceUnion imageSource; |
218 imageSource.setImageBitmap(imageBitmapDerived); | 218 imageSource.setImageBitmap(imageBitmapDerived); |
219 context.getAsCanvasRenderingContext2D()->drawImage(imageSource, 0, 0, except
ionState); | 219 context.getAsCanvasRenderingContext2D()->drawImage(imageSource, 0, 0, except
ionState); |
220 } | 220 } |
221 | 221 |
222 } // namespace | 222 } // namespace |
OLD | NEW |