void LayerAndroid::updateLocalTransformAndClip(const TransformationMatrix& parentMatrix, const FloatRect& clipping) { FloatPoint position(getPosition().x() + m_replicatedLayerPosition.x() - getScrollOffset().x(), getPosition().y() + m_replicatedLayerPosition.y() - getScrollOffset().y()); float originX = getAnchorPoint().x() * getWidth(); float originY = getAnchorPoint().y() * getHeight(); TransformationMatrix localMatrix; if (isPositionFixed()) m_drawTransform.makeIdentity(); else m_drawTransform = parentMatrix; m_drawTransform.translate3d(originX + position.x(), originY + position.y(), anchorPointZ()); m_drawTransform.multiply(m_transform); m_drawTransform.translate3d(-originX, -originY, -anchorPointZ()); m_drawTransformUnfudged = m_drawTransform; if (m_drawTransform.isIdentityOrTranslation() && surface() && surface()->allowTransformFudging()) { // adjust the translation coordinates of the draw transform matrix so // that layers (defined in content coordinates) will align to display/view pixels // the surface may not allow fudging if it uses the draw transform at paint time float desiredContentX = round(m_drawTransform.m41() * m_scale) / m_scale; float desiredContentY = round(m_drawTransform.m42() * m_scale) / m_scale; ALOGV("fudging translation from %f, %f to %f, %f", m_drawTransform.m41(), m_drawTransform.m42(), desiredContentX, desiredContentY); m_drawTransform.setM41(desiredContentX); m_drawTransform.setM42(desiredContentY); } m_zValue = TilesManager::instance()->shader()->zValue(m_drawTransform, getSize().width(), getSize().height()); if (m_haveClip) { // The clipping rect calculation and intersetion will be done in content // coordinates. FloatRect rect(0, 0, getWidth(), getHeight()); FloatRect clip = m_drawTransform.mapRect(rect); clip.intersect(clipping); setDrawClip(clip); } else { setDrawClip(clipping); } ALOGV("%s - %d %f %f %f %f", subclassType() == BaseLayer ? "BASE" : "nonbase", m_haveClip, m_clippingRect.x(), m_clippingRect.y(), m_clippingRect.width(), m_clippingRect.height()); setVisible(m_backfaceVisibility || m_drawTransform.inverse().m33() >= 0); }
void WKCACFLayer::printLayer(int indent) const { CGPoint layerPosition = position(); CGPoint layerAnchorPoint = anchorPoint(); CGRect layerBounds = bounds(); printIndent(indent); fprintf(stderr, "(%s [%g %g %g] [%g %g %g %g] [%g %g %g]\n", isTransformLayer() ? "transform-layer" : "layer", layerPosition.x, layerPosition.y, zPosition(), layerBounds.origin.x, layerBounds.origin.y, layerBounds.size.width, layerBounds.size.height, layerAnchorPoint.x, layerAnchorPoint.y, anchorPointZ()); // Print name if needed String layerName = name(); if (!layerName.isEmpty()) { printIndent(indent + 1); fprintf(stderr, "(name %s)\n", layerName.utf8().data()); } // Print masksToBounds if needed bool layerMasksToBounds = masksToBounds(); if (layerMasksToBounds) { printIndent(indent + 1); fprintf(stderr, "(masksToBounds true)\n"); } // Print opacity if needed float layerOpacity = opacity(); if (layerOpacity != 1) { printIndent(indent + 1); fprintf(stderr, "(opacity %hf)\n", layerOpacity); } // Print sublayerTransform if needed CATransform3D layerTransform = sublayerTransform(); if (!CATransform3DIsIdentity(layerTransform)) { printIndent(indent + 1); fprintf(stderr, "(sublayerTransform "); printTransform(layerTransform); fprintf(stderr, ")\n"); } // Print transform if needed layerTransform = transform(); if (!CATransform3DIsIdentity(layerTransform)) { printIndent(indent + 1); fprintf(stderr, "(transform "); printTransform(layerTransform); fprintf(stderr, ")\n"); } // Print contents if needed CGImageRef layerContents = contents(); if (layerContents) { printIndent(indent + 1); fprintf(stderr, "(contents (image [%d %d]))\n", CGImageGetWidth(layerContents), CGImageGetHeight(layerContents)); } // Print sublayers if needed int n = numSublayers(); if (n > 0) { printIndent(indent + 1); fprintf(stderr, "(sublayers\n"); for (int i = 0; i < n; ++i) sublayerAtIndex(i)->printLayer(indent + 2); printIndent(indent + 1); fprintf(stderr, ")\n"); } printIndent(indent); fprintf(stderr, ")\n"); }