예제 #1
0
void PaintedSurface::prepare(GLWebViewState* state)
{
    XLOG("PS %p has PL %p, DL %p", this, m_paintingLayer, m_drawingLayer);
    LayerAndroid* paintingLayer = m_paintingLayer;
    if (!paintingLayer)
        paintingLayer = m_drawingLayer;

    if (!paintingLayer)
        return;

    bool startFastSwap = false;
    if (state->isScrolling()) {
        // when scrolling, block updates and swap tiles as soon as they're ready
        startFastSwap = true;
    }

    XLOG("prepare layer %d %x at scale %.2f",
         paintingLayer->uniqueId(), paintingLayer,
         paintingLayer->getScale());

    IntRect visibleArea = computeVisibleArea(paintingLayer);
    IntRect prepareArea = computePrepareArea(paintingLayer); // SAMSUNG CHANGE

    m_scale = state->scale();

    // If we do not have text, we may as well limit ourselves to
    // a scale factor of one... this saves up textures.
    if (m_scale > 1 && !paintingLayer->hasText())
        m_scale = 1;

    m_tiledTexture->prepare(state, m_scale, m_pictureUsed != paintingLayer->pictureUsed(),
                            startFastSwap, visibleArea, prepareArea); // SAMSUNG CHANGE
}
예제 #2
0
void ChromeClientAndroid::enterFullscreenForNode(Node* node)
{
      if (!node->hasTagName(HTMLNames::videoTag))
          return;

      HTMLMediaElement* videoElement = static_cast<HTMLMediaElement*>(node);
      String url = videoElement->currentSrc();
      LayerAndroid* layer = videoElement->platformLayer();
      if (!layer)
          return;

      FrameView* frameView = m_webFrame->page()->mainFrame()->view();
      android::WebViewCore* core = android::WebViewCore::getWebViewCore(frameView);
      if (core)
          core->enterFullscreenForVideoLayer(layer->uniqueId(), url);
}
LayerAndroid* deserializeLayer(int version, SkStream* stream)
{
    int type = stream->readU8();
    if (type == LTNone)
        return 0;
    // Cast is to disambiguate between ctors.
    LayerAndroid *layer;
    if (type == LTLayerAndroid)
        layer = new LayerAndroid((RenderLayer*) 0);
    else if (type == LTScrollableLayerAndroid)
        layer = new ScrollableLayerAndroid((RenderLayer*) 0);
    else {
        ALOGV("Unexpected layer type: %d, aborting!", type);
        return 0;
    }

    // Layer fields
    layer->setShouldInheritFromRootTransform(stream->readBool());
    layer->setOpacity(stream->readScalar());
    layer->setSize(stream->readScalar(), stream->readScalar());
    layer->setPosition(stream->readScalar(), stream->readScalar());
    layer->setAnchorPoint(stream->readScalar(), stream->readScalar());
    layer->setMatrix(readMatrix(stream));
    layer->setChildrenMatrix(readMatrix(stream));

    // LayerAndroid fields
    layer->m_haveClip = stream->readBool();

    // Keep the legacy serialization/deserialization format...
    bool isFixed = stream->readBool();

    layer->m_backgroundColorSet = stream->readBool();

    bool isIframe = stream->readBool();
    // If we are a scrollable layer android, we are an iframe content
    if (isIframe && type == LTScrollableLayerAndroid) {
         IFrameContentLayerAndroid* iframeContent = new IFrameContentLayerAndroid(*layer);
         layer->unref();
         layer = iframeContent;
    } else if (isIframe) { // otherwise we are just the iframe (we use it to compute offset)
         IFrameLayerAndroid* iframe = new IFrameLayerAndroid(*layer);
         layer->unref();
         layer = iframe;
    }

    if (isFixed) {
        FixedPositioning* fixedPosition = new FixedPositioning(layer);

        fixedPosition->m_fixedLeft = readSkLength(stream);
        fixedPosition->m_fixedTop = readSkLength(stream);
        fixedPosition->m_fixedRight = readSkLength(stream);
        fixedPosition->m_fixedBottom = readSkLength(stream);
        fixedPosition->m_fixedMarginLeft = readSkLength(stream);
        fixedPosition->m_fixedMarginTop = readSkLength(stream);
        fixedPosition->m_fixedMarginRight = readSkLength(stream);
        fixedPosition->m_fixedMarginBottom = readSkLength(stream);
        fixedPosition->m_fixedRect = readSkRect(stream);
        fixedPosition->m_renderLayerPos.setX(stream->readS32());
        fixedPosition->m_renderLayerPos.setY(stream->readS32());

        layer->setFixedPosition(fixedPosition);
    } else {
        // Not a fixed element, bypass the values in the stream
        readSkLength(stream); // fixedLeft
        readSkLength(stream); // fixedTop
        readSkLength(stream); // fixedRight
        readSkLength(stream); // fixedBottom
        readSkLength(stream); // fixedMarginLeft
        readSkLength(stream); // fixedMarginTop
        readSkLength(stream); // fixedMarginRight
        readSkLength(stream); // fixedMarginBottom
        readSkRect(stream);   // fixedRect
        stream->readS32();    // renderLayerPos.x()
        stream->readS32();    // renderLayerPos.y()
    }

    layer->m_backfaceVisibility = stream->readBool();
    layer->m_visible = stream->readBool();
    layer->m_backgroundColor = stream->readU32();
    layer->m_preserves3D = stream->readBool();
    layer->m_anchorPointZ = stream->readScalar();
    layer->m_drawOpacity = stream->readScalar();
    bool hasContentsImage = stream->readBool();
    if (hasContentsImage) {
        int size = stream->readU32();
        SkAutoMalloc storage(size);
        stream->read(storage.get(), size);
        SkFlattenableReadBuffer buffer(storage.get(), size);
        SkBitmap contentsImage;
        contentsImage.unflatten(buffer);
        SkBitmapRef* imageRef = new SkBitmapRef(contentsImage);
        layer->setContentsImage(imageRef);
        delete imageRef;
    }
    bool hasRecordingPicture = stream->readBool();
    if (hasRecordingPicture) {
        SkPicture* picture = new SkPicture(stream);
        PictureLayerContent* content = new PictureLayerContent(picture);
        layer->setContent(content);
        SkSafeUnref(content);
        SkSafeUnref(picture);
    }
    int animationCount = stream->readU32(); // TODO: Support (maybe?)
    readTransformationMatrix(stream, layer->m_transform);
    readTransformationMatrix(stream, layer->m_childrenTransform);
    if (type == LTScrollableLayerAndroid) {
        ScrollableLayerAndroid* scrollableLayer =
                static_cast<ScrollableLayerAndroid*>(layer);
        scrollableLayer->m_scrollLimits.set(
                stream->readScalar(),
                stream->readScalar(),
                stream->readScalar(),
                stream->readScalar());
    }
    int childCount = stream->readU32();
    for (int i = 0; i < childCount; i++) {
        LayerAndroid *childLayer = deserializeLayer(version, stream);
        if (childLayer)
            layer->addChild(childLayer);
    }
    ALOGV("Created layer with id %d", layer->uniqueId());
    return layer;
}
LayerAndroid* deserializeLayer(SkStream* stream)
{
    int type = stream->readU8();
    if (type == LTNone)
        return 0;
    // Cast is to disambiguate between ctors.
    LayerAndroid *layer;
    if (type == LTLayerAndroid)
        layer = new LayerAndroid((RenderLayer*) 0);
    else if (type == LTScrollableLayerAndroid)
        layer = new ScrollableLayerAndroid((RenderLayer*) 0);
    else {
        XLOG("Unexpected layer type: %d, aborting!", type);
        return 0;
    }

    // Layer fields
    layer->setShouldInheritFromRootTransform(stream->readBool());
    layer->setOpacity(stream->readScalar());
    layer->setSize(stream->readScalar(), stream->readScalar());
    layer->setPosition(stream->readScalar(), stream->readScalar());
    layer->setAnchorPoint(stream->readScalar(), stream->readScalar());
    layer->setMatrix(readMatrix(stream));
    layer->setChildrenMatrix(readMatrix(stream));

    // LayerAndroid fields
    layer->m_haveClip = stream->readBool();
    layer->m_isFixed = stream->readBool();
    layer->m_backgroundColorSet = stream->readBool();
    layer->m_isIframe = stream->readBool();
    layer->m_fixedLeft = readSkLength(stream);
    layer->m_fixedTop = readSkLength(stream);
    layer->m_fixedRight = readSkLength(stream);
    layer->m_fixedBottom = readSkLength(stream);
    layer->m_fixedMarginLeft = readSkLength(stream);
    layer->m_fixedMarginTop = readSkLength(stream);
    layer->m_fixedMarginRight = readSkLength(stream);
    layer->m_fixedMarginBottom = readSkLength(stream);
    layer->m_fixedRect = readSkRect(stream);
    layer->m_renderLayerPos.setX(stream->readS32());
    layer->m_renderLayerPos.setY(stream->readS32());
    layer->m_backfaceVisibility = stream->readBool();
    layer->m_visible = stream->readBool();
    layer->m_backgroundColor = stream->readU32();
    layer->m_preserves3D = stream->readBool();
    layer->m_anchorPointZ = stream->readScalar();
    layer->m_drawOpacity = stream->readScalar();
    bool hasContentsImage = stream->readBool();
    if (hasContentsImage) {
        int size = stream->readU32();
        SkAutoMalloc storage(size);
        stream->read(storage.get(), size);
        SkFlattenableReadBuffer buffer(storage.get(), size);
        SkBitmap contentsImage;
        contentsImage.unflatten(buffer);
        SkBitmapRef* imageRef = new SkBitmapRef(contentsImage);
        layer->setContentsImage(imageRef);
        delete imageRef;
    }
    bool hasRecordingPicture = stream->readBool();
    if (hasRecordingPicture) {
        layer->m_recordingPicture = new SkPicture(stream);
    }
    int animationCount = stream->readU32(); // TODO: Support (maybe?)
    readTransformationMatrix(stream, layer->m_transform);
    readTransformationMatrix(stream, layer->m_childrenTransform);
    if (type == LTScrollableLayerAndroid) {
        ScrollableLayerAndroid* scrollableLayer =
                static_cast<ScrollableLayerAndroid*>(layer);
        scrollableLayer->m_scrollLimits.set(
                stream->readScalar(),
                stream->readScalar(),
                stream->readScalar(),
                stream->readScalar());
    }
    int childCount = stream->readU32();
    for (int i = 0; i < childCount; i++) {
        LayerAndroid *childLayer = deserializeLayer(stream);
        if (childLayer)
            layer->addChild(childLayer);
    }
    layer->needsRepaint();
    XLOG("Created layer with id %d", layer->uniqueId());
    return layer;
}