diff options
Diffstat (limited to 'Source/WebCore')
8 files changed, 79 insertions, 17 deletions
| diff --git a/Source/WebCore/html/HTMLCanvasElement.cpp b/Source/WebCore/html/HTMLCanvasElement.cpp index 764620c..9f51f10 100644 --- a/Source/WebCore/html/HTMLCanvasElement.cpp +++ b/Source/WebCore/html/HTMLCanvasElement.cpp @@ -79,7 +79,19 @@ HTMLCanvasElement::HTMLCanvasElement(const QualifiedName& tagName, Document* doc      , m_size(DefaultWidth, DefaultHeight)      , m_rendererIsCanvas(false)      , m_ignoreReset(false) +#ifdef ANDROID +    /* In Android we capture the drawing into a displayList, and then +       replay that list at various scale factors (sometimes zoomed out, other +       times zoomed in for "normal" reading, yet other times at arbitrary +       zoom values based on the user's choice). In all of these cases, we do +       not re-record the displayList, hence it is usually harmful to perform +       any pre-rounding, since we just don't know the actual drawing resolution +       at record time. +    */ +    , m_pageScaleFactor(1) +#else      , m_pageScaleFactor(document->frame() ? document->frame()->page()->chrome()->scaleFactor() : 1) +#endif      , m_originClean(true)      , m_hasCreatedImageBuffer(false)  { diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp index 97ff692..65e0ec1 100644 --- a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp @@ -706,23 +706,38 @@ void LayerAndroid::showLayer(int indent)          this->getChild(i)->showLayer(indent + 1);  } -void LayerAndroid::assignTexture(LayerAndroid* oldTree) +// We go through our tree, and if we have layer in the new +// tree that is similar, we tranfer our texture to it. +// Otherwise, we remove ourselves from the texture so +// that TilesManager::swapLayersTextures() have a chance +// at deallocating the textures (PaintedSurfaces) +void LayerAndroid::assignTextureTo(LayerAndroid* newTree)  {      int count = this->countChildren();      for (int i = 0; i < count; i++) -        this->getChild(i)->assignTexture(oldTree); +        this->getChild(i)->assignTextureTo(newTree); -    if (oldTree) { -        LayerAndroid* oldLayer = oldTree->findById(uniqueId()); -        if (oldLayer == this) +    if (newTree) { +        LayerAndroid* newLayer = newTree->findById(uniqueId()); +        if (newLayer == this)              return; - -        if (oldLayer && oldLayer->texture()) { -            oldLayer->texture()->replaceLayer(this); -            m_texture = oldLayer->texture(); -            SkSafeRef(m_texture); +        if (newLayer && m_texture) { +            m_texture->replaceLayer(newLayer); +            newLayer->m_texture = m_texture; +            SkSafeRef(newLayer->m_texture); +        } +        if (!newLayer && m_texture) { +            m_texture->removeLayer(this); +            m_texture = 0;          }      } +} + +void LayerAndroid::createTexture() +{ +    int count = this->countChildren(); +    for (int i = 0; i < count; i++) +        this->getChild(i)->createTexture();      if (needsTexture() && !m_texture)          m_texture = new PaintedSurface(this); diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.h b/Source/WebCore/platform/graphics/android/LayerAndroid.h index c4ed9fe..8ad52e0 100644 --- a/Source/WebCore/platform/graphics/android/LayerAndroid.h +++ b/Source/WebCore/platform/graphics/android/LayerAndroid.h @@ -252,7 +252,8 @@ public:      friend LayerAndroid* android::deserializeLayer(SkStream* stream);      PaintedSurface* texture() { return m_texture; } -    void assignTexture(LayerAndroid* oldTree); +    void assignTextureTo(LayerAndroid* newTree); +    void createTexture();  protected:      virtual void onDraw(SkCanvas*, SkScalar opacity); diff --git a/Source/WebCore/platform/graphics/android/MediaTexture.cpp b/Source/WebCore/platform/graphics/android/MediaTexture.cpp index 3fecfb5..96d136a 100644 --- a/Source/WebCore/platform/graphics/android/MediaTexture.cpp +++ b/Source/WebCore/platform/graphics/android/MediaTexture.cpp @@ -104,10 +104,20 @@ void MediaTexture::drawContent(const TransformationMatrix& matrix)      m_surfaceTexture->updateTexImage(); -    bool forceBlending = ANativeWindow_getFormat(m_surfaceTextureClient.get()) == WINDOW_FORMAT_RGB_565; +    sp<GraphicBuffer> buf = m_surfaceTexture->getCurrentBuffer(); + +    PixelFormat f = buf->getPixelFormat(); +    // only attempt to use alpha blending if alpha channel exists +    bool forceAlphaBlending = !( +        PIXEL_FORMAT_RGBX_8888 == f || +        PIXEL_FORMAT_RGB_888 == f || +        PIXEL_FORMAT_RGB_565 == f || +        PIXEL_FORMAT_RGB_332 == f); +      TilesManager::instance()->shader()->drawLayerQuad(matrix, m_dimensions,                                                        m_textureId, 1.0f, -                                                      forceBlending, GL_TEXTURE_EXTERNAL_OES); +                                                      forceAlphaBlending, +                                                      GL_TEXTURE_EXTERNAL_OES);  }  void MediaTexture::drawVideo(const TransformationMatrix& matrix, const SkRect& parentBounds) diff --git a/Source/WebCore/platform/graphics/android/PaintedSurface.cpp b/Source/WebCore/platform/graphics/android/PaintedSurface.cpp index fe7044c..fd4475b 100644 --- a/Source/WebCore/platform/graphics/android/PaintedSurface.cpp +++ b/Source/WebCore/platform/graphics/android/PaintedSurface.cpp @@ -60,6 +60,7 @@ void PaintedSurface::removeLayer(LayerAndroid* layer)      android::Mutex::Autolock lock(m_layerLock);      if (m_layer != layer)          return; +    SkSafeUnref(m_layer);      m_layer = 0;  } @@ -72,6 +73,8 @@ void PaintedSurface::replaceLayer(LayerAndroid* layer)      if (m_layer && layer->uniqueId() != m_layer->uniqueId())          return; +    SkSafeRef(layer); +    SkSafeUnref(m_layer);      m_layer = layer;  } @@ -140,6 +143,7 @@ bool PaintedSurface::paint(BaseTile* tile, SkCanvas* canvas, unsigned int* pictu  {      m_layerLock.lock();      LayerAndroid* layer = m_layer; +    SkSafeRef(layer);      m_layerLock.unlock();      if (!layer) @@ -148,6 +152,7 @@ bool PaintedSurface::paint(BaseTile* tile, SkCanvas* canvas, unsigned int* pictu      layer->contentDraw(canvas);      m_pictureUsed = layer->pictureUsed();      *pictureUsed = m_pictureUsed; +    SkSafeUnref(layer);      return true;  } @@ -156,10 +161,13 @@ void PaintedSurface::paintExtra(SkCanvas* canvas)  {      m_layerLock.lock();      LayerAndroid* layer = m_layer; +    SkSafeRef(layer);      m_layerLock.unlock();      if (layer)          layer->extraDraw(canvas); + +    SkSafeUnref(layer);  }  float PaintedSurface::opacity() { diff --git a/Source/WebCore/platform/graphics/android/PaintedSurface.h b/Source/WebCore/platform/graphics/android/PaintedSurface.h index 84fe64c..6b6c74f 100644 --- a/Source/WebCore/platform/graphics/android/PaintedSurface.h +++ b/Source/WebCore/platform/graphics/android/PaintedSurface.h @@ -51,12 +51,14 @@ public:          , m_busy(false)      {          TilesManager::instance()->addPaintedSurface(this); +        SkSafeRef(m_layer);  #ifdef DEBUG_COUNT          ClassTracker::instance()->increment("PaintedSurface");  #endif      }      virtual ~PaintedSurface()      { +        SkSafeUnref(m_layer);  #ifdef DEBUG_COUNT          ClassTracker::instance()->decrement("PaintedSurface");  #endif diff --git a/Source/WebCore/platform/graphics/android/TilesManager.cpp b/Source/WebCore/platform/graphics/android/TilesManager.cpp index ba48111..4ada041 100644 --- a/Source/WebCore/platform/graphics/android/TilesManager.cpp +++ b/Source/WebCore/platform/graphics/android/TilesManager.cpp @@ -189,8 +189,22 @@ void TilesManager::resetTextureUsage(TiledPage* page)  void TilesManager::swapLayersTextures(LayerAndroid* oldTree, LayerAndroid* newTree)  { +    if (oldTree) +        oldTree->assignTextureTo(newTree); +      if (newTree) -        newTree->assignTexture(oldTree); +        newTree->createTexture(); + +    WTF::Vector<PaintedSurface*> collect; +    for (unsigned int i = 0; i < m_paintedSurfaces.size(); i++) { +        PaintedSurface* surface = m_paintedSurfaces[i]; +        if (!surface->layer()) +            collect.append(surface); +    } +    for (unsigned int i = 0; i < collect.size(); i++) { +        m_paintedSurfaces.remove(m_paintedSurfaces.find(collect[i])); +        SkSafeUnref(collect[i]); +    }  }  void TilesManager::addPaintedSurface(PaintedSurface* surface) diff --git a/Source/WebCore/rendering/RenderLayerCompositor.cpp b/Source/WebCore/rendering/RenderLayerCompositor.cpp index b8e30cb..e757080 100644 --- a/Source/WebCore/rendering/RenderLayerCompositor.cpp +++ b/Source/WebCore/rendering/RenderLayerCompositor.cpp @@ -621,10 +621,10 @@ bool RenderLayerCompositor::overlapsCompositedLayers(OverlapMap& overlapMap, con  //  bool RenderLayerCompositor::checkForFixedLayers(Vector<RenderLayer*>* list, bool stopAtFixedLayer)  { -    size_t listSize = list->size(); +    int listSize = list->size();      int haveFixedLayer = -1;      bool fixedSibling = false; -    for (size_t j = 0; j < listSize; ++j) { +    for (int j = 0; j < listSize; ++j) {          RenderLayer* currentLayer = list->at(j);          if (currentLayer->isFixed() && needsToBeComposited(currentLayer)) {              haveFixedLayer = j; @@ -644,7 +644,7 @@ bool RenderLayerCompositor::checkForFixedLayers(Vector<RenderLayer*>* list, bool              if (stopAtFixedLayer)                  stop = haveFixedLayer + 1; -            for (size_t k = j - 1; k >= stop; --k) { +            for (int k = j - 1; k >= stop; --k) {                  RenderLayer* aLayer = list->at(k);                  if (aLayer && aLayer->renderer()) {                      IntRect bounds = aLayer->renderer()->localToAbsoluteQuad( | 
