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

Side by Side Diff: Source/web/tests/DeferredImageDecoderTest.cpp

Issue 105003005: Revert of Teach Skia to use discardable memory (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « Source/platform/graphics/ImageFrameGenerator.cpp ('k') | 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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 m_canvas->drawPicture(m_picture); 169 m_canvas->drawPicture(m_picture);
170 EXPECT_EQ(0, m_frameBufferRequestCount); 170 EXPECT_EQ(0, m_frameBufferRequestCount);
171 171
172 SkBitmap canvasBitmap; 172 SkBitmap canvasBitmap;
173 canvasBitmap.setConfig(SkBitmap::kARGB_8888_Config, 100, 100); 173 canvasBitmap.setConfig(SkBitmap::kARGB_8888_Config, 100, 100);
174 ASSERT_TRUE(m_canvas->readPixels(&canvasBitmap, 0, 0)); 174 ASSERT_TRUE(m_canvas->readPixels(&canvasBitmap, 0, 0));
175 SkAutoLockPixels autoLock(canvasBitmap); 175 SkAutoLockPixels autoLock(canvasBitmap);
176 EXPECT_EQ(SkColorSetARGB(255, 255, 255, 255), canvasBitmap.getColor(0, 0)); 176 EXPECT_EQ(SkColorSetARGB(255, 255, 255, 255), canvasBitmap.getColor(0, 0));
177 } 177 }
178 178
179 TEST_F(DeferredImageDecoderTest, drawDiscardableIntoSkPicture)
180 {
181 DeferredImageDecoder::setSkiaDiscardableMemoryEnabled(true);
182
183 m_lazyDecoder->setData(m_data.get(), true);
184 RefPtr<NativeImageSkia> image = m_lazyDecoder->frameBufferAtIndex(0)->asNewN ativeImage();
185 EXPECT_EQ(1, image->bitmap().width());
186 EXPECT_EQ(1, image->bitmap().height());
187 EXPECT_FALSE(image->bitmap().isNull());
188 EXPECT_TRUE(image->bitmap().isImmutable());
189
190 SkCanvas* tempCanvas = m_picture.beginRecording(100, 100);
191 tempCanvas->drawBitmap(image->bitmap(), 0, 0);
192 m_picture.endRecording();
193 EXPECT_EQ(0, m_frameBufferRequestCount);
194
195 m_canvas->drawPicture(m_picture);
196 EXPECT_EQ(0, m_frameBufferRequestCount);
197
198 SkBitmap canvasBitmap;
199 canvasBitmap.setConfig(SkBitmap::kARGB_8888_Config, 100, 100);
200 ASSERT_TRUE(m_canvas->readPixels(&canvasBitmap, 0, 0));
201 SkAutoLockPixels autoLock(canvasBitmap);
202 EXPECT_EQ(SkColorSetARGB(255, 255, 255, 255), canvasBitmap.getColor(0, 0));
203
204 DeferredImageDecoder::setSkiaDiscardableMemoryEnabled(false);
205 }
206
207 TEST_F(DeferredImageDecoderTest, DISABLED_drawScaledIntoSkPicture) 179 TEST_F(DeferredImageDecoderTest, DISABLED_drawScaledIntoSkPicture)
208 { 180 {
209 m_lazyDecoder->setData(m_data.get(), true); 181 m_lazyDecoder->setData(m_data.get(), true);
210 RefPtr<NativeImageSkia> image = m_lazyDecoder->frameBufferAtIndex(0)->asNewN ativeImage(); 182 RefPtr<NativeImageSkia> image = m_lazyDecoder->frameBufferAtIndex(0)->asNewN ativeImage();
211 SkBitmap scaledBitmap = image->resizedBitmap(SkISize::Make(50, 51), SkIRect: :MakeWH(50, 51)); 183 SkBitmap scaledBitmap = image->resizedBitmap(SkISize::Make(50, 51), SkIRect: :MakeWH(50, 51));
212 EXPECT_FALSE(scaledBitmap.isNull()); 184 EXPECT_FALSE(scaledBitmap.isNull());
213 EXPECT_TRUE(scaledBitmap.isImmutable()); 185 EXPECT_TRUE(scaledBitmap.isImmutable());
214 EXPECT_EQ(50, scaledBitmap.width()); 186 EXPECT_EQ(50, scaledBitmap.width());
215 EXPECT_EQ(51, scaledBitmap.height()); 187 EXPECT_EQ(51, scaledBitmap.height());
216 EXPECT_EQ(0, m_frameBufferRequestCount); 188 EXPECT_EQ(0, m_frameBufferRequestCount);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 // The following code should not fail any assert. 313 // The following code should not fail any assert.
342 SkCanvas* tempCanvas = m_picture.beginRecording(100, 100); 314 SkCanvas* tempCanvas = m_picture.beginRecording(100, 100);
343 tempCanvas->drawBitmap(image->bitmap(), 0, 0); 315 tempCanvas->drawBitmap(image->bitmap(), 0, 0);
344 m_picture.endRecording(); 316 m_picture.endRecording();
345 EXPECT_EQ(0, m_frameBufferRequestCount); 317 EXPECT_EQ(0, m_frameBufferRequestCount);
346 m_canvas->drawPicture(m_picture); 318 m_canvas->drawPicture(m_picture);
347 EXPECT_EQ(1, m_frameBufferRequestCount); 319 EXPECT_EQ(1, m_frameBufferRequestCount);
348 } 320 }
349 321
350 } // namespace WebCore 322 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/platform/graphics/ImageFrameGenerator.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698