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

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

Issue 2290903002: Change (Pass)RefPtr<SkXxx> into sk_sp<SkXxx>. (Closed)
Patch Set: Rebasing... Created 4 years, 3 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
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "third_party/skia/include/core/SkSurface.h" 47 #include "third_party/skia/include/core/SkSurface.h"
48 48
49 namespace blink { 49 namespace blink {
50 50
51 class ImageBitmapTest : public ::testing::Test { 51 class ImageBitmapTest : public ::testing::Test {
52 protected: 52 protected:
53 virtual void SetUp() 53 virtual void SetUp()
54 { 54 {
55 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(10, 10); 55 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(10, 10);
56 surface->getCanvas()->clear(0xFFFFFFFF); 56 surface->getCanvas()->clear(0xFFFFFFFF);
57 m_image = fromSkSp(surface->makeImageSnapshot()); 57 m_image = surface->makeImageSnapshot();
58 58
59 sk_sp<SkSurface> surface2 = SkSurface::MakeRasterN32Premul(5, 5); 59 sk_sp<SkSurface> surface2 = SkSurface::MakeRasterN32Premul(5, 5);
60 surface2->getCanvas()->clear(0xAAAAAAAA); 60 surface2->getCanvas()->clear(0xAAAAAAAA);
61 m_image2 = fromSkSp(surface2->makeImageSnapshot()); 61 m_image2 = surface2->makeImageSnapshot();
62 62
63 // Save the global memory cache to restore it upon teardown. 63 // Save the global memory cache to restore it upon teardown.
64 m_globalMemoryCache = replaceMemoryCacheForTesting(MemoryCache::create() ); 64 m_globalMemoryCache = replaceMemoryCacheForTesting(MemoryCache::create() );
65 } 65 }
66 virtual void TearDown() 66 virtual void TearDown()
67 { 67 {
68 // Garbage collection is required prior to switching out the 68 // Garbage collection is required prior to switching out the
69 // test's memory cache; image resources are released, evicting 69 // test's memory cache; image resources are released, evicting
70 // them from the cache. 70 // them from the cache.
71 ThreadHeap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWi thSweep, BlinkGC::ForcedGC); 71 ThreadHeap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWi thSweep, BlinkGC::ForcedGC);
72 72
73 replaceMemoryCacheForTesting(m_globalMemoryCache.release()); 73 replaceMemoryCacheForTesting(m_globalMemoryCache.release());
74 } 74 }
75 75
76 RefPtr<SkImage> m_image, m_image2; 76 sk_sp<SkImage> m_image, m_image2;
77 Persistent<MemoryCache> m_globalMemoryCache; 77 Persistent<MemoryCache> m_globalMemoryCache;
78 }; 78 };
79 79
80 TEST_F(ImageBitmapTest, ImageResourceConsistency) 80 TEST_F(ImageBitmapTest, ImageResourceConsistency)
81 { 81 {
82 const ImageBitmapOptions defaultOptions; 82 const ImageBitmapOptions defaultOptions;
83 HTMLImageElement* imageElement = HTMLImageElement::create(*Document::create( )); 83 HTMLImageElement* imageElement = HTMLImageElement::create(*Document::create( ));
84 ImageResource* image = ImageResource::create(StaticBitmapImage::create(m_ima ge).get()); 84 ImageResource* image = ImageResource::create(StaticBitmapImage::create(m_ima ge).get());
85 imageElement->setImageResource(image); 85 imageElement->setImageResource(image);
86 86
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 ASSERT_NE(imageBitmap->bitmapImage()->imageForCurrentFrame(), newImageRe source->getImage()->imageForCurrentFrame()); 137 ASSERT_NE(imageBitmap->bitmapImage()->imageForCurrentFrame(), newImageRe source->getImage()->imageForCurrentFrame());
138 SkImage* image1 = imageBitmap->bitmapImage()->imageForCurrentFrame().get (); 138 SkImage* image1 = imageBitmap->bitmapImage()->imageForCurrentFrame().get ();
139 ASSERT_NE(image1, nullptr); 139 ASSERT_NE(image1, nullptr);
140 SkImage* image2 = newImageResource->getImage()->imageForCurrentFrame().g et(); 140 SkImage* image2 = newImageResource->getImage()->imageForCurrentFrame().g et();
141 ASSERT_NE(image2, nullptr); 141 ASSERT_NE(image2, nullptr);
142 ASSERT_NE(image1, image2); 142 ASSERT_NE(image1, image2);
143 } 143 }
144 } 144 }
145 145
146 } // namespace blink 146 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/ImageBitmap.cpp ('k') | third_party/WebKit/Source/core/frame/LocalFrame.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698