| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "public/web/WebImageDecoder.h" | 31 #include "public/web/WebImageDecoder.h" |
| 32 | 32 |
| 33 #include "platform/SharedBuffer.h" | 33 #include "platform/SharedBuffer.h" |
| 34 #include "platform/image-decoders/bmp/BMPImageDecoder.h" | 34 #include "platform/image-decoders/ImageDecoder.h" |
| 35 #include "platform/image-decoders/ico/ICOImageDecoder.h" | |
| 36 #include "platform/wtf/PassRefPtr.h" | 35 #include "platform/wtf/PassRefPtr.h" |
| 37 #include "public/platform/Platform.h" | 36 #include "public/platform/Platform.h" |
| 38 #include "public/platform/WebData.h" | 37 #include "public/platform/WebData.h" |
| 39 #include "public/platform/WebImage.h" | 38 #include "public/platform/WebImage.h" |
| 40 #include "public/platform/WebSize.h" | 39 #include "public/platform/WebSize.h" |
| 41 | 40 |
| 42 namespace blink { | 41 namespace blink { |
| 43 | 42 |
| 44 void WebImageDecoder::Reset() { | 43 void WebImageDecoder::Reset() { |
| 45 delete private_; | 44 delete private_; |
| 46 } | 45 } |
| 47 | 46 |
| 48 void WebImageDecoder::Init(Type type) { | 47 void WebImageDecoder::Init(Type type) { |
| 48 #if 0 |
| 49 size_t max_decoded_bytes = Platform::Current()->MaxDecodedImageBytes(); | 49 size_t max_decoded_bytes = Platform::Current()->MaxDecodedImageBytes(); |
| 50 | 50 |
| 51 switch (type) { | 51 private_ = new ImageDecoder( |
| 52 case kTypeBMP: | |
| 53 private_ = new BMPImageDecoder( | |
| 54 ImageDecoder::kAlphaPremultiplied, | 52 ImageDecoder::kAlphaPremultiplied, |
| 55 ColorBehavior::TransformToTargetForTesting(), max_decoded_bytes); | 53 ColorBehavior::TransformToTargetForTesting(), max_decoded_bytes); |
| 56 break; | 54 #endif |
| 57 case kTypeICO: | |
| 58 private_ = new ICOImageDecoder( | |
| 59 ImageDecoder::kAlphaPremultiplied, | |
| 60 ColorBehavior::TransformToTargetForTesting(), max_decoded_bytes); | |
| 61 break; | |
| 62 } | |
| 63 } | 55 } |
| 64 | 56 |
| 65 void WebImageDecoder::SetData(const WebData& data, bool all_data_received) { | 57 void WebImageDecoder::SetData(const WebData& data, bool all_data_received) { |
| 66 DCHECK(private_); | 58 DCHECK(private_); |
| 67 private_->SetData(PassRefPtr<SharedBuffer>(data).Get(), all_data_received); | 59 private_->SetData(PassRefPtr<SharedBuffer>(data).Get(), all_data_received); |
| 68 } | 60 } |
| 69 | 61 |
| 70 bool WebImageDecoder::IsFailed() const { | 62 bool WebImageDecoder::IsFailed() const { |
| 71 DCHECK(private_); | 63 DCHECK(private_); |
| 72 return private_->Failed(); | 64 return private_->Failed(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 97 | 89 |
| 98 WebImage WebImageDecoder::GetFrameAtIndex(int index = 0) const { | 90 WebImage WebImageDecoder::GetFrameAtIndex(int index = 0) const { |
| 99 DCHECK(private_); | 91 DCHECK(private_); |
| 100 ImageFrame* const frame_buffer = private_->FrameBufferAtIndex(index); | 92 ImageFrame* const frame_buffer = private_->FrameBufferAtIndex(index); |
| 101 if (!frame_buffer) | 93 if (!frame_buffer) |
| 102 return WebImage(); | 94 return WebImage(); |
| 103 return WebImage(frame_buffer->Bitmap()); | 95 return WebImage(frame_buffer->Bitmap()); |
| 104 } | 96 } |
| 105 | 97 |
| 106 } // namespace blink | 98 } // namespace blink |
| OLD | NEW |