| OLD | NEW |
| 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 CrossThreadBind(&RasterizeMain, CrossThreadUnretained(canvas_.get()), | 226 CrossThreadBind(&RasterizeMain, CrossThreadUnretained(canvas_.get()), |
| 227 record)); | 227 record)); |
| 228 thread.reset(); | 228 thread.reset(); |
| 229 EXPECT_EQ(0, decode_request_count_); | 229 EXPECT_EQ(0, decode_request_count_); |
| 230 EXPECT_EQ(SkColorSetARGB(255, 255, 255, 255), bitmap_.getColor(0, 0)); | 230 EXPECT_EQ(SkColorSetARGB(255, 255, 255, 255), bitmap_.getColor(0, 0)); |
| 231 } | 231 } |
| 232 | 232 |
| 233 TEST_F(DeferredImageDecoderTest, singleFrameImageLoading) { | 233 TEST_F(DeferredImageDecoderTest, singleFrameImageLoading) { |
| 234 status_ = ImageFrame::kFramePartial; | 234 status_ = ImageFrame::kFramePartial; |
| 235 lazy_decoder_->SetData(data_, false); | 235 lazy_decoder_->SetData(data_, false); |
| 236 EXPECT_FALSE(lazy_decoder_->FrameIsCompleteAtIndex(0)); | 236 EXPECT_FALSE(lazy_decoder_->FrameIsReceivedAtIndex(0)); |
| 237 sk_sp<SkImage> image = lazy_decoder_->CreateFrameAtIndex(0); | 237 sk_sp<SkImage> image = lazy_decoder_->CreateFrameAtIndex(0); |
| 238 ASSERT_TRUE(image); | 238 ASSERT_TRUE(image); |
| 239 unsigned first_id = image->uniqueID(); | 239 unsigned first_id = image->uniqueID(); |
| 240 EXPECT_FALSE(lazy_decoder_->FrameIsCompleteAtIndex(0)); | 240 EXPECT_FALSE(lazy_decoder_->FrameIsReceivedAtIndex(0)); |
| 241 EXPECT_TRUE(actual_decoder_); | 241 EXPECT_TRUE(actual_decoder_); |
| 242 | 242 |
| 243 status_ = ImageFrame::kFrameComplete; | 243 status_ = ImageFrame::kFrameComplete; |
| 244 data_->Append(" ", 1u); | 244 data_->Append(" ", 1u); |
| 245 lazy_decoder_->SetData(data_, true); | 245 lazy_decoder_->SetData(data_, true); |
| 246 EXPECT_FALSE(actual_decoder_); | 246 EXPECT_FALSE(actual_decoder_); |
| 247 EXPECT_TRUE(lazy_decoder_->FrameIsCompleteAtIndex(0)); | 247 EXPECT_TRUE(lazy_decoder_->FrameIsReceivedAtIndex(0)); |
| 248 | 248 |
| 249 image = lazy_decoder_->CreateFrameAtIndex(0); | 249 image = lazy_decoder_->CreateFrameAtIndex(0); |
| 250 ASSERT_TRUE(image); | 250 ASSERT_TRUE(image); |
| 251 unsigned second_id = image->uniqueID(); | 251 unsigned second_id = image->uniqueID(); |
| 252 EXPECT_FALSE(decode_request_count_); | 252 EXPECT_FALSE(decode_request_count_); |
| 253 EXPECT_NE(first_id, second_id); | 253 EXPECT_NE(first_id, second_id); |
| 254 } | 254 } |
| 255 | 255 |
| 256 TEST_F(DeferredImageDecoderTest, multiFrameImageLoading) { | 256 TEST_F(DeferredImageDecoderTest, multiFrameImageLoading) { |
| 257 repetition_count_ = 10; | 257 repetition_count_ = 10; |
| 258 frame_count_ = 1; | 258 frame_count_ = 1; |
| 259 frame_duration_ = 10; | 259 frame_duration_ = 10; |
| 260 status_ = ImageFrame::kFramePartial; | 260 status_ = ImageFrame::kFramePartial; |
| 261 lazy_decoder_->SetData(data_, false); | 261 lazy_decoder_->SetData(data_, false); |
| 262 | 262 |
| 263 sk_sp<SkImage> image = lazy_decoder_->CreateFrameAtIndex(0); | 263 sk_sp<SkImage> image = lazy_decoder_->CreateFrameAtIndex(0); |
| 264 ASSERT_TRUE(image); | 264 ASSERT_TRUE(image); |
| 265 unsigned first_id = image->uniqueID(); | 265 unsigned first_id = image->uniqueID(); |
| 266 EXPECT_FALSE(lazy_decoder_->FrameIsCompleteAtIndex(0)); | 266 EXPECT_FALSE(lazy_decoder_->FrameIsReceivedAtIndex(0)); |
| 267 EXPECT_EQ(10.0f, lazy_decoder_->FrameDurationAtIndex(0)); | 267 EXPECT_EQ(10.0f, lazy_decoder_->FrameDurationAtIndex(0)); |
| 268 | 268 |
| 269 frame_count_ = 2; | 269 frame_count_ = 2; |
| 270 frame_duration_ = 20; | 270 frame_duration_ = 20; |
| 271 status_ = ImageFrame::kFrameComplete; | 271 status_ = ImageFrame::kFrameComplete; |
| 272 data_->Append(" ", 1u); | 272 data_->Append(" ", 1u); |
| 273 lazy_decoder_->SetData(data_, false); | 273 lazy_decoder_->SetData(data_, false); |
| 274 | 274 |
| 275 image = lazy_decoder_->CreateFrameAtIndex(0); | 275 image = lazy_decoder_->CreateFrameAtIndex(0); |
| 276 ASSERT_TRUE(image); | 276 ASSERT_TRUE(image); |
| 277 unsigned second_id = image->uniqueID(); | 277 unsigned second_id = image->uniqueID(); |
| 278 EXPECT_NE(first_id, second_id); | 278 EXPECT_NE(first_id, second_id); |
| 279 EXPECT_TRUE(lazy_decoder_->FrameIsCompleteAtIndex(0)); | 279 EXPECT_TRUE(lazy_decoder_->FrameIsReceivedAtIndex(0)); |
| 280 EXPECT_TRUE(lazy_decoder_->FrameIsCompleteAtIndex(1)); | 280 EXPECT_TRUE(lazy_decoder_->FrameIsReceivedAtIndex(1)); |
| 281 EXPECT_EQ(20.0f, lazy_decoder_->FrameDurationAtIndex(1)); | 281 EXPECT_EQ(20.0f, lazy_decoder_->FrameDurationAtIndex(1)); |
| 282 EXPECT_TRUE(actual_decoder_); | 282 EXPECT_TRUE(actual_decoder_); |
| 283 | 283 |
| 284 frame_count_ = 3; | 284 frame_count_ = 3; |
| 285 frame_duration_ = 30; | 285 frame_duration_ = 30; |
| 286 status_ = ImageFrame::kFrameComplete; | 286 status_ = ImageFrame::kFrameComplete; |
| 287 lazy_decoder_->SetData(data_, true); | 287 lazy_decoder_->SetData(data_, true); |
| 288 EXPECT_FALSE(actual_decoder_); | 288 EXPECT_FALSE(actual_decoder_); |
| 289 EXPECT_TRUE(lazy_decoder_->FrameIsCompleteAtIndex(0)); | 289 EXPECT_TRUE(lazy_decoder_->FrameIsReceivedAtIndex(0)); |
| 290 EXPECT_TRUE(lazy_decoder_->FrameIsCompleteAtIndex(1)); | 290 EXPECT_TRUE(lazy_decoder_->FrameIsReceivedAtIndex(1)); |
| 291 EXPECT_TRUE(lazy_decoder_->FrameIsCompleteAtIndex(2)); | 291 EXPECT_TRUE(lazy_decoder_->FrameIsReceivedAtIndex(2)); |
| 292 EXPECT_EQ(10.0f, lazy_decoder_->FrameDurationAtIndex(0)); | 292 EXPECT_EQ(10.0f, lazy_decoder_->FrameDurationAtIndex(0)); |
| 293 EXPECT_EQ(20.0f, lazy_decoder_->FrameDurationAtIndex(1)); | 293 EXPECT_EQ(20.0f, lazy_decoder_->FrameDurationAtIndex(1)); |
| 294 EXPECT_EQ(30.0f, lazy_decoder_->FrameDurationAtIndex(2)); | 294 EXPECT_EQ(30.0f, lazy_decoder_->FrameDurationAtIndex(2)); |
| 295 EXPECT_EQ(10, lazy_decoder_->RepetitionCount()); | 295 EXPECT_EQ(10, lazy_decoder_->RepetitionCount()); |
| 296 } | 296 } |
| 297 | 297 |
| 298 TEST_F(DeferredImageDecoderTest, decodedSize) { | 298 TEST_F(DeferredImageDecoderTest, decodedSize) { |
| 299 decoded_size_ = IntSize(22, 33); | 299 decoded_size_ = IntSize(22, 33); |
| 300 lazy_decoder_->SetData(data_, true); | 300 lazy_decoder_->SetData(data_, true); |
| 301 sk_sp<SkImage> image = lazy_decoder_->CreateFrameAtIndex(0); | 301 sk_sp<SkImage> image = lazy_decoder_->CreateFrameAtIndex(0); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 lazy_decoder_->SetData(original_buffer, false); | 389 lazy_decoder_->SetData(original_buffer, false); |
| 390 RefPtr<SharedBuffer> new_buffer = lazy_decoder_->Data(); | 390 RefPtr<SharedBuffer> new_buffer = lazy_decoder_->Data(); |
| 391 EXPECT_EQ(original_buffer->size(), new_buffer->size()); | 391 EXPECT_EQ(original_buffer->size(), new_buffer->size()); |
| 392 const Vector<char> original_data = original_buffer->Copy(); | 392 const Vector<char> original_data = original_buffer->Copy(); |
| 393 const Vector<char> new_data = new_buffer->Copy(); | 393 const Vector<char> new_data = new_buffer->Copy(); |
| 394 EXPECT_EQ(0, std::memcmp(original_data.data(), new_data.data(), | 394 EXPECT_EQ(0, std::memcmp(original_data.data(), new_data.data(), |
| 395 new_buffer->size())); | 395 new_buffer->size())); |
| 396 } | 396 } |
| 397 | 397 |
| 398 } // namespace blink | 398 } // namespace blink |
| OLD | NEW |