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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/ImageFrameGeneratorTest.cpp

Issue 2787053004: Respect colorSpace in DecodingImageGenerator::onGetPixels() (Closed)
Patch Set: Response to comments Created 3 years, 8 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 kOpaque_SkAlphaType); 52 kOpaque_SkAlphaType);
53 } 53 }
54 54
55 } // namespace 55 } // namespace
56 56
57 class ImageFrameGeneratorTest : public ::testing::Test, 57 class ImageFrameGeneratorTest : public ::testing::Test,
58 public MockImageDecoderClient { 58 public MockImageDecoderClient {
59 public: 59 public:
60 void SetUp() override { 60 void SetUp() override {
61 ImageDecodingStore::instance().setCacheLimitInBytes(1024 * 1024); 61 ImageDecodingStore::instance().setCacheLimitInBytes(1024 * 1024);
62 m_generator = 62 m_generator = ImageFrameGenerator::create(imageInfo(), false,
63 ImageFrameGenerator::create(fullSize(), false, ColorBehavior::ignore()); 63 ColorBehavior::ignore());
64 m_data = SharedBuffer::create(); 64 m_data = SharedBuffer::create();
65 m_segmentReader = SegmentReader::createFromSharedBuffer(m_data); 65 m_segmentReader = SegmentReader::createFromSharedBuffer(m_data);
66 useMockImageDecoderFactory(); 66 useMockImageDecoderFactory();
67 m_decodersDestroyed = 0; 67 m_decodersDestroyed = 0;
68 m_decodeRequestCount = 0; 68 m_decodeRequestCount = 0;
69 m_status = ImageFrame::FrameEmpty; 69 m_status = ImageFrame::FrameEmpty;
70 m_frameCount = 1; 70 m_frameCount = 1;
71 m_requestedClearExceptFrame = kNotFound; 71 m_requestedClearExceptFrame = kNotFound;
72 } 72 }
73 73
(...skipping 30 matching lines...) Expand all
104 void setFrameStatus(ImageFrame::Status status) { 104 void setFrameStatus(ImageFrame::Status status) {
105 m_status = m_nextFrameStatus = status; 105 m_status = m_nextFrameStatus = status;
106 } 106 }
107 void setNextFrameStatus(ImageFrame::Status status) { 107 void setNextFrameStatus(ImageFrame::Status status) {
108 m_nextFrameStatus = status; 108 m_nextFrameStatus = status;
109 } 109 }
110 void setFrameCount(size_t count) { 110 void setFrameCount(size_t count) {
111 m_frameCount = count; 111 m_frameCount = count;
112 if (count > 1) { 112 if (count > 1) {
113 m_generator.clear(); 113 m_generator.clear();
114 m_generator = ImageFrameGenerator::create(fullSize(), true, 114 m_generator = ImageFrameGenerator::create(imageInfo(), true,
115 ColorBehavior::ignore()); 115 ColorBehavior::ignore());
116 useMockImageDecoderFactory(); 116 useMockImageDecoderFactory();
117 } 117 }
118 } 118 }
119 119
120 RefPtr<SharedBuffer> m_data; 120 RefPtr<SharedBuffer> m_data;
121 RefPtr<SegmentReader> m_segmentReader; 121 RefPtr<SegmentReader> m_segmentReader;
122 RefPtr<ImageFrameGenerator> m_generator; 122 RefPtr<ImageFrameGenerator> m_generator;
123 int m_decodersDestroyed; 123 int m_decodersDestroyed;
124 int m_decodeRequestCount; 124 int m_decodeRequestCount;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 setFrameStatus(ImageFrame::FramePartial); 209 setFrameStatus(ImageFrame::FramePartial);
210 210
211 char buffer[100 * 100 * 4]; 211 char buffer[100 * 100 * 4];
212 m_generator->decodeAndScale(m_segmentReader.get(), false, 0, imageInfo(), 212 m_generator->decodeAndScale(m_segmentReader.get(), false, 0, imageInfo(),
213 buffer, 100 * 4); 213 buffer, 100 * 4);
214 EXPECT_TRUE(m_generator->hasAlpha(0)); 214 EXPECT_TRUE(m_generator->hasAlpha(0));
215 EXPECT_EQ(1, m_decodeRequestCount); 215 EXPECT_EQ(1, m_decodeRequestCount);
216 216
217 ImageDecoder* tempDecoder = 0; 217 ImageDecoder* tempDecoder = 0;
218 EXPECT_TRUE(ImageDecodingStore::instance().lockDecoder( 218 EXPECT_TRUE(ImageDecodingStore::instance().lockDecoder(
219 m_generator.get(), fullSize(), &tempDecoder)); 219 m_generator.get(), fullSize(), ImageDecoder::AlphaPremultiplied,
220 &tempDecoder));
220 ASSERT_TRUE(tempDecoder); 221 ASSERT_TRUE(tempDecoder);
221 tempDecoder->frameBufferAtIndex(0)->setHasAlpha(false); 222 tempDecoder->frameBufferAtIndex(0)->setHasAlpha(false);
222 ImageDecodingStore::instance().unlockDecoder(m_generator.get(), tempDecoder); 223 ImageDecodingStore::instance().unlockDecoder(m_generator.get(), tempDecoder);
223 EXPECT_EQ(2, m_decodeRequestCount); 224 EXPECT_EQ(2, m_decodeRequestCount);
224 225
225 setFrameStatus(ImageFrame::FrameComplete); 226 setFrameStatus(ImageFrame::FrameComplete);
226 m_generator->decodeAndScale(m_segmentReader.get(), false, 0, imageInfo(), 227 m_generator->decodeAndScale(m_segmentReader.get(), false, 0, imageInfo(),
227 buffer, 100 * 4); 228 buffer, 100 * 4);
228 EXPECT_EQ(3, m_decodeRequestCount); 229 EXPECT_EQ(3, m_decodeRequestCount);
229 EXPECT_FALSE(m_generator->hasAlpha(0)); 230 EXPECT_FALSE(m_generator->hasAlpha(0));
(...skipping 24 matching lines...) Expand all
254 // all the frame data, but not destroying the decoder. See comments in 255 // all the frame data, but not destroying the decoder. See comments in
255 // ImageFrameGenerator::tryToResumeDecode(). 256 // ImageFrameGenerator::tryToResumeDecode().
256 m_generator->decodeAndScale(m_segmentReader.get(), true, 2, imageInfo(), 257 m_generator->decodeAndScale(m_segmentReader.get(), true, 2, imageInfo(),
257 buffer, 100 * 4); 258 buffer, 100 * 4);
258 EXPECT_EQ(3, m_decodeRequestCount); 259 EXPECT_EQ(3, m_decodeRequestCount);
259 EXPECT_EQ(0, m_decodersDestroyed); 260 EXPECT_EQ(0, m_decodersDestroyed);
260 EXPECT_EQ(kNotFound, m_requestedClearExceptFrame); 261 EXPECT_EQ(kNotFound, m_requestedClearExceptFrame);
261 } 262 }
262 263
263 } // namespace blink 264 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698