WBMP in Chromium

21 篇文章 0 订阅
14 篇文章 0 订阅

我记得这个问题是当初在chromium里面实现WML时发现的。

diff --git a/Source/platform/image-decoders/wbmp/WBMPImageDecoder.cpp b/Source/platform/image-decoders/wbmp/WBMPImageDecoder.cpp
index a8ee7e6…88131e6 100644
— a/Source/platform/image-decoders/wbmp/WBMPImageDecoder.cpp
+++ b/Source/platform/image-decoders/wbmp/WBMPImageDecoder.cpp
@@ -34,7 +34,8 @@
#include “platform/PlatformInstrumentation.h”
#include “platform/image-decoders/wbmp/WBMPImageReader.h”
#include “wtf/PassOwnPtr.h”

+#include “wtf/Assertions.h”
+#include <base/debug/stack_trace.h>
namespace WebCore {

WBMPImageDecoder::WBMPImageDecoder(ImageSource::AlphaOption alphaOption,
@@ -44,10 +45,12 @@ WBMPImageDecoder::WBMPImageDecoder(ImageSource::AlphaOption alphaOption,
, m_width(0)
, m_height(0)
{
+base::debug::StackTrace().Print();
}

void WBMPImageDecoder::setData(SharedBuffer* data, bool allDataReceived)
{
+WTFReportError(FILE, LINE, WTF_PRETTY_FUNCTION, " Neo,data size %d, failed: %d",data->size(),failed());
if (failed())
return;

@@ -132,6 +135,7 @@ void WBMPImageDecoder::decode(bool onlySize)

long readVarInt(SharedBuffer * buffer, size_t &cursor)
{
+WTFReportError(FILE, LINE, WTF_PRETTY_FUNCTION, " Neo, cursor: %d, buffer->size(): %d",cursor,buffer->size());
ASSERT(cursor >= 0);
ASSERT(cursor < buffer->size());

@@ -159,7 +163,7 @@ bool WBMPImageDecoder::processFileHeader(size_t* imgDataOffset)
long fixedHeader;

 type = readVarInt(m_data.get(), decodedOffset);

+WTFReportError(FILE, LINE, WTF_PRETTY_FUNCTION, " Neo, 1 decodedOffset: %d",decodedOffset);
// We only support type 0 for now. We’ve never seen anything else.
if (type != 0) {
return setFailed();
@@ -174,10 +178,14 @@ bool WBMPImageDecoder::processFileHeader(size_t* imgDataOffset)
}

 m_width = readVarInt(m_data.get(), decodedOffset);

+WTFReportError(FILE, LINE, WTF_PRETTY_FUNCTION, " Neo, 2 decodedOffset: %d,m_width: %d",decodedOffset,m_width);
+
if ((m_width < 0) || (m_width >= (1 << 16)))
return setFailed();

 m_height = readVarInt(m_data.get(), decodedOffset);

+WTFReportError(FILE, LINE, WTF_PRETTY_FUNCTION, " Neo, 3 decodedOffset: %d,m_height: %d",decodedOffset,m_height);
+
if ((m_height < 0) || (m_height >= (1 << 16)))
return setFailed();

diff --git a/Source/platform/image-decoders/wbmp/WBMPImageReader.cpp b/Source/platform/image-decoders/wbmp/WBMPImageReader.cpp
index 6f75337…f64ddde 100644
— a/Source/platform/image-decoders/wbmp/WBMPImageReader.cpp
+++ b/Source/platform/image-decoders/wbmp/WBMPImageReader.cpp
@@ -31,7 +31,8 @@

#include “config.h”
#include “platform/image-decoders/wbmp/WBMPImageReader.h”

+#include “wtf/Assertions.h”
+#include <android/log.h>
namespace WebCore {

WBMPImageReader::WBMPImageReader(ImageDecoder* parent, int width, int height, size_t imgDataOffset)
@@ -41,12 +42,14 @@ WBMPImageReader::WBMPImageReader(ImageDecoder* parent, int width, int height, si
, m_buffer(0)
, m_imgDataOffset(imgDataOffset)
{
+//memset(&m_coord,0, sizeof(m_coord));
}

bool WBMPImageReader::decodeWBMP()
{
// Initialize the framebuffer if needed.
ASSERT(m_buffer); // Parent should set this before asking us to decode!
+WTFReportError(FILE, LINE, WTF_PRETTY_FUNCTION, " Neo,m_buffer->status():%d, width: %d, height: %d",m_buffer->status(),m_width,m_height);
if (m_buffer->status() == ImageFrame::FrameEmpty) {
if (!m_buffer->setSize(m_width, m_height))
return m_parent->setFailed(); // Unable to allocate.
@@ -78,7 +81,7 @@ WBMPImageReader::ProcessingResult WBMPImageReader::processData()
if ((m_data->size() - m_imgDataOffset) < (size_t)numBytes) {
return InsufficientData;
}

+WTFReportError(FILE, LINE, WTF_PRETTY_FUNCTION, " Neo,m_coord.x:%d, m_coord.y: %d, m_width :%d,m_height : %d,parent height: %d",m_coord.x(),m_coord.y(),m_width,m_height,m_parent->size().height());
#define setWHITE() setRGBA(0xff, 0xff, 0xff, 0xff /alpha/)
#define setBLACK() setRGBA(0x00, 0x00, 0x00, 0xff /alpha/)

@@ -87,7 +90,9 @@ WBMPImageReader::ProcessingResult WBMPImageReader::processData()
for (int y = 0; y < m_parent->size().height(); y++) {
char pixels = 0;
int width = m_width;

  •    m_coord.setY(y);
    
  •    m_coord.setX(0);
    

+__android_log_print(ANDROID_LOG_DEBUG, “Neo”, " loop 0 y:%d, m_coord.x:%d, m_coord.y: %d, m_width :%d", y ,m_coord.x(),m_coord.y(),width);
while (width >= 8) {
pixels = m_data->data()[cursor++];
for (unsigned char bitPosition = 0x80; bitPosition; bitPosition >>= 1) {
@@ -99,7 +104,8 @@ WBMPImageReader::ProcessingResult WBMPImageReader::processData()
}
width -= 8;
}

+__android_log_print(ANDROID_LOG_DEBUG, “Neo”, " loop 1 y:%d, m_coord.x:%d, m_coord.y: %d, m_width :%d", y ,m_coord.x(),m_coord.y(),width);
+//WTFReportError(FILE, LINE, WTF_PRETTY_FUNCTION, " Neo, loop 1 y:%d, m_coord.x:%d, m_coord.y: %d, m_width :%d", y ,m_coord.x(),m_coord.y(),width);
if (width)
pixels = m_data->data()[cursor++];

@@ -111,10 +117,12 @@ WBMPImageReader::ProcessingResult WBMPImageReader::processData()
}
width–;
}
+__android_log_print(ANDROID_LOG_DEBUG, “Neo”, " loop 2 y:%d, m_coord.x:%d, m_coord.y: %d, m_width :%d,m_height : %d", y ,m_coord.x(),m_coord.y(),m_width,m_height);
+//WTFReportError(FILE, LINE, WTF_PRETTY_FUNCTION, " Neo, loop 2 y:%d, m_coord.x:%d, m_coord.y: %d, m_width :%d,m_height : %d", y ,m_coord.x(),m_coord.y(),m_width,m_height);
}

 // Finished decoding whole image.
 return Success;

}

-} // namespace WebCore
\ No newline at end of file
+} // namespace WebCore
diff --git a/Source/web/web.gypi b/Source/web/web.gypi
index f102558…07bc0ad 100644
— a/Source/web/web.gypi
+++ b/Source/web/web.gypi
@@ -288,6 +288,7 @@
‘tests/ImageFilterBuilderTest.cpp’,
‘tests/ImageLayerChromiumTest.cpp’,
‘tests/JPEGImageDecoderTest.cpp’,

  •  'tests/WBMPImageDecoderTest.cpp',             
     'tests/KeyboardTest.cpp',
     'tests/LinkHighlightTest.cpp',
     'tests/ListenerLeakTest.cpp',
    

diff --git a/Source/wtf/Assertions.h b/Source/wtf/Assertions.h
index 8f7f2ae…92ccc42 100644
— a/Source/wtf/Assertions.h
+++ b/Source/wtf/Assertions.h
@@ -45,7 +45,7 @@

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值