Ejemplo n.º 1
0
void SharedBitmap::clearPixels(const IntRect& rect)
{
    if (!m_pixels)
        return;

    IntRect bmpRect(0, 0, width(), height());
    bmpRect.intersect(rect);
    if (is16bit()) {
        unsigned w = m_bmpInfo.paddedWidth();
        unsigned short* dst = static_cast<unsigned short*>(m_pixels);
        dst += bmpRect.y() * w + bmpRect.x();
        int wordsToSet = bmpRect.width();
        const unsigned short* dstEnd = dst + bmpRect.height() * w;
        while (dst < dstEnd) {
            wmemset(reinterpret_cast<wchar_t*>(dst), 0, wordsToSet);
            dst += w;
        }
        return;
    }

    unsigned w = width();
    unsigned* dst = static_cast<unsigned*>(m_pixels);
    dst += bmpRect.y() * w + bmpRect.x();
    int wordsToSet = bmpRect.width() * 2;
    const unsigned* dstEnd = dst + bmpRect.height() * w;
    while (dst < dstEnd) {
        wmemset(reinterpret_cast<wchar_t*>(dst), 0, wordsToSet);
        dst += w;
    }
}
Ejemplo n.º 2
0
void SharedBitmap::resetPixels(bool black)
{
    if (!m_pixels)
        return;

    unsigned bufferSize = m_bmpInfo.numPixels();
    if (black) {
        unsigned bufferSizeInBytes = bufferSize * (is16bit() ? 2 : 4);
        memset(m_pixels, 0, bufferSizeInBytes);
        return;
    }

    if (is16bit()) {
        // Fill it with white color
        wmemset(static_cast<wchar_t*>(m_pixels), 0xFFFF, bufferSize);
        return;
    }

    // Make it white but transparent
    unsigned* pixel = static_cast<unsigned*>(m_pixels);
    const unsigned* bufferEnd = pixel + bufferSize;
    while (pixel < bufferEnd)
        *pixel++ = 0x00FFFFFF;
}
Ejemplo n.º 3
0
bool SharedBitmap::to16bit()
{
    if (m_locked)
        return false;
    if (is16bit())
        return true;

    BitmapInfo newBmpInfo = BitmapInfo::create(m_bmpInfo.size(), BitmapInfo::BitCount16);

    int width = newBmpInfo.width();
    int paddedWidth = newBmpInfo.paddedWidth();
    int bufferSize = paddedWidth * newBmpInfo.height();
    OwnArrayPtr<unsigned> newPixelData = adoptArrayPtr(new unsigned[bufferSize / 2]);
    void* newPixels = newPixelData.get();

    if (!newPixels)
        return false;

    unsigned short* p16 = static_cast<unsigned short*>(newPixels);
    const unsigned* p32 = static_cast<const unsigned*>(m_pixels);

    bool skips = paddedWidth != width;

    const unsigned short* p16end = p16 + bufferSize;
    while (p16 < p16end) {
        for (unsigned short* p16lineEnd = p16 + width; p16 < p16lineEnd; )
            *p16++ = convert32To16(*p32++);

        if (skips)
            *p16++ = 0;
    }

    if (m_hbitmap)
        m_hbitmap = nullptr;
    else
        m_pixelData = newPixelData.release();

    m_pixels = newPixels;
    m_bmpInfo = newBmpInfo;

    setHasAlpha(false);
    return true;
}
Ejemplo n.º 4
0
PassOwnPtr<HBITMAP> SharedBitmap::createHandle(void** pixels, BitmapInfo* bmpInfo, int height, bool use16bit) const
{
    if (!m_pixels)
        return nullptr;

    if (height == -1)
        height = this->height();
    *bmpInfo = BitmapInfo::createBottomUp(IntSize(width(), height), (use16bit || is16bit()) ? BitmapInfo::BitCount16 : BitmapInfo::BitCount32);

    OwnPtr<HBITMAP> hbmp = adoptPtr(CreateDIBSection(0, bmpInfo, DIB_RGB_COLORS, pixels, 0, 0));

    if (!hbmp)
        return nullptr;

    OwnPtr<HDC> bmpDC = adoptPtr(CreateCompatibleDC(0));
    HGDIOBJ hOldBmp = SelectObject(bmpDC.get(), hbmp.get());

    StretchDIBits(bmpDC.get(), 0, 0, width(), height, 0, 0, width(), height, m_pixels, &m_bmpInfo, DIB_RGB_COLORS, SRCCOPY);

    SelectObject(bmpDC.get(), hOldBmp);

    return hbmp.release();
}
Ejemplo n.º 5
0
 bool  has_sib () const 
    {	 return ! is16bit() && rep_.mod != 3  && rep_.rm == 4; }
Ejemplo n.º 6
0
 disp32_type get_disp() const  
    { return is16bit() ? get_disp16() : get_disp32() ; }
Ejemplo n.º 7
0
 int  get_disp_size() const 
    { return is16bit() ? get_disp_size16() : get_disp_size32() ; }