void TextureMapperLayer::paintRecursive(const TextureMapperPaintOptions& options) { if (!isVisible()) return; float opacity = options.opacity * m_opacity; RefPtr<BitmapTexture> maskTexture = m_state.maskLayer ? m_state.maskLayer->texture() : 0; TextureMapperPaintOptions paintOptions(options); paintOptions.mask = maskTexture.get(); IntRect surfaceRect; RefPtr<BitmapTexture> surface; if (!shouldPaintToIntermediateSurface()) { paintOptions.opacity = opacity; paintSelfAndChildrenWithReplica(paintOptions); return; } // Prepare a surface to paint into. // We paint into the surface ignoring the opacity/transform of the current layer. surfaceRect = intermediateSurfaceRect(); surface = options.textureMapper->acquireTextureFromPool(surfaceRect.size()); options.textureMapper->bindSurface(surface.get()); paintOptions.opacity = 1; // We have to use combinedForChildren() and not combined(), otherwise preserve-3D doesn't work. paintOptions.transform = m_transform.combinedForChildren().inverse(); paintOptions.offset = -IntSize(surfaceRect.x(), surfaceRect.y()); paintSelfAndChildrenWithReplica(paintOptions); // If we painted the replica, the mask is already applied so we don't need to paint it again. if (m_state.replicaLayer) maskTexture = 0; #if ENABLE(CSS_FILTERS) surface = applyFilters(m_state.filters, options.textureMapper, surface.get(), surfaceRect); #endif options.textureMapper->bindSurface(options.surface.get()); TransformationMatrix targetTransform = TransformationMatrix(options.transform) .multiply(m_transform.combined()) .translate(options.offset.width(), options.offset.height()); options.textureMapper->drawTexture(*surface.get(), surfaceRect, targetTransform, opacity, maskTexture.get()); }
IntRect TextureMapperLayer::intermediateSurfaceRect() { // FIXME: Add an inverse transform to LayerTransform. return intermediateSurfaceRect(m_transform.combined().inverse()); }