Changeset 145968 in webkit


Ignore:
Timestamp:
Mar 15, 2013 5:36:12 PM (11 years ago)
Author:
anilsson@rim.com
Message:

[BlackBerry] BlackBerry::Platform::Graphics::GraphicsContext integration related changes in Source/WebKit/blackberry
https://bugs.webkit.org/show_bug.cgi?id=112467

Reviewed by Rob Buis.

PR 293208

This patch contains contributions from many members of the BlackBerry
WebKit team:

Mike Lattanzio
Arvid Nilsson
Jakob Petsovits
Konrad Piascik
Jeff Rogers
Filip Spacek

  • Api/BackingStore.cpp:

(BlackBerry::WebKit::BackingStorePrivate::render):
(BlackBerry::WebKit::BackingStorePrivate::blitVisibleContents):
(BlackBerry::WebKit::BackingStorePrivate::compositeContents):
(BlackBerry::WebKit::BackingStorePrivate::tileSize):

  • Api/WebOverlay.cpp:

(BlackBerry::WebKit::WebOverlayPrivate::drawContents):
(BlackBerry::WebKit::WebOverlayPrivateWebKitThread::paintContents):
(BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::WebOverlayLayerCompositingThreadClient):
(BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::setContentsToImage):
(BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::clearUploadedContents):
(BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::setContentsToColor):
(BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::uploadTexturesIfNeeded):
(BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::drawTextures):
(BlackBerry::WebKit::WebOverlayPrivateCompositingThread::WebOverlayPrivateCompositingThread):
(BlackBerry::WebKit::WebOverlayPrivateCompositingThread::removeFromParent):
(BlackBerry::WebKit::WebOverlayPrivateCompositingThread::setContentsToImage):

  • Api/WebOverlay.h:
  • Api/WebOverlayClient.h:
  • Api/WebOverlay_p.h:

(WebOverlayPrivate):
(BlackBerry::WebKit::WebOverlayPrivateWebKitThread::showDebugBorders):
(BlackBerry::WebKit::WebOverlayPrivateWebKitThread::showRepaintCounter):
(WebOverlayLayerCompositingThreadClient):
(BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::image):
(WebOverlayPrivateCompositingThread):

  • Api/WebPageCompositor.cpp:

(BlackBerry::WebKit::WebPageCompositorPrivate::WebPageCompositorPrivate):

  • WebKitSupport/BackingStoreTile.cpp:

(BlackBerry::WebKit::TileBuffer::~TileBuffer):
(BlackBerry::WebKit::TileBuffer::nativeBuffer):
(BlackBerry::WebKit::TileBuffer::paintBackground):

  • WebKitSupport/DefaultTapHighlight.cpp:

(BlackBerry::WebKit::DefaultTapHighlight::paintContents):
(BlackBerry::WebKit::DefaultTapHighlight::showDebugBorders):
(WebKit):
(BlackBerry::WebKit::DefaultTapHighlight::showRepaintCounter):

  • WebKitSupport/DefaultTapHighlight.h:

(DefaultTapHighlight):

  • WebKitSupport/InspectorOverlayBlackBerry.cpp:

(BlackBerry::WebKit::InspectorOverlay::showDebugBorders):
(WebKit):
(BlackBerry::WebKit::InspectorOverlay::showRepaintCounter):

  • WebKitSupport/InspectorOverlayBlackBerry.h:

(InspectorOverlay):

  • WebKitSupport/SelectionOverlay.cpp:

(BlackBerry::WebKit::SelectionOverlay::draw):
(BlackBerry::WebKit::SelectionOverlay::hide):
(BlackBerry::WebKit::SelectionOverlay::paintContents):
(BlackBerry::WebKit::SelectionOverlay::showDebugBorders):
(WebKit):
(BlackBerry::WebKit::SelectionOverlay::showRepaintCounter):

  • WebKitSupport/SelectionOverlay.h:

(SelectionOverlay):

  • WebKitSupport/SurfacePool.cpp:

(BlackBerry::WebKit::SurfacePool::createPlatformGraphicsContext):
(BlackBerry::WebKit::SurfacePool::destroyPlatformGraphicsContext):
(BlackBerry::WebKit::SurfacePool::waitForBuffer):
(BlackBerry::WebKit::SurfacePool::notifyBuffersComposited):
(BlackBerry::WebKit::SurfacePool::destroyPlatformSync):

  • WebKitSupport/SurfacePool.h:
Location:
trunk/Source/WebKit/blackberry
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/blackberry/Api/BackingStore.cpp

    r143615 r145968  
    5050#include <BlackBerryPlatformWindow.h>
    5151
    52 #include <SkImageDecoder.h>
    53 
    5452#include <wtf/CurrentTime.h>
    5553#include <wtf/MathExtras.h>
     
    10651063        ASSERT(backBuffer);
    10661064
    1067         // If the tile has been created, but this is the first time we are painting on it
    1068         // then it hasn't been given a default background yet so that we can save time during
    1069         // startup. That's why we are doing it here instead...
    1070         if (!backBuffer->backgroundPainted())
    1071             backBuffer->paintBackground();
    1072 
     1065        backBuffer->paintBackground();
    10731066        backBuffer->setLastRenderScale(currentScale);
    10741067        backBuffer->setLastRenderOrigin(tileOrigin);
     
    12231216        dstRect.toString().c_str(), documentSrcRect.toString().c_str(), viewportAccessor->scale());
    12241217#endif
     1218
     1219    BlackBerry::Platform::Graphics::Buffer* dstBuffer = buffer();
     1220    ASSERT(dstBuffer);
     1221    if (dstBuffer) {
     1222        // On the GPU, clearing is free and allows for optimizations,
     1223        // so we always want to do this first for the whole surface.
     1224        // Don't call clearWindow() as we don't want to add it to the posted rect.
     1225        BlackBerry::Platform::Graphics::clearBuffer(dstBuffer,
     1226            m_webPageBackgroundColor.red(), m_webPageBackgroundColor.green(),
     1227            m_webPageBackgroundColor.blue(), m_webPageBackgroundColor.alpha());
     1228    } else
     1229        Platform::logAlways(Platform::LogLevelWarn, "Empty window buffer, can't blit contents.");
    12251230
    12261231#if DEBUG_CHECKERBOARD
     
    14261431    Platform::IntRectRegion transformedContentsRegion = transformedContents;
    14271432    Platform::IntRectRegion backingStoreRegion = geometry->backingStoreRect();
    1428     Platform::IntRectRegion checkeredRegion
     1433    Platform::IntRectRegion clearRegion
    14291434        = Platform::IntRectRegion::subtractRegions(transformedContentsRegion, backingStoreRegion);
    14301435
    1431     // Blit checkered to those parts that are not covered by the backingStoreRect.
    1432     std::vector<Platform::IntRect> checkeredRects = checkeredRegion.rects();
    1433     for (size_t i = 0; i < checkeredRects.size(); ++i)
    1434         layerRenderer->drawCheckerboardPattern(transform, m_webPage->d->mapFromTransformedFloatRect(WebCore::IntRect(checkeredRects.at(i))));
     1436    // Clear those parts that are not covered by the backingStoreRect.
     1437    Color clearColor(Color::white);
     1438    std::vector<Platform::IntRect> clearRects = clearRegion.rects();
     1439    for (size_t i = 0; i < clearRects.size(); ++i)
     1440        layerRenderer->drawColor(transform, m_webPage->d->mapFromTransformedFloatRect(WebCore::IntRect(clearRects.at(i))), clearColor);
    14351441
    14361442    // Get the list of tile rects that makeup the content.
     
    14431449
    14441450        if (!tileBuffer || !geometry->isTileCorrespondingToBuffer(index, tileBuffer))
    1445             layerRenderer->drawCheckerboardPattern(transform, m_webPage->d->mapFromTransformedFloatRect(Platform::FloatRect(dirtyRect)));
     1451            layerRenderer->drawColor(transform, m_webPage->d->mapFromTransformedFloatRect(Platform::FloatRect(dirtyRect)), clearColor);
    14461452        else {
    14471453            Platform::IntPoint tileOrigin = tileBuffer->lastRenderOrigin();
     
    14571463                Platform::IntRect tileSurfaceRect = notRenderedRects.at(i);
    14581464                tileSurfaceRect.move(-tileOrigin.x(), -tileOrigin.y());
    1459                 layerRenderer->drawCheckerboardPattern(transform, m_webPage->d->mapFromTransformedFloatRect(Platform::FloatRect(tileSurfaceRect)));
     1465                layerRenderer->drawColor(transform, m_webPage->d->mapFromTransformedFloatRect(Platform::FloatRect(tileSurfaceRect)), clearColor);
    14601466            }
    14611467        }
     
    18091815Platform::IntSize BackingStorePrivate::tileSize()
    18101816{
    1811     static Platform::IntSize tileSize = Platform::Settings::instance()->tileSize(Platform::BackingStoreTileUsage);
     1817    static Platform::IntSize tileSize = Platform::Settings::instance()->tileSize();
    18121818    return tileSize;
    18131819}
  • trunk/Source/WebKit/blackberry/Api/WebOverlay.cpp

    r145962 r145968  
    11/*
    2  * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
     2 * Copyright (C) 2012, 2013 Research In Motion Limited. All rights reserved.
    33 *
    44 * This library is free software; you can redistribute it and/or
     
    2525#include "LayerWebKitThread.h"
    2626#include "NotImplemented.h"
    27 #include "PlatformContextSkia.h"
    2827#include "TextureCacheCompositingThread.h"
    2928#include "WebAnimation.h"
     
    3635#include "WebPage_p.h"
    3736
     37#include <BlackBerryPlatformGraphicsContext.h>
    3838#include <BlackBerryPlatformMessageClient.h>
    3939#include <BlackBerryPlatformString.h>
    4040#include <GLES2/gl2.h>
    41 #include <SkDevice.h>
     41
     42using namespace WebCore;
     43using BlackBerry::Platform::Graphics::GLES2Program;
    4244
    4345namespace BlackBerry {
    4446namespace WebKit {
    45 
    46 using namespace WebCore;
    4747
    4848WebOverlay::WebOverlay()
     
    231231}
    232232
    233 void WebOverlayPrivate::drawContents(SkCanvas* canvas)
     233void WebOverlayPrivate::drawContents(Platform::Graphics::Drawable* drawable)
    234234{
    235235    if (!client)
    236236        return;
    237237
    238     client->drawOverlayContents(q, canvas);
     238    client->drawOverlayContents(q, drawable);
    239239}
    240240
     
    384384void WebOverlayPrivateWebKitThread::paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext& c, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect&)
    385385{
    386     drawContents(c.platformContext()->canvas());
     386    drawContents(c.platformContext());
    387387}
    388388
    389389WebOverlayLayerCompositingThreadClient::WebOverlayLayerCompositingThreadClient()
    390390    : m_drawsContent(false)
    391     , m_layerCompositingThread(0)
    392391    , m_client(0)
    393392{
     
    405404}
    406405
    407 void WebOverlayLayerCompositingThreadClient::setContents(const SkBitmap& contents)
    408 {
    409     m_contents = contents;
     406void WebOverlayLayerCompositingThreadClient::setContentsToImage(const BlackBerry::Platform::Graphics::TiledImage& image)
     407{
     408    m_image = image;
    410409    m_color = Color();
    411410    m_texture.clear();
     
    415414void WebOverlayLayerCompositingThreadClient::clearUploadedContents()
    416415{
    417     m_uploadedContents = SkBitmap();
     416    m_uploadedImage = BlackBerry::Platform::Graphics::TiledImage();
    418417}
    419418
    420419void WebOverlayLayerCompositingThreadClient::setContentsToColor(const Color& color)
    421420{
    422     m_contents = SkBitmap();
     421    m_image = BlackBerry::Platform::Graphics::TiledImage();
    423422    m_color = color;
    424423    m_texture.clear();
     
    435434}
    436435
    437 void WebOverlayLayerCompositingThreadClient::uploadTexturesIfNeeded(LayerCompositingThread*)
    438 {
    439     if (m_contents.isNull() && !m_color.isValid() && !m_drawsContent)
     436void WebOverlayLayerCompositingThreadClient::uploadTexturesIfNeeded(LayerCompositingThread* layer)
     437{
     438    if (m_image.isNull() && !m_color.isValid() && !m_drawsContent)
    440439        return;
    441440
     
    447446        return;
    448447    }
     448
     449    Texture::HostType textureContents = Texture::HostType();
     450    IntSize textureSize;
    449451
    450452    if (m_drawsContent) {
     
    452454            return;
    453455
    454         if (m_contents.isNull()) {
    455             m_contents.setConfig(SkBitmap::kARGB_8888_Config, m_layerCompositingThread->bounds().width(), m_layerCompositingThread->bounds().height());
    456             m_contents.allocPixels();
    457         }
    458 
    459         SkDevice device(m_contents);
    460         SkCanvas canvas(&device);
    461         m_client->drawOverlayContents(m_owner, &canvas);
    462         canvas.flush();
     456        textureSize = layer->bounds();
     457        textureContents = BlackBerry::Platform::Graphics::createBuffer(IntSize(0, 0), BlackBerry::Platform::Graphics::NeverBacked);
     458        if (!textureContents)
     459            return;
     460
     461        clearBuffer(textureContents, 0, 0, 0, 0);
     462        PlatformGraphicsContext* platformContext = lockBufferDrawable(textureContents);
     463        double transform[] = {
     464            1, 0,
     465            0, 1,
     466            -layer->bounds().width() / 2.0, -layer->bounds().height() / 2.0
     467        };
     468        platformContext->setTransform(transform);
     469        m_client->drawOverlayContents(m_owner, platformContext);
     470
     471        releaseBufferDrawable(textureContents);
     472    } else if (!m_image.isNull()) {
     473        textureSize = IntSize(m_image.width(), m_image.height());
     474        textureContents = BlackBerry::Platform::Graphics::createBuffer(IntSize(0, 0), BlackBerry::Platform::Graphics::NeverBacked);
     475        if (!textureContents)
     476            return;
     477
     478        PlatformGraphicsContext* platformContext = BlackBerry::Platform::Graphics::lockBufferDrawable(textureContents);
     479
     480        AffineTransform transform;
     481        platformContext->getTransform(reinterpret_cast<double*>(&transform));
     482        transform.translate(-m_image.width() / 2.0, -m_image.height() / 2.0);
     483        platformContext->setTransform(reinterpret_cast<double*>(&transform));
     484
     485        FloatRect rect(0, 0, m_image.width(), m_image.height());
     486        platformContext->addImage(rect, rect, &m_image);
     487        releaseBufferDrawable(textureContents);
     488        m_uploadedImage = m_image;
    463489    }
    464490
    465491    m_texture = Texture::create();
    466     m_texture->protect(IntSize(m_contents.width(), m_contents.height()));
    467     IntRect bitmapRect(0, 0, m_contents.width(), m_contents.height());
    468     m_uploadedContents = m_contents;
    469     m_texture->updateContents(m_uploadedContents, bitmapRect, bitmapRect, false);
    470 }
    471 
    472 void WebOverlayLayerCompositingThreadClient::drawTextures(LayerCompositingThread* layer, double /*scale*/, int positionLocation, int texCoordLocation)
     492    m_texture->protect(IntSize(), BlackBerry::Platform::Graphics::BackedWhenNecessary);
     493    IntRect bitmapRect(0, 0, textureSize.width(), textureSize.height());
     494    m_texture->updateContents(textureContents, bitmapRect, bitmapRect, false);
     495}
     496
     497void WebOverlayLayerCompositingThreadClient::drawTextures(LayerCompositingThread* layer, double scale, const GLES2Program& program)
    473498{
    474499    if (!m_texture || !m_texture->textureId())
    475500        return;
    476501
    477     glBindTexture(GL_TEXTURE_2D, m_texture->textureId());
    478     glVertexAttribPointer(positionLocation, 2, GL_FLOAT, GL_FALSE, 0, &layer->getTransformedBounds());
    479     float texcoords[4 * 2] = { 0, 0,  0, 1,  1, 1,  1, 0 };
    480     glVertexAttribPointer(texCoordLocation, 2, GL_FLOAT, GL_FALSE, 0, texcoords);
    481     glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
     502    TransformationMatrix matrix = layer->drawTransform();
     503    if (!m_image.isNull()) {
     504        if (m_image.size().isEmpty())
     505            return;
     506
     507        matrix.scaleNonUniform(static_cast<double>(layer->bounds().width()) / m_image.width(), static_cast<double>(layer->bounds().height()) / m_image.height());
     508    }
     509    matrix.scale(layer->sizeIsScaleInvariant() ? 1.0 / scale : 1.0);
     510    blitToBuffer(0, m_texture->textureId(), reinterpret_cast<BlackBerry::Platform::TransformationMatrix&>(matrix),
     511        BlackBerry::Platform::Graphics::SourceOver, static_cast<unsigned char>(layer->drawOpacity() * 255));
    482512}
    483513
     
    490520WebOverlayPrivateCompositingThread::WebOverlayPrivateCompositingThread(PassRefPtr<LayerCompositingThread> layerCompositingThread)
    491521    : m_layerCompositingThreadClient(0)
     522    , m_data(0)
    492523{
    493524    m_layerCompositingThread = layerCompositingThread;
     
    498529{
    499530    m_layerCompositingThread = LayerCompositingThread::create(LayerData::CustomLayer, m_layerCompositingThreadClient);
    500     m_layerCompositingThreadClient->setLayer(m_layerCompositingThread.get());
    501531}
    502532
     
    617647void WebOverlayPrivateCompositingThread::removeFromParent()
    618648{
    619     if (m_layerCompositingThread->superlayer() == page()->m_compositor->compositingThreadOverlayLayer())
    620         page()->m_compositor->removeOverlay(m_layerCompositingThread.get());
     649    if (page() && m_layerCompositingThread->superlayer() == page()->compositor()->compositingThreadOverlayLayer())
     650        page()->m_webPage->removeCompositingThreadOverlay(q);
    621651    else
    622652        m_layerCompositingThread->removeFromSuperlayer();
     
    629659        return;
    630660
    631     const SkBitmap& oldContents = m_layerCompositingThreadClient->contents();
    632     if (!oldContents.isNull()) {
    633         SkAutoLockPixels lock(oldContents);
    634         if (data == oldContents.getPixels())
    635             return;
    636     }
    637 
    638     SkBitmap contents;
    639     contents.setConfig(SkBitmap::kARGB_8888_Config, imageSize.width(), imageSize.height());
    640 
    641     switch (adoptionType) {
    642     case WebOverlay::ReferenceImageData:
    643         contents.setPixels(const_cast<unsigned char*>(data));
    644         break;
    645     case WebOverlay::CopyImageData:
    646         if (contents.allocPixels()) {
    647             contents.lockPixels();
    648             size_t bytes = SkBitmap::ComputeSize(SkBitmap::kARGB_8888_Config, imageSize.width(), imageSize.height());
    649             memcpy(contents.getPixels(), data, bytes);
    650             contents.unlockPixels();
    651         }
    652         break;
    653     default:
    654         ASSERT_NOT_REACHED();
    655     }
    656 
    657     m_layerCompositingThreadClient->setContents(contents);
     661    if (data == m_data)
     662        return;
     663
     664    m_data = data;
     665
     666    BlackBerry::Platform::Graphics::TiledImage image = BlackBerry::Platform::Graphics::TiledImage(imageSize, reinterpret_cast_ptr<const unsigned*>(data), true, BlackBerry::Platform::Graphics::TiledImage::Hardware);
     667
     668    m_layerCompositingThreadClient->setContentsToImage(image);
    658669    m_layerCompositingThread->setNeedsTexture(true);
    659670}
  • trunk/Source/WebKit/blackberry/Api/WebOverlay.h

    r145962 r145968  
    11/*
    2  * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
     2 * Copyright (C) 2012, 2013 Research In Motion Limited. All rights reserved.
    33 *
    44 * This library is free software; you can redistribute it and/or
     
    119119    void invalidate();
    120120
    121     // The client can be used to draw layer contents using Skia.
     121    // The client can be used to draw layer contents.
    122122    void setClient(WebOverlayClient*);
    123123
  • trunk/Source/WebKit/blackberry/Api/WebOverlayClient.h

    r118750 r145968  
    2121
    2222#include "BlackBerryGlobal.h"
    23 
    24 class SkCanvas;
     23#include <BlackBerryPlatformGraphics.h>
    2524
    2625namespace BlackBerry {
     
    3534    virtual ~WebOverlayClient() { }
    3635
    37     virtual void drawOverlayContents(WebOverlay*, SkCanvas*) = 0;
     36    virtual void drawOverlayContents(WebOverlay*, BlackBerry::Platform::Graphics::Drawable*) = 0;
    3837};
    3938
  • trunk/Source/WebKit/blackberry/Api/WebOverlay_p.h

    r145962 r145968  
    11/*
    2  * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
     2 * Copyright (C) 2012, 2013 Research In Motion Limited. All rights reserved.
    33 *
    44 * This library is free software; you can redistribute it and/or
     
    2828#include "WebOverlayOverride.h"
    2929
    30 #include <SkBitmap.h>
     30#include <TiledImage.h>
    3131#include <pthread.h>
    3232#include <wtf/OwnPtr.h>
    3333#include <wtf/RefPtr.h>
    34 
    35 class SkCanvas;
    3634
    3735namespace WTF {
     
    104102    virtual void clear() = 0;
    105103    virtual void invalidate() = 0;
    106     void drawContents(SkCanvas*);
     104    void drawContents(Platform::Graphics::Drawable*);
    107105
    108106    virtual void resetOverrides() = 0;
     
    172170    virtual void notifyFlushRequired(const WebCore::GraphicsLayer*);
    173171    virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& inClip);
    174     virtual bool contentsVisible(const WebCore::GraphicsLayer*, const WebCore::IntRect& contentRect) const { return true; }
     172    virtual bool showDebugBorders(const WebCore::GraphicsLayer*) const { return false; }
     173    virtual bool showRepaintCounter(const WebCore::GraphicsLayer*) const { return false; }
    175174
    176175private:
     
    185184    virtual ~WebOverlayLayerCompositingThreadClient() { }
    186185
    187     void setLayer(WebCore::LayerCompositingThread* layer) { m_layerCompositingThread = layer; }
    188186    void setClient(WebOverlay* owner, WebOverlayClient* client) { m_owner = owner; m_client = client; }
    189187
     
    192190    void invalidate();
    193191
    194     const SkBitmap& contents() const { return m_contents; }
    195     void setContents(const SkBitmap&);
    196 
     192    void setContentsToImage(const BlackBerry::Platform::Graphics::TiledImage&);
    197193    void setContentsToColor(const WebCore::Color&);
     194
     195    const BlackBerry::Platform::Graphics::TiledImage& image() const { return m_image; }
    198196
    199197    // LayerCompositingThreadClient
     
    201199    virtual void layerVisibilityChanged(WebCore::LayerCompositingThread*, bool visible);
    202200    virtual void uploadTexturesIfNeeded(WebCore::LayerCompositingThread*);
    203     virtual void drawTextures(WebCore::LayerCompositingThread*, double scale, int positionLocation, int texCoordLocation);
     201    virtual void drawTextures(WebCore::LayerCompositingThread*, double scale, const Platform::Graphics::GLES2Program&);
    204202    virtual void deleteTextures(WebCore::LayerCompositingThread*);
    205203
     
    208206
    209207private:
     208    bool m_drawsContent;
    210209    RefPtr<WebCore::Texture> m_texture;
    211     bool m_drawsContent;
    212     SkBitmap m_contents;
    213     SkBitmap m_uploadedContents;
     210    BlackBerry::Platform::Graphics::TiledImage m_image;
     211    BlackBerry::Platform::Graphics::TiledImage m_uploadedImage;
    214212    WebCore::Color m_color;
    215     WebCore::LayerCompositingThread* m_layerCompositingThread;
    216213    WebOverlay* m_owner;
    217214    WebOverlayClient* m_client;
     
    263260private:
    264261    WebOverlayLayerCompositingThreadClient* m_layerCompositingThreadClient;
     262    const unsigned char* m_data;
    265263};
    266264
  • trunk/Source/WebKit/blackberry/Api/WebPageCompositor.cpp

    r145953 r145968  
    4646    : m_client(client)
    4747    , m_webPage(page)
     48    , m_context(0)
    4849    , m_drawsRootLayer(false)
    4950    , m_childWindowPlacement(WebPageCompositor::DocumentCoordinates)
  • trunk/Source/WebKit/blackberry/ChangeLog

    r145962 r145968  
     12013-03-15  Arvid Nilsson  <anilsson@rim.com>
     2
     3        [BlackBerry] BlackBerry::Platform::Graphics::GraphicsContext integration related changes in Source/WebKit/blackberry
     4        https://bugs.webkit.org/show_bug.cgi?id=112467
     5
     6        Reviewed by Rob Buis.
     7
     8        PR 293208
     9
     10        This patch contains contributions from many members of the BlackBerry
     11        WebKit team:
     12
     13        Mike Lattanzio
     14        Arvid Nilsson
     15        Jakob Petsovits
     16        Konrad Piascik
     17        Jeff Rogers
     18        Filip Spacek
     19
     20        * Api/BackingStore.cpp:
     21        (BlackBerry::WebKit::BackingStorePrivate::render):
     22        (BlackBerry::WebKit::BackingStorePrivate::blitVisibleContents):
     23        (BlackBerry::WebKit::BackingStorePrivate::compositeContents):
     24        (BlackBerry::WebKit::BackingStorePrivate::tileSize):
     25        * Api/WebOverlay.cpp:
     26        (BlackBerry::WebKit::WebOverlayPrivate::drawContents):
     27        (BlackBerry::WebKit::WebOverlayPrivateWebKitThread::paintContents):
     28        (BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::WebOverlayLayerCompositingThreadClient):
     29        (BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::setContentsToImage):
     30        (BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::clearUploadedContents):
     31        (BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::setContentsToColor):
     32        (BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::uploadTexturesIfNeeded):
     33        (BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::drawTextures):
     34        (BlackBerry::WebKit::WebOverlayPrivateCompositingThread::WebOverlayPrivateCompositingThread):
     35        (BlackBerry::WebKit::WebOverlayPrivateCompositingThread::removeFromParent):
     36        (BlackBerry::WebKit::WebOverlayPrivateCompositingThread::setContentsToImage):
     37        * Api/WebOverlay.h:
     38        * Api/WebOverlayClient.h:
     39        * Api/WebOverlay_p.h:
     40        (WebOverlayPrivate):
     41        (BlackBerry::WebKit::WebOverlayPrivateWebKitThread::showDebugBorders):
     42        (BlackBerry::WebKit::WebOverlayPrivateWebKitThread::showRepaintCounter):
     43        (WebOverlayLayerCompositingThreadClient):
     44        (BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::image):
     45        (WebOverlayPrivateCompositingThread):
     46        * Api/WebPageCompositor.cpp:
     47        (BlackBerry::WebKit::WebPageCompositorPrivate::WebPageCompositorPrivate):
     48        * WebKitSupport/BackingStoreTile.cpp:
     49        (BlackBerry::WebKit::TileBuffer::~TileBuffer):
     50        (BlackBerry::WebKit::TileBuffer::nativeBuffer):
     51        (BlackBerry::WebKit::TileBuffer::paintBackground):
     52        * WebKitSupport/DefaultTapHighlight.cpp:
     53        (BlackBerry::WebKit::DefaultTapHighlight::paintContents):
     54        (BlackBerry::WebKit::DefaultTapHighlight::showDebugBorders):
     55        (WebKit):
     56        (BlackBerry::WebKit::DefaultTapHighlight::showRepaintCounter):
     57        * WebKitSupport/DefaultTapHighlight.h:
     58        (DefaultTapHighlight):
     59        * WebKitSupport/InspectorOverlayBlackBerry.cpp:
     60        (BlackBerry::WebKit::InspectorOverlay::showDebugBorders):
     61        (WebKit):
     62        (BlackBerry::WebKit::InspectorOverlay::showRepaintCounter):
     63        * WebKitSupport/InspectorOverlayBlackBerry.h:
     64        (InspectorOverlay):
     65        * WebKitSupport/SelectionOverlay.cpp:
     66        (BlackBerry::WebKit::SelectionOverlay::draw):
     67        (BlackBerry::WebKit::SelectionOverlay::hide):
     68        (BlackBerry::WebKit::SelectionOverlay::paintContents):
     69        (BlackBerry::WebKit::SelectionOverlay::showDebugBorders):
     70        (WebKit):
     71        (BlackBerry::WebKit::SelectionOverlay::showRepaintCounter):
     72        * WebKitSupport/SelectionOverlay.h:
     73        (SelectionOverlay):
     74        * WebKitSupport/SurfacePool.cpp:
     75        (BlackBerry::WebKit::SurfacePool::createPlatformGraphicsContext):
     76        (BlackBerry::WebKit::SurfacePool::destroyPlatformGraphicsContext):
     77        (BlackBerry::WebKit::SurfacePool::waitForBuffer):
     78        (BlackBerry::WebKit::SurfacePool::notifyBuffersComposited):
     79        (BlackBerry::WebKit::SurfacePool::destroyPlatformSync):
     80        * WebKitSupport/SurfacePool.h:
     81
    1822013-03-15  Arvid Nilsson  <anilsson@rim.com>
    283
  • trunk/Source/WebKit/blackberry/WebKitSupport/BackingStoreTile.cpp

    r136965 r145968  
    4646TileBuffer::~TileBuffer()
    4747{
    48     destroyBuffer(m_nativeBuffer);
     48    Platform::Graphics::destroyBuffer(m_nativeBuffer);
    4949}
    5050
     
    102102{
    103103    if (!m_nativeBuffer)
    104         m_nativeBuffer = createBuffer(m_size, Platform::Graphics::AlwaysBacked, SurfacePool::globalSurfacePool()->sharedPixmapGroup());
     104        m_nativeBuffer = Platform::Graphics::createBuffer(m_size, Platform::Graphics::AlwaysBacked, SurfacePool::globalSurfacePool()->sharedPixmapGroup());
    105105
    106106    return m_nativeBuffer;
     
    116116    m_backgroundPainted = true;
    117117
    118     clearBuffer(nativeBuffer(), 0, 0, 0, 0);
     118    Platform::Graphics::clearBuffer(nativeBuffer(), 0, 0, 0, 0);
    119119}
    120120
  • trunk/Source/WebKit/blackberry/WebKitSupport/DefaultTapHighlight.cpp

    r144640 r145968  
    2525#include "GraphicsContext.h"
    2626#include "Path.h"
    27 #include "PlatformContextSkia.h"
    2827#include "WebAnimation.h"
    2928#include "WebPage_p.h"
    3029
     30#include <BlackBerryPlatformGraphicsContext.h>
    3131#include <BlackBerryPlatformMessageClient.h>
    3232
     
    128128void DefaultTapHighlight::paintContents(const GraphicsLayer*, GraphicsContext& c, GraphicsLayerPaintingPhase, const IntRect& /*inClip*/)
    129129{
    130     std::vector<Platform::IntRect> rects = m_region.rects();
    131     Platform::IntRect rect = m_region.extents();
    132     SkRegion overlayRegion;
    133 
    134     unsigned rectCount = m_region.numRects();
    135     if (!rectCount)
     130    if (!m_region.numRects())
    136131        return;
    137132
    138     for (unsigned i = 0; i < rectCount; ++i) {
    139         Platform::IntRect rectToPaint = rects[i];
    140         SkIRect r = SkIRect::MakeXYWH(rectToPaint.x(), rectToPaint.y(), rectToPaint.width(), rectToPaint.height());
    141         overlayRegion.op(r, SkRegion::kUnion_Op);
    142     }
     133    Path path(m_region.boundaryPath());
    143134
    144     SkPath pathToPaint;
    145     overlayRegion.getBoundaryPath(&pathToPaint);
    146 
    147     Path path(pathToPaint);
    148135    c.save();
     136    const Platform::IntRect& rect = m_region.extents();
    149137    c.translate(-rect.x(), -rect.y());
    150138
     
    159147}
    160148
    161 bool DefaultTapHighlight::contentsVisible(const GraphicsLayer*, const IntRect& contentRect) const
     149bool DefaultTapHighlight::showDebugBorders(const GraphicsLayer* layer) const
    162150{
    163     // This layer is typically small enough that we can afford to cache all tiles and never
    164     // risk checkerboarding.
    165     return true;
     151    return m_page->showDebugBorders(layer);
     152}
     153
     154bool DefaultTapHighlight::showRepaintCounter(const GraphicsLayer* layer) const
     155{
     156    return m_page->showRepaintCounter(layer);
    166157}
    167158
  • trunk/Source/WebKit/blackberry/WebKitSupport/DefaultTapHighlight.h

    r144640 r145968  
    11/*
    2  * Copyright (C) 2011, 2012 Research In Motion Limited. All rights reserved.
     2 * Copyright (C) 2011, 2012, 2013 Research In Motion Limited. All rights reserved.
    33 *
    44 * This library is free software; you can redistribute it and/or
     
    5858    virtual void notifyFlushRequired(const WebCore::GraphicsLayer*);
    5959    virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& inClip);
    60     virtual bool contentsVisible(const WebCore::GraphicsLayer*, const WebCore::IntRect& contentRect) const;
     60    virtual bool showDebugBorders(const WebCore::GraphicsLayer*) const;
     61    virtual bool showRepaintCounter(const WebCore::GraphicsLayer*) const;
    6162
    6263private:
  • trunk/Source/WebKit/blackberry/WebKitSupport/InspectorOverlayBlackBerry.cpp

    r133517 r145968  
    11/*
    2  * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
     2 * Copyright (C) 2012, 2013 Research In Motion Limited. All rights reserved.
    33 *
    44 * This library is free software; you can redistribute it and/or
     
    5757}
    5858
     59bool InspectorOverlay::showDebugBorders(const WebCore::GraphicsLayer* layer) const
     60{
     61    return m_webPage->showDebugBorders(layer);
     62}
     63
     64bool InspectorOverlay::showRepaintCounter(const WebCore::GraphicsLayer* layer) const
     65{
     66    return m_webPage->showRepaintCounter(layer);
     67}
    5968#endif
    6069
  • trunk/Source/WebKit/blackberry/WebKitSupport/InspectorOverlayBlackBerry.h

    r133517 r145968  
    11/*
    2  * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
     2 * Copyright (C) 2012, 2013 Research In Motion Limited. All rights reserved.
    33 *
    44 * This library is free software; you can redistribute it and/or
     
    5555    virtual void notifyFlushRequired(const WebCore::GraphicsLayer*);
    5656    virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& inClip);
     57    virtual bool showDebugBorders(const WebCore::GraphicsLayer*) const;
     58    virtual bool showRepaintCounter(const WebCore::GraphicsLayer*) const;
    5759#endif
    5860
  • trunk/Source/WebKit/blackberry/WebKitSupport/SelectionOverlay.cpp

    r133517 r145968  
    11/*
    2  * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
     2 * Copyright (C) 2012, 2013 Research In Motion Limited. All rights reserved.
    33 *
    44 * This library is free software; you can redistribute it and/or
     
    2525#include "GraphicsContext.h"
    2626#include "LayerMessage.h"
     27#include "LayerWebKitThread.h"
    2728#include "Path.h"
    28 #include "PlatformContextSkia.h"
    2929#include "RenderTheme.h"
    3030#include "WebPage_p.h"
     
    4646}
    4747
    48 void SelectionOverlay::draw(const Platform::IntRectRegion& region)
     48void SelectionOverlay::draw(const Selection& selection)
    4949{
    5050    ASSERT(BlackBerry::Platform::webKitThreadMessageClient()->isCurrentThread());
    5151
    52     m_region = region;
    53     FloatRect rect = IntRect(m_region.extents());
    54     if (rect.isEmpty()) {
    55         hide();
    56         return;
     52    m_selection = selection;
     53
     54    while (m_layers.size() < m_selection.size())
     55        m_layers.append(GraphicsLayer::create(this));
     56
     57    m_layers.resize(m_selection.size());
     58
     59    size_t i = 0;
     60    for (Selection::iterator it = m_selection.begin(); it != m_selection.end(); ++it, ++i) {
     61        GraphicsLayer* parent = it->key;
     62        GraphicsLayer* overlay = m_layers[i].get();
     63
     64        parent->platformLayer()->addOverlay(overlay->platformLayer());
     65        overlay->setPosition(FloatPoint::zero());
     66        if (parent == m_page->m_overlayLayer)
     67            overlay->setSize(m_page->contentsSize());
     68        else
     69            overlay->setSize(parent->size());
     70        overlay->setAnchorPoint(FloatPoint3D(0, 0, 0));
     71        overlay->setDrawsContent(true);
     72        overlay->setNeedsDisplay();
    5773    }
    58 
    59     if (!m_overlay)
    60         m_overlay = adoptPtr(new WebOverlay(this));
    61 
    62     m_page->m_webPage->addOverlay(m_overlay.get());
    63     m_overlay->resetOverrides();
    64     m_overlay->setPosition(rect.location());
    65     m_overlay->setSize(rect.size());
    66     m_overlay->setDrawsContent(true);
    67     m_overlay->setOpacity(1.0);
    68     m_overlay->invalidate();
    6974}
    7075
     
    7378    ASSERT(BlackBerry::Platform::webKitThreadMessageClient()->isCurrentThread());
    7479
    75     if (!m_overlay)
    76         return;
    77 
    78     m_page->m_webPage->removeOverlay(m_overlay.get());
     80    for (size_t i = 0; i < m_layers.size(); ++i)
     81        m_layers[i]->platformLayer()->removeFromSuperlayer();
     82    m_selection.clear();
    7983}
    8084
     
    8488}
    8589
    86 void SelectionOverlay::paintContents(const GraphicsLayer*, GraphicsContext& c, GraphicsLayerPaintingPhase, const IntRect& inClip)
     90void SelectionOverlay::paintContents(const GraphicsLayer* layer, GraphicsContext& c, GraphicsLayerPaintingPhase, const IntRect& clip)
    8791{
    88     std::vector<Platform::IntRect> rects = m_region.rects();
    89     Platform::IntRect rect = m_region.extents();
    90     SkRegion windowRegion;
    91 
    92     unsigned rectCount = m_region.numRects();
    93     if (!rectCount)
     92    if (!layer->platformLayer()->superlayer())
    9493        return;
    9594
    96     IntRect clip(inClip);
    97     clip.move(rect.x(), rect.y());
    98     for (unsigned i = 0; i < rectCount; ++i) {
    99         IntRect rectToPaint = rects[i];
     95    Selection::iterator it = m_selection.find(layer->platformLayer()->superlayer()->owner());
     96    if (it == m_selection.end())
     97        return;
     98
     99    const Vector<WebCore::FloatQuad>& quads = it->value;
     100
     101    c.save();
     102
     103    Color color = RenderTheme::defaultTheme()->activeSelectionBackgroundColor();
     104    c.setFillColor(color, ColorSpaceDeviceRGB);
     105
     106    for (unsigned i = 0; i < quads.size(); ++i) {
     107        FloatRect rectToPaint = quads[i].boundingBox();
    100108        rectToPaint.intersect(clip);
    101         SkIRect r = SkIRect::MakeXYWH(rectToPaint.x(), rectToPaint.y(), rectToPaint.width(), rectToPaint.height());
    102         windowRegion.op(r, SkRegion::kUnion_Op);
     109        if (rectToPaint.isEmpty())
     110            continue;
     111
     112        c.fillRect(rectToPaint);
    103113    }
    104114
    105     SkPath pathToPaint;
    106     windowRegion.getBoundaryPath(&pathToPaint);
     115    c.restore();
     116}
    107117
    108     Path path(pathToPaint);
    109     c.save();
    110     c.translate(-rect.x(), -rect.y());
     118bool SelectionOverlay::showDebugBorders(const GraphicsLayer* layer) const
     119{
     120    return m_page->showDebugBorders(layer);
     121}
    111122
    112     // Draw selection overlay
    113     Color color = RenderTheme::defaultTheme()->activeSelectionBackgroundColor();
    114     c.setFillColor(color, ColorSpaceDeviceRGB);
    115     c.fillPath(path);
    116 
    117     c.restore();
     123bool SelectionOverlay::showRepaintCounter(const GraphicsLayer* layer) const
     124{
     125    return m_page->showRepaintCounter(layer);
    118126}
    119127
  • trunk/Source/WebKit/blackberry/WebKitSupport/SelectionOverlay.h

    r133517 r145968  
    11/*
    2  * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
     2 * Copyright (C) 2012, 2013 Research In Motion Limited. All rights reserved.
    33 *
    44 * This library is free software; you can redistribute it and/or
     
    2525
    2626#include "Color.h"
     27#include "FloatQuad.h"
    2728#include "GraphicsLayerClient.h"
    28 #include "WebOverlay.h"
     29#include "IntRect.h"
    2930
    3031#include <BlackBerryPlatformIntRectRegion.h>
     32#include <wtf/HashMap.h>
    3133#include <wtf/OwnPtr.h>
    3234#include <wtf/PassOwnPtr.h>
     35#include <wtf/Vector.h>
    3336
    3437namespace BlackBerry {
     
    3942class SelectionOverlay : public WebCore::GraphicsLayerClient {
    4043public:
     44    typedef HashMap<WebCore::GraphicsLayer*, Vector<WebCore::FloatQuad> > Selection;
     45
    4146    static PassOwnPtr<SelectionOverlay> create(WebPagePrivate* page)
    4247    {
     
    4449    }
    4550
    46     virtual ~SelectionOverlay();
     51    ~SelectionOverlay();
    4752
    48     virtual void draw(const Platform::IntRectRegion&);
    49     virtual void hide();
     53    void draw(const Selection&);
     54    void hide();
    5055
    5156    // GraphicsLayerClient
    5257    virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double time) { }
    5358    virtual void notifyFlushRequired(const WebCore::GraphicsLayer*);
    54     virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& inClip);
     59    virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect&);
     60    virtual bool showDebugBorders(const WebCore::GraphicsLayer*) const;
     61    virtual bool showRepaintCounter(const WebCore::GraphicsLayer*) const;
    5562
    5663private:
     
    5865
    5966    WebPagePrivate* m_page;
    60     OwnPtr<WebOverlay> m_overlay;
    61     BlackBerry::Platform::IntRectRegion m_region;
     67    Selection m_selection;
     68    Vector<OwnPtr<WebCore::GraphicsLayer> > m_layers;
    6269};
    6370
  • trunk/Source/WebKit/blackberry/WebKitSupport/SurfacePool.cpp

    r142677 r145968  
    11/*
    2  * Copyright (C) 2010, 2011, 2012 Research In Motion Limited. All rights reserved.
     2 * Copyright (C) 2010, 2011, 2012, 2013 Research In Motion Limited. All rights reserved.
    33 *
    44 * This library is free software; you can redistribute it and/or
     
    2020#include "SurfacePool.h"
    2121
    22 #include "PlatformContextSkia.h"
    23 
    2422#include <BlackBerryPlatformExecutableMessage.h>
    2523#include <BlackBerryPlatformGraphics.h>
     
    123121PlatformGraphicsContext* SurfacePool::createPlatformGraphicsContext(Platform::Graphics::Drawable* drawable) const
    124122{
    125     return new WebCore::PlatformContextSkia(drawable);
     123    return drawable;
    126124}
    127125
    128126void SurfacePool::destroyPlatformGraphicsContext(PlatformGraphicsContext* platformGraphicsContext) const
    129127{
    130     delete platformGraphicsContext;
    131128}
    132129
     
    204201    if (!m_hasFenceExtension)
    205202        return;
    206 
    207 #if BLACKBERRY_PLATFORM_GRAPHICS_EGL
    208     EGLSyncKHR platformSync;
    209 
    210     {
    211         Platform::MutexLocker locker(&m_mutex);
    212         platformSync = tileBuffer->fence()->takePlatformSync();
    213     }
    214 
    215     if (!platformSync)
    216         return;
    217 
    218     if (!eglClientWaitSyncKHR(Platform::Graphics::eglDisplay(), platformSync, 0, 100000000LL))
    219         Platform::logAlways(Platform::LogLevelWarn, "Failed to wait for EGLSyncKHR object!\n");
    220 
    221     // Instead of assuming eglDestroySyncKHR is thread safe, we add it to
    222     // a garbage list for later collection on the thread that created it.
    223     {
    224         Platform::MutexLocker locker(&m_mutex);
    225         m_garbage.insert(platformSync);
    226     }
    227 #endif
    228203}
    229204
     
    232207    if (!m_hasFenceExtension)
    233208        return;
    234 
    235 #if BLACKBERRY_PLATFORM_GRAPHICS_EGL
    236     Platform::MutexLocker locker(&m_mutex);
    237 
    238     EGLDisplay display = Platform::Graphics::eglDisplay();
    239 
    240     // The EGL_KHR_fence_sync spec is nice enough to specify that the sync object
    241     // is not actually deleted until everyone has stopped using it.
    242     for (std::set<void*>::const_iterator it = m_garbage.begin(); it != m_garbage.end(); ++it)
    243         eglDestroySyncKHR(display, *it);
    244     m_garbage.clear();
    245 
    246     // If we didn't blit anything, we don't need to create a new fence.
    247     if (tileBuffers.isEmpty())
    248         return;
    249 
    250     // Create a new fence and assign to the tiles that were blit. Invalidate any previous
    251     // fence that may be active among these tiles and add its sync object to the garbage set
    252     // for later destruction to make sure it doesn't leak.
    253     RefPtr<Fence> fence = Fence::create(eglCreateSyncKHR(display, EGL_SYNC_FENCE_KHR, 0));
    254     for (unsigned int i = 0; i < tileBuffers.size(); ++i)
    255         tileBuffers[i]->setFence(fence);
    256 #endif
    257209}
    258210
    259211void SurfacePool::destroyPlatformSync(void* platformSync)
    260212{
    261 #if BLACKBERRY_PLATFORM_GRAPHICS_EGL && USE(SKIA)
    262     Platform::MutexLocker locker(&m_mutex);
    263     m_garbage.insert(platformSync);
    264 #endif
    265 }
    266 
    267 }
    268 }
     213}
     214
     215}
     216}
  • trunk/Source/WebKit/blackberry/WebKitSupport/SurfacePool.h

    r142037 r145968  
    11/*
    2  * Copyright (C) 2010, 2011, 2012 Research In Motion Limited. All rights reserved.
     2 * Copyright (C) 2010, 2011, 2012, 2013 Research In Motion Limited. All rights reserved.
    33 *
    44 * This library is free software; you can redistribute it and/or
     
    2121
    2222#include "BackingStoreTile.h"
    23 
    24 #include "PlatformContextSkia.h"
     23#include "GraphicsContext.h"
    2524
    2625#include <BlackBerryPlatformGraphics.h>
Note: See TracChangeset for help on using the changeset viewer.