Changeset 64374 in webkit


Ignore:
Timestamp:
Jul 30, 2010 2:20:03 PM (14 years ago)
Author:
jamesr@google.com
Message:

2010-07-30 James Robinson <jamesr@chromium.org>

Reviewed by Darin Fisher.

[chromium] Make the GLES2 texture map generic and teach ImageSkia and ImageBufferSkia about GLES2
https://bugs.webkit.org/show_bug.cgi?id=43218

This makes the GLES2Canvas' TextureHashMap key on void* instead of NativeImagePtr
to make it easier to use with other backends. It also teaches ImageSkia how
to draw to a GLES2Canvas instead of a skia buffer.

No change in functionality (yet), no new tests.

  • platform/graphics/chromium/GLES2Canvas.cpp: (WebCore::GLES2Canvas::GLES2Canvas): (WebCore::GLES2Canvas::createTexture): (WebCore::GLES2Canvas::getTexture):
  • platform/graphics/chromium/GLES2Canvas.h:
  • platform/graphics/skia/ImageBufferSkia.cpp: (WebCore::ImageBuffer::getUnmultipliedImageData): (WebCore::ImageBuffer::getPremultipliedImageData):
  • platform/graphics/skia/ImageSkia.cpp: (WebCore::drawBitmapGLES2): (WebCore::BitmapImage::draw): (WebCore::BitmapImageSingleFrameSkia::draw):
Location:
trunk/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r64373 r64374  
     12010-07-30  James Robinson  <jamesr@chromium.org>
     2
     3        Reviewed by Darin Fisher.
     4
     5        [chromium] Make the GLES2 texture map generic and teach ImageSkia and ImageBufferSkia about GLES2
     6        https://bugs.webkit.org/show_bug.cgi?id=43218
     7
     8        This makes the GLES2Canvas' TextureHashMap key on void* instead of NativeImagePtr
     9        to make it easier to use with other backends.  It also teaches ImageSkia how
     10        to draw to a GLES2Canvas instead of a skia buffer.
     11
     12        No change in functionality (yet), no new tests.
     13
     14        * platform/graphics/chromium/GLES2Canvas.cpp:
     15        (WebCore::GLES2Canvas::GLES2Canvas):
     16        (WebCore::GLES2Canvas::createTexture):
     17        (WebCore::GLES2Canvas::getTexture):
     18        * platform/graphics/chromium/GLES2Canvas.h:
     19        * platform/graphics/skia/ImageBufferSkia.cpp:
     20        (WebCore::ImageBuffer::getUnmultipliedImageData):
     21        (WebCore::ImageBuffer::getPremultipliedImageData):
     22        * platform/graphics/skia/ImageSkia.cpp:
     23        (WebCore::drawBitmapGLES2):
     24        (WebCore::BitmapImage::draw):
     25        (WebCore::BitmapImageSingleFrameSkia::draw):
     26
    1272010-07-30  Yong Li  <yoli@rim.com>
    228
  • trunk/WebCore/platform/graphics/chromium/GLES2Canvas.cpp

    r64161 r64374  
    100100    m_stateStack.append(State());
    101101    m_state = &m_stateStack.last();
     102
     103    // Force the source over composite mode to be applied.
     104    m_lastCompositeOp = CompositeClear;
     105    applyCompositeOperator(CompositeSourceOver);
    102106}
    103107
  • trunk/WebCore/platform/graphics/chromium/GLES2Canvas.h

    r64161 r64374  
    4343#include <wtf/HashMap.h>
    4444#include <wtf/Noncopyable.h>
     45#include <wtf/Vector.h>
    4546
    4647namespace WebCore {
  • trunk/WebCore/platform/graphics/skia/ImageBufferSkia.cpp

    r64103 r64374  
    199199PassRefPtr<ImageData> ImageBuffer::getUnmultipliedImageData(const IntRect& rect) const
    200200{
     201    context()->platformContext()->syncSoftwareCanvas();
    201202    return getImageData<Unmultiplied>(rect, *context()->platformContext()->bitmap(), m_size);
    202203}
     
    204205PassRefPtr<ImageData> ImageBuffer::getPremultipliedImageData(const IntRect& rect) const
    205206{
     207    context()->platformContext()->syncSoftwareCanvas();
    206208    return getImageData<Premultiplied>(rect, *context()->platformContext()->bitmap(), m_size);
    207209}
  • trunk/WebCore/platform/graphics/skia/ImageSkia.cpp

    r60658 r64374  
    4848#include "skia/ext/image_operations.h"
    4949#include "skia/ext/platform_canvas.h"
     50#if USE(GLES2_RENDERING)
     51#include "GLES2Canvas.h"
     52#include "GLES2Context.h"
     53#include "SkPixelRef.h"
     54#endif
    5055
    5156namespace WebCore {
     
    405410}
    406411
     412#if USE(GLES2_RENDERING)
     413static void drawBitmapGLES2(GraphicsContext* ctxt, NativeImageSkia* bitmap, const FloatRect& srcRect, const FloatRect& dstRect, ColorSpace styleColorSpace, CompositeOperator compositeOp)
     414{
     415    ctxt->platformContext()->prepareForHardwareDraw();
     416    GLES2Canvas* gpuCanvas = ctxt->platformContext()->gpuCanvas();
     417    gpuCanvas->gles2Context()->makeCurrent();
     418    GLES2Texture* texture = gpuCanvas->getTexture(bitmap);
     419    if (!texture) {
     420        ASSERT(bitmap->config() == SkBitmap::kARGB_8888_Config);
     421        ASSERT(bitmap->rowBytes() == bitmap->width() * 4);
     422        texture = gpuCanvas->createTexture(bitmap, GLES2Texture::BGRA8, bitmap->width(), bitmap->height());
     423        ASSERT(bitmap->pixelRef());
     424        texture->load(bitmap->pixelRef()->pixels());
     425    }
     426    gpuCanvas->drawTexturedRect(texture, srcRect, dstRect, styleColorSpace, compositeOp);
     427}
     428#endif
     429
    407430// ================================================
    408431// BitmapImage Class
     
    430453
    431454void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dstRect,
    432                        const FloatRect& srcRect, ColorSpace, CompositeOperator compositeOp)
     455                       const FloatRect& srcRect, ColorSpace colorSpace, CompositeOperator compositeOp)
    433456{
    434457    if (!m_source.initialized())
     
    440463    startAnimation();
    441464
    442     const NativeImageSkia* bm = nativeImageForCurrentFrame();
     465    NativeImageSkia* bm = nativeImageForCurrentFrame();
    443466    if (!bm)
    444467        return;  // It's too early and we don't have an image yet.
    445468
     469#if  USE(GLES2_RENDERING)
     470    if (ctxt->platformContext()->useGPU()) {
     471        drawBitmapGLES2(ctxt, bm, srcRect, dstRect, colorSpace, compositeOp);
     472        return;
     473    }
     474#endif
    446475    FloatRect normDstRect = normalizeRect(dstRect);
    447476    FloatRect normSrcRect = normalizeRect(srcRect);
     
    449478    if (normSrcRect.isEmpty() || normDstRect.isEmpty())
    450479        return;  // Nothing to draw.
     480
     481    ctxt->platformContext()->prepareForSoftwareDraw();
    451482
    452483    paintSkBitmap(ctxt->platformContext(),
     
    471502        return;  // Nothing to draw.
    472503
     504#if  USE(GLES2_RENDERING)
     505    if (ctxt->platformContext()->useGPU()) {
     506        drawBitmapGLES2(ctxt, &m_nativeImage, srcRect, dstRect, styleColorSpace, compositeOp);
     507        return;
     508    }
     509#endif
     510
     511    ctxt->platformContext()->prepareForSoftwareDraw();
     512
    473513    paintSkBitmap(ctxt->platformContext(),
    474514                  m_nativeImage,
Note: See TracChangeset for help on using the changeset viewer.