Changeset 47841 in webkit
- Timestamp:
- Aug 27, 2009, 4:16:32 PM (16 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r47840 r47841 1 2009-08-27 Peter Kasting <pkasting@google.com> 2 3 Reviewed by Eric Seidel. 4 5 https://bugs.webkit.org/show_bug.cgi?id=28751 6 Clean up ImageDecoder*.cpp a bit. 7 8 * platform/image-decoders/ImageDecoder.cpp: Put functions in the same 9 order as in the header file. Also, since there's already an anonymous 10 namespace in this file, use it to enclose the local helper functions. 11 (WebCore::): 12 (WebCore::ImageDecoder::upperBoundScaledX): 13 (WebCore::ImageDecoder::lowerBoundScaledX): 14 (WebCore::ImageDecoder::scaledY): 15 * platform/image-decoders/cairo/ImageDecoderCairo.cpp: 16 (WebCore::RGBA32Buffer::width): Style fix. 17 (WebCore::RGBA32Buffer::height): Style fix. 18 * platform/image-decoders/haiku/ImageDecoderHaiku.cpp: 19 (WebCore::RGBA32Buffer::copyBitmapData): Ensure m_size is set correctly. 20 (WebCore::RGBA32Buffer::asNewNativeImage): Remove unneeded temp. 21 (WebCore::RGBA32Buffer::operator=): Simplify. 22 * platform/image-decoders/wx/ImageDecoderWx.cpp: 23 (WebCore::RGBA32Buffer::asNewNativeImage): Try and collect spaced-out temps under loop comment to show they're all related. Use size_t for iterating over elements of a Vector. 24 (WebCore::RGBA32Buffer::width): Style fix. 25 (WebCore::RGBA32Buffer::height): Style fix. 26 1 27 2009-08-27 Peter Kasting <pkasting@google.com> 2 28 -
trunk/WebCore/platform/image-decoders/ImageDecoder.cpp
r47836 r47841 39 39 }; 40 40 41 inline void fillScaledValues(Vector<int>& scaledValues, double scaleRate, int length) 42 { 43 double inflateRate = 1. / scaleRate; 44 scaledValues.reserveCapacity(static_cast<int>(length * scaleRate + 0.5)); 45 for (int scaledIndex = 0;;) { 46 int index = static_cast<int>(scaledIndex * inflateRate + 0.5); 47 if (index < length) { 48 scaledValues.append(index); 49 ++scaledIndex; 50 } else 51 break; 52 } 41 53 } 42 54 43 template <MatchType type> staticint getScaledValue(const Vector<int>& scaledValues, int valueToMatch, int searchStart)55 template <MatchType type> int getScaledValue(const Vector<int>& scaledValues, int valueToMatch, int searchStart) 44 56 { 45 57 const int* dataStart = scaledValues.data(); … … 57 69 } 58 70 59 int ImageDecoder::upperBoundScaledX(int origX, int searchStart)60 {61 return getScaledValue<UpperBound>(m_scaledColumns, origX, searchStart);62 }63 64 int ImageDecoder::lowerBoundScaledX(int origX, int searchStart)65 {66 return getScaledValue<LowerBound>(m_scaledColumns, origX, searchStart);67 }68 69 int ImageDecoder::scaledY(int origY, int searchStart)70 {71 return getScaledValue<Exact>(m_scaledRows, origY, searchStart);72 }73 74 static inline void fillScaledValues(Vector<int>& scaledValues, double scaleRate, int length)75 {76 double inflateRate = 1. / scaleRate;77 scaledValues.reserveCapacity(static_cast<int>(length * scaleRate + 0.5));78 for (int scaledIndex = 0;;) {79 int index = static_cast<int>(scaledIndex * inflateRate + 0.5);80 if (index < length) {81 scaledValues.append(index);82 ++scaledIndex;83 } else84 break;85 }86 71 } 87 72 … … 102 87 } 103 88 89 int ImageDecoder::upperBoundScaledX(int origX, int searchStart) 90 { 91 return getScaledValue<UpperBound>(m_scaledColumns, origX, searchStart); 92 } 93 94 int ImageDecoder::lowerBoundScaledX(int origX, int searchStart) 95 { 96 return getScaledValue<LowerBound>(m_scaledColumns, origX, searchStart); 97 } 98 99 int ImageDecoder::scaledY(int origY, int searchStart) 100 { 101 return getScaledValue<Exact>(m_scaledRows, origY, searchStart); 102 } 103 104 104 #endif // ENABLE(IMAGE_DECODER_DOWN_SAMPLING) 105 105 -
trunk/WebCore/platform/image-decoders/cairo/ImageDecoderCairo.cpp
r44733 r47841 114 114 } 115 115 116 int RGBA32Buffer::width() const { 116 int RGBA32Buffer::width() const 117 { 117 118 return m_size.width(); 118 119 } 119 120 120 int RGBA32Buffer::height() const { 121 int RGBA32Buffer::height() const 122 { 121 123 return m_size.height(); 122 124 } -
trunk/WebCore/platform/image-decoders/haiku/ImageDecoderHaiku.cpp
r46012 r47841 28 28 29 29 #include <Bitmap.h> 30 31 30 32 31 namespace WebCore { … … 62 61 63 62 m_bytes = other.m_bytes; 63 m_size = other.m_size; 64 64 setHasAlpha(other.m_hasAlpha); 65 65 } … … 80 80 NativeImagePtr RGBA32Buffer::asNewNativeImage() const 81 81 { 82 const void* bytes = m_bytes.data();83 84 82 BBitmap* bmp = new BBitmap(BRect(0, 0, width(), height()), B_RGB32); 85 bmp->SetBits(bytes, m_size.width() * m_size.height(), 0, B_RGB32); 86 83 bmp->SetBits(m_bytes.data(), m_size.width() * m_size.height(), 0, B_RGB32); 87 84 return bmp; 88 85 } … … 108 105 return *this; 109 106 110 m_bytes = other.m_bytes; 111 m_size = other.m_size; 112 setHasAlpha(other.hasAlpha()); 107 copyBitmapData(other); 113 108 setRect(other.rect()); 114 109 setStatus(other.status()); -
trunk/WebCore/platform/image-decoders/wx/ImageDecoderWx.cpp
r44733 r47841 87 87 NativeImagePtr RGBA32Buffer::asNewNativeImage() const 88 88 { 89 const unsigned char* bytes = (const unsigned char*)m_bytes.data(); 90 89 wxBitmap* bmp = new wxBitmap(width(), height(), 32); 91 90 typedef wxPixelData<wxBitmap, wxAlphaPixelFormat> WxPixelData; 92 93 wxBitmap* bmp = new wxBitmap(width(), height(), 32);94 91 WxPixelData data(*bmp); 95 96 int rowCounter = 0;97 long pixelCounter = 0;98 99 WxPixelData::Iterator p(data);100 101 WxPixelData::Iterator rowStart = p;102 92 103 93 // NB: It appears that the data is in BGRA format instead of RGBA format. 104 94 // This code works properly on both ppc and intel, meaning the issue is 105 95 // likely not an issue of byte order getting mixed up on different archs. 106 for (long i = 0; i < m_bytes.size() * sizeof(PixelData); i += sizeof(PixelData)) { 96 const unsigned char* bytes = (const unsigned char*)m_bytes.data(); 97 int rowCounter = 0; 98 long pixelCounter = 0; 99 WxPixelData::Iterator p(data); 100 WxPixelData::Iterator rowStart = p; 101 for (size_t i = 0; i < m_bytes.size() * sizeof(PixelData); i += sizeof(PixelData)) { 107 102 p.Red() = bytes[i+2]; 108 103 p.Green() = bytes[i+1]; … … 113 108 114 109 pixelCounter++; 115 if ( (pixelCounter % width() ) == 0) {110 if ((pixelCounter % width()) == 0) { 116 111 rowCounter++; 117 112 p = rowStart; 118 113 p.MoveTo(data, 0, rowCounter); 119 114 } 120 121 115 } 122 116 #if !wxCHECK_VERSION(2,9,0) … … 126 120 127 121 #if USE(WXGC) 128 wxGraphicsBitmap* bitmap = 122 wxGraphicsBitmap* bitmap = new wxGraphicsBitmap(wxGraphicsRenderer::GetDefaultRenderer()->CreateBitmap(*bmp)); 129 123 delete bmp; 130 124 return bitmap; … … 162 156 } 163 157 164 int RGBA32Buffer::width() const { 158 int RGBA32Buffer::width() const 159 { 165 160 return m_size.width(); 166 161 } 167 162 168 int RGBA32Buffer::height() const { 163 int RGBA32Buffer::height() const 164 { 169 165 return m_size.height(); 170 166 }
Note:
See TracChangeset
for help on using the changeset viewer.