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

Side by Side Diff: Source/core/platform/graphics/chromium/ImageFrameGeneratorTest.cpp

Issue 23068027: Animated WebP: Optimize decoding in case of seeking (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@add_noblend_image
Patch Set: Fix assert fail on debug Created 7 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) 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 class ImageFrameGeneratorTest : public ::testing::Test, public MockImageDecoderC lient { 65 class ImageFrameGeneratorTest : public ::testing::Test, public MockImageDecoderC lient {
66 public: 66 public:
67 virtual void SetUp() 67 virtual void SetUp()
68 { 68 {
69 ImageDecodingStore::initializeOnce(); 69 ImageDecodingStore::initializeOnce();
70 m_data = SharedBuffer::create(); 70 m_data = SharedBuffer::create();
71 m_generator = ImageFrameGenerator::create(fullSize(), m_data, true); 71 m_generator = ImageFrameGenerator::create(fullSize(), m_data, true);
72 m_generator->setImageDecoderFactoryForTesting(MockImageDecoderFactory::c reate(this)); 72 m_generator->setImageDecoderFactoryForTesting(MockImageDecoderFactory::c reate(this));
73 m_decodersDestroyed = 0; 73 m_decodersDestroyed = 0;
74 m_frameBufferRequestCount = 0; 74 m_frameBufferRequestCount = 0;
75 m_frameStatus = ImageFrame::FrameEmpty; 75 m_status = ImageFrame::FrameEmpty;
76 } 76 }
77 77
78 virtual void TearDown() 78 virtual void TearDown()
79 { 79 {
80 ImageDecodingStore::shutdown(); 80 ImageDecodingStore::shutdown();
81 } 81 }
82 82
83 virtual void decoderBeingDestroyed() 83 virtual void decoderBeingDestroyed()
84 { 84 {
85 ++m_decodersDestroyed; 85 ++m_decodersDestroyed;
86 } 86 }
87 87
88 virtual void frameBufferRequested() 88 virtual void frameBufferRequested()
89 { 89 {
90 ++m_frameBufferRequestCount; 90 ++m_frameBufferRequestCount;
91 } 91 }
92 92
93 virtual ImageFrame::FrameStatus frameStatus() 93 virtual ImageFrame::Status status()
94 { 94 {
95 ImageFrame::FrameStatus currentStatus = m_frameStatus; 95 ImageFrame::Status currentStatus = m_status;
96 m_frameStatus = m_nextFrameStatus; 96 m_status = m_nextFrameStatus;
97 return currentStatus; 97 return currentStatus;
98 } 98 }
99 99
100 virtual size_t frameCount() { return 1; } 100 virtual size_t frameCount() { return 1; }
101 virtual int repetitionCount() const { return cAnimationNone; } 101 virtual int repetitionCount() const { return cAnimationNone; }
102 virtual float frameDuration() const { return 0; } 102 virtual float frameDuration() const { return 0; }
103 103
104 protected: 104 protected:
105 PassOwnPtr<ScaledImageFragment> createCompleteImage(const SkISize& size) 105 PassOwnPtr<ScaledImageFragment> createCompleteImage(const SkISize& size)
106 { 106 {
107 SkBitmap bitmap; 107 SkBitmap bitmap;
108 bitmap.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height( )); 108 bitmap.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height( ));
109 bitmap.allocPixels(); 109 bitmap.allocPixels();
110 return ScaledImageFragment::createComplete(size, 0, bitmap); 110 return ScaledImageFragment::createComplete(size, 0, bitmap);
111 } 111 }
112 112
113 void addNewData() 113 void addNewData()
114 { 114 {
115 m_data->append("g", 1); 115 m_data->append("g", 1);
116 m_generator->setData(m_data, false); 116 m_generator->setData(m_data, false);
117 } 117 }
118 118
119 void setFrameStatus(ImageFrame::FrameStatus status) { m_frameStatus = m_nex tFrameStatus = status; } 119 void setFrameStatus(ImageFrame::Status status) { m_status = m_nextFrameStat us = status; }
120 void setNextFrameStatus(ImageFrame::FrameStatus status) { m_nextFrameStatus = status; } 120 void setNextFrameStatus(ImageFrame::Status status) { m_nextFrameStatus = st atus; }
121 121
122 RefPtr<SharedBuffer> m_data; 122 RefPtr<SharedBuffer> m_data;
123 RefPtr<ImageFrameGenerator> m_generator; 123 RefPtr<ImageFrameGenerator> m_generator;
124 int m_decodersDestroyed; 124 int m_decodersDestroyed;
125 int m_frameBufferRequestCount; 125 int m_frameBufferRequestCount;
126 ImageFrame::FrameStatus m_frameStatus; 126 ImageFrame::Status m_status;
127 ImageFrame::FrameStatus m_nextFrameStatus; 127 ImageFrame::Status m_nextFrameStatus;
128 }; 128 };
129 129
130 PassOwnPtr<ImageDecoder> MockImageDecoderFactory::create() 130 PassOwnPtr<ImageDecoder> MockImageDecoderFactory::create()
131 { 131 {
132 OwnPtr<MockImageDecoder> decoder = MockImageDecoder::create(m_test); 132 OwnPtr<MockImageDecoder> decoder = MockImageDecoder::create(m_test);
133 decoder->setSize(fullSize().width(), fullSize().height()); 133 decoder->setSize(fullSize().width(), fullSize().height());
134 decoder->setFrameHasAlpha(false); 134 decoder->setFrameHasAlpha(false);
135 return decoder.release(); 135 return decoder.release();
136 } 136 }
137 137
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 ASSERT_TRUE(tempDecoder); 422 ASSERT_TRUE(tempDecoder);
423 static_cast<MockImageDecoder*>(tempDecoder)->setFrameHasAlpha(false); 423 static_cast<MockImageDecoder*>(tempDecoder)->setFrameHasAlpha(false);
424 ImageDecodingStore::instance()->unlockDecoder(m_generator.get(), tempDecoder ); 424 ImageDecodingStore::instance()->unlockDecoder(m_generator.get(), tempDecoder );
425 425
426 setFrameStatus(ImageFrame::FrameComplete); 426 setFrameStatus(ImageFrame::FrameComplete);
427 ImageDecodingStore::instance()->unlockCache(m_generator.get(), m_generator-> decodeAndScale(fullSize(), 1)); 427 ImageDecodingStore::instance()->unlockCache(m_generator.get(), m_generator-> decodeAndScale(fullSize(), 1));
428 EXPECT_FALSE(m_generator->hasAlpha(1)); 428 EXPECT_FALSE(m_generator->hasAlpha(1));
429 } 429 }
430 430
431 } // namespace 431 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698