OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. |
3 * Copyright (C) 2007 Alp Toker <alp.toker@collabora.co.uk> | 3 * Copyright (C) 2007 Alp Toker <alp.toker@collabora.co.uk> |
4 * Copyright (C) 2008, Google Inc. All rights reserved. | 4 * Copyright (C) 2008, Google Inc. All rights reserved. |
5 * Copyright (C) 2007-2009 Torch Mobile, Inc | |
6 * | 5 * |
7 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
8 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
9 * are met: | 8 * are met: |
10 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
11 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
12 * 2. Redistributions in binary form must reproduce the above copyright | 11 * 2. Redistributions in binary form must reproduce the above copyright |
13 * notice, this list of conditions and the following disclaimer in the | 12 * notice, this list of conditions and the following disclaimer in the |
14 * documentation and/or other materials provided with the distribution. | 13 * documentation and/or other materials provided with the distribution. |
15 * | 14 * |
(...skipping 16 matching lines...) Expand all Loading... |
32 #include "core/platform/image-decoders/ImageDecoder.h" | 31 #include "core/platform/image-decoders/ImageDecoder.h" |
33 | 32 |
34 #include "core/platform/NotImplemented.h" | 33 #include "core/platform/NotImplemented.h" |
35 #include "core/platform/PlatformMemoryInstrumentation.h" | 34 #include "core/platform/PlatformMemoryInstrumentation.h" |
36 #include "core/platform/graphics/ImageOrientation.h" | 35 #include "core/platform/graphics/ImageOrientation.h" |
37 | 36 |
38 #include "core/platform/graphics/chromium/DeferredImageDecoder.h" | 37 #include "core/platform/graphics/chromium/DeferredImageDecoder.h" |
39 | 38 |
40 namespace WebCore { | 39 namespace WebCore { |
41 | 40 |
42 #if ENABLE(IMAGE_DECODER_DOWN_SAMPLING) | |
43 unsigned ImageSource::s_maxPixelsPerDecodedImage = 1024 * 1024; | |
44 #endif | |
45 | |
46 ImageSource::ImageSource(ImageSource::AlphaOption alphaOption, ImageSource::Gamm
aAndColorProfileOption gammaAndColorProfileOption) | 41 ImageSource::ImageSource(ImageSource::AlphaOption alphaOption, ImageSource::Gamm
aAndColorProfileOption gammaAndColorProfileOption) |
47 : m_alphaOption(alphaOption) | 42 : m_alphaOption(alphaOption) |
48 , m_gammaAndColorProfileOption(gammaAndColorProfileOption) | 43 , m_gammaAndColorProfileOption(gammaAndColorProfileOption) |
49 { | 44 { |
50 } | 45 } |
51 | 46 |
52 ImageSource::~ImageSource() | 47 ImageSource::~ImageSource() |
53 { | 48 { |
54 clear(true); | 49 clear(true); |
55 } | 50 } |
(...skipping 15 matching lines...) Expand all Loading... |
71 { | 66 { |
72 return m_decoder; | 67 return m_decoder; |
73 } | 68 } |
74 | 69 |
75 void ImageSource::setData(SharedBuffer* data, bool allDataReceived) | 70 void ImageSource::setData(SharedBuffer* data, bool allDataReceived) |
76 { | 71 { |
77 // Make the decoder by sniffing the bytes. | 72 // Make the decoder by sniffing the bytes. |
78 // This method will examine the data and instantiate an instance of the appr
opriate decoder plugin. | 73 // This method will examine the data and instantiate an instance of the appr
opriate decoder plugin. |
79 // If insufficient bytes are available to determine the image type, no decod
er plugin will be | 74 // If insufficient bytes are available to determine the image type, no decod
er plugin will be |
80 // made. | 75 // made. |
81 if (!m_decoder) { | 76 if (!m_decoder) |
82 m_decoder = NativeImageDecoder::create(*data, m_alphaOption, m_gammaAndC
olorProfileOption); | 77 m_decoder = NativeImageDecoder::create(*data, m_alphaOption, m_gammaAndC
olorProfileOption); |
83 #if ENABLE(IMAGE_DECODER_DOWN_SAMPLING) | |
84 if (m_decoder && s_maxPixelsPerDecodedImage) | |
85 m_decoder->setMaxNumPixels(s_maxPixelsPerDecodedImage); | |
86 #endif | |
87 } | |
88 | 78 |
89 if (m_decoder) | 79 if (m_decoder) |
90 m_decoder->setData(data, allDataReceived); | 80 m_decoder->setData(data, allDataReceived); |
91 } | 81 } |
92 | 82 |
93 String ImageSource::filenameExtension() const | 83 String ImageSource::filenameExtension() const |
94 { | 84 { |
95 return m_decoder ? m_decoder->filenameExtension() : String(); | 85 return m_decoder ? m_decoder->filenameExtension() : String(); |
96 } | 86 } |
97 | 87 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 return m_decoder->frameBytesAtIndex(index); | 183 return m_decoder->frameBytesAtIndex(index); |
194 } | 184 } |
195 | 185 |
196 void ImageSource::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const | 186 void ImageSource::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const |
197 { | 187 { |
198 MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Image); | 188 MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Image); |
199 info.addMember(m_decoder, "decoder"); | 189 info.addMember(m_decoder, "decoder"); |
200 } | 190 } |
201 | 191 |
202 } | 192 } |
OLD | NEW |