| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 index = i; // Closer to desired area than previous best match. | 72 index = i; // Closer to desired area than previous best match. |
| 73 frameAreaAtIndex = frameArea; | 73 frameAreaAtIndex = frameArea; |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 | 76 |
| 77 ImageFrame* frame = decoder->frameBufferAtIndex(index); | 77 ImageFrame* frame = decoder->frameBufferAtIndex(index); |
| 78 return (frame && !decoder->failed()) ? WebImage(frame->bitmap()) : WebImage(); | 78 return (frame && !decoder->failed()) ? WebImage(frame->bitmap()) : WebImage(); |
| 79 } | 79 } |
| 80 | 80 |
| 81 WebVector<WebImage> WebImage::framesFromData(const WebData& data) { | 81 WebVector<WebImage> WebImage::framesFromData(const WebData& data) { |
| 82 // This is to protect from malicious images. It should be big enough that it's
never hit in pracice. | 82 // This is to protect from malicious images. It should be big enough that it's |
| 83 // never hit in practice. |
| 83 const size_t maxFrameCount = 8; | 84 const size_t maxFrameCount = 8; |
| 84 | 85 |
| 85 RefPtr<SharedBuffer> buffer = PassRefPtr<SharedBuffer>(data); | 86 RefPtr<SharedBuffer> buffer = PassRefPtr<SharedBuffer>(data); |
| 86 std::unique_ptr<ImageDecoder> decoder( | 87 std::unique_ptr<ImageDecoder> decoder( |
| 87 ImageDecoder::create(buffer, true, ImageDecoder::AlphaPremultiplied, | 88 ImageDecoder::create(buffer, true, ImageDecoder::AlphaPremultiplied, |
| 88 ImageDecoder::GammaAndColorProfileIgnored)); | 89 ImageDecoder::GammaAndColorProfileIgnored)); |
| 89 if (!decoder || !decoder->isSizeAvailable()) | 90 if (!decoder || !decoder->isSizeAvailable()) |
| 90 return WebVector<WebImage>(); | 91 return WebVector<WebImage>(); |
| 91 | 92 |
| 92 // Frames are arranged by decreasing size, then decreasing bit depth. | 93 // Frames are arranged by decreasing size, then decreasing bit depth. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 | 132 |
| 132 WebImage::WebImage(PassRefPtr<Image> image) { | 133 WebImage::WebImage(PassRefPtr<Image> image) { |
| 133 if (!image) | 134 if (!image) |
| 134 return; | 135 return; |
| 135 | 136 |
| 136 if (sk_sp<SkImage> skImage = image->imageForCurrentFrame()) | 137 if (sk_sp<SkImage> skImage = image->imageForCurrentFrame()) |
| 137 skImage->asLegacyBitmap(&m_bitmap, SkImage::kRO_LegacyBitmapMode); | 138 skImage->asLegacyBitmap(&m_bitmap, SkImage::kRO_LegacyBitmapMode); |
| 138 } | 139 } |
| 139 | 140 |
| 140 } // namespace blink | 141 } // namespace blink |
| OLD | NEW |