void PlatformCALayer::ensureAnimationsSubmitted() { resubmitAllAnimations(this); PlatformCALayerList children; intern(this)->getSublayers(children); for (size_t i = 0; i < children.size(); ++i) children[i]->ensureAnimationsSubmitted(); }
void PlatformCALayerWinInternal::getSublayers(PlatformCALayerList& list) const { CFArrayRef sublayers = CACFLayerGetSublayers(owner()->platformLayer()); if (!sublayers) { list.clear(); return; } size_t count = CFArrayGetCount(sublayers); list.resize(count); for (size_t arrayIndex = 0; arrayIndex < count; ++arrayIndex) list[arrayIndex] = PlatformCALayer::platformCALayer(const_cast<void*>(CFArrayGetValueAtIndex(sublayers, arrayIndex))); }
void PlatformCALayerRemote::adoptSublayers(PlatformCALayer& source) { PlatformCALayerList layersToMove = downcast<PlatformCALayerRemote>(source).m_children; if (const PlatformCALayerList* customLayers = source.customSublayers()) { for (const auto& layer : *customLayers) { size_t layerIndex = layersToMove.find(layer); if (layerIndex != notFound) layersToMove.remove(layerIndex); } } setSublayers(layersToMove); }
void PlatformCALayerWinInternal::setSublayers(const PlatformCALayerList& list) { // Remove all the current sublayers and add the passed layers CACFLayerSetSublayers(owner()->platformLayer(), 0); // Perform removeFromSuperLayer in a separate pass. CACF requires superlayer to // be null or CACFLayerInsertSublayer silently fails. for (size_t i = 0; i < list.size(); i++) CACFLayerRemoveFromSuperlayer(list[i]->platformLayer()); for (size_t i = 0; i < list.size(); i++) CACFLayerInsertSublayer(owner()->platformLayer(), list[i]->platformLayer(), i); owner()->setNeedsCommit(); }
void PlatformCALayerWinInternal::getSublayers(PlatformCALayerList& list) const { CFArrayRef sublayers = CACFLayerGetSublayers(owner()->platformLayer()); if (!sublayers) { list.clear(); return; } size_t count = CFArrayGetCount(sublayers); size_t layersToSkip = 0; if (owner()->layerType() == PlatformCALayer::LayerTypeWebTiledLayer) { // Exclude the tile parent layer. layersToSkip = 1; } list.resize(count - layersToSkip); for (size_t arrayIndex = layersToSkip; arrayIndex < count; ++arrayIndex) list[arrayIndex - layersToSkip] = PlatformCALayer::platformCALayer(const_cast<void*>(CFArrayGetValueAtIndex(sublayers, arrayIndex))); }
static void printLayer(const PlatformCALayer* layer, int indent) { FloatPoint3D layerPosition = layer->position(); FloatPoint3D layerAnchorPoint = layer->anchorPoint(); FloatRect layerBounds = layer->bounds(); printIndent(indent); char* layerTypeName = 0; switch (layer->layerType()) { case PlatformCALayer::LayerTypeLayer: layerTypeName = "layer"; break; case PlatformCALayer::LayerTypeWebLayer: layerTypeName = "web-layer"; break; case PlatformCALayer::LayerTypeTransformLayer: layerTypeName = "transform-layer"; break; case PlatformCALayer::LayerTypeWebTiledLayer: layerTypeName = "web-tiled-layer"; break; case PlatformCALayer::LayerTypeTiledBackingLayer: layerTypeName = "tiled-backing-layer"; break; case PlatformCALayer::LayerTypeRootLayer: layerTypeName = "root-layer"; break; case PlatformCALayer::LayerTypeCustom: layerTypeName = "custom-layer"; break; } fprintf(stderr, "(%s [%g %g %g] [%g %g %g %g] [%g %g %g] superlayer=%p\n", layerTypeName, layerPosition.x(), layerPosition.y(), layerPosition.z(), layerBounds.x(), layerBounds.y(), layerBounds.width(), layerBounds.height(), layerAnchorPoint.x(), layerAnchorPoint.y(), layerAnchorPoint.z(), layer->superlayer()); // Print name if needed String layerName = CACFLayerGetName(layer->platformLayer()); if (!layerName.isEmpty()) { printIndent(indent + 1); fprintf(stderr, "(name %s)\n", layerName.utf8().data()); } // Print masksToBounds if needed bool layerMasksToBounds = layer->masksToBounds(); if (layerMasksToBounds) { printIndent(indent + 1); fprintf(stderr, "(masksToBounds true)\n"); } // Print opacity if needed float layerOpacity = layer->opacity(); if (layerOpacity != 1) { printIndent(indent + 1); fprintf(stderr, "(opacity %hf)\n", layerOpacity); } // Print sublayerTransform if needed TransformationMatrix layerTransform = layer->sublayerTransform(); if (!layerTransform.isIdentity()) { printIndent(indent + 1); fprintf(stderr, "(sublayerTransform "); printTransform(layerTransform); fprintf(stderr, ")\n"); } // Print transform if needed layerTransform = layer->transform(); if (!layerTransform.isIdentity()) { printIndent(indent + 1); fprintf(stderr, "(transform "); printTransform(layerTransform); fprintf(stderr, ")\n"); } // Print contents if needed CFTypeRef layerContents = layer->contents(); if (layerContents) { if (CFGetTypeID(layerContents) == CGImageGetTypeID()) { CGImageRef imageContents = static_cast<CGImageRef>(const_cast<void*>(layerContents)); printIndent(indent + 1); fprintf(stderr, "(contents (image [%d %d]))\n", CGImageGetWidth(imageContents), CGImageGetHeight(imageContents)); } } // Print sublayers if needed int n = intern(layer)->sublayerCount(); if (n > 0) { printIndent(indent + 1); fprintf(stderr, "(sublayers\n"); PlatformCALayerList sublayers; intern(layer)->getSublayers(sublayers); ASSERT(n == sublayers.size()); for (int i = 0; i < n; ++i) printLayer(sublayers[i].get(), indent + 2); printIndent(indent + 1); fprintf(stderr, ")\n"); } printIndent(indent); fprintf(stderr, ")\n"); }
static void printLayer(StringBuilder& builder, const PlatformCALayer* layer, int indent) { FloatPoint3D layerPosition = layer->position(); FloatPoint3D layerAnchorPoint = layer->anchorPoint(); FloatRect layerBounds = layer->bounds(); builder.append('\n'); printIndent(builder, indent); char* layerTypeName = nullptr; switch (layer->layerType()) { case PlatformCALayer::LayerTypeLayer: layerTypeName = "layer"; break; case PlatformCALayer::LayerTypeWebLayer: layerTypeName = "web-layer"; break; case PlatformCALayer::LayerTypeSimpleLayer: layerTypeName = "simple-layer"; break; case PlatformCALayer::LayerTypeTransformLayer: layerTypeName = "transform-layer"; break; case PlatformCALayer::LayerTypeWebTiledLayer: layerTypeName = "web-tiled-layer"; break; case PlatformCALayer::LayerTypeTiledBackingLayer: layerTypeName = "tiled-backing-layer"; break; case PlatformCALayer::LayerTypePageTiledBackingLayer: layerTypeName = "page-tiled-backing-layer"; break; case PlatformCALayer::LayerTypeTiledBackingTileLayer: layerTypeName = "tiled-backing-tile-layer"; break; case PlatformCALayer::LayerTypeRootLayer: layerTypeName = "root-layer"; break; case PlatformCALayer::LayerTypeAVPlayerLayer: layerTypeName = "avplayer-layer"; break; case PlatformCALayer::LayerTypeWebGLLayer: layerTypeName = "webgl-layer"; break; case PlatformCALayer::LayerTypeBackdropLayer: layerTypeName = "backdrop-layer"; break; case PlatformCALayer::LayerTypeShapeLayer: layerTypeName = "shape-layer"; break; case PlatformCALayer::LayerTypeLightSystemBackdropLayer: layerTypeName = "light-system-backdrop-layer"; break; case PlatformCALayer::LayerTypeDarkSystemBackdropLayer: layerTypeName = "dark-system-backdrop-layer"; break; case PlatformCALayer::LayerTypeScrollingLayer: layerTypeName = "scrolling-layer"; break; case PlatformCALayer::LayerTypeCustom: layerTypeName = "custom-layer"; break; } builder.append("("); builder.append(layerTypeName); builder.append(" ["); builder.appendNumber(layerPosition.x()); builder.append(' '); builder.appendNumber(layerPosition.y()); builder.append(' '); builder.appendNumber(layerPosition.z()); builder.append("] ["); builder.appendNumber(layerBounds.x()); builder.append(' '); builder.appendNumber(layerBounds.y()); builder.append(' '); builder.appendNumber(layerBounds.width()); builder.append(' '); builder.appendNumber(layerBounds.height()); builder.append("] ["); builder.appendNumber(layerAnchorPoint.x()); builder.append(' '); builder.appendNumber(layerAnchorPoint.y()); builder.append(' '); builder.appendNumber(layerAnchorPoint.z()); builder.append("] superlayer="); builder.appendNumber(reinterpret_cast<unsigned long long>(layer->superlayer())); // Print name if needed String layerName = CACFLayerGetName(layer->platformLayer()); if (!layerName.isEmpty()) { builder.append('\n'); printIndent(builder, indent + 1); builder.append("(name \""); builder.append(layerName); builder.append("\")"); } // Print borderWidth if needed if (CGFloat borderWidth = CACFLayerGetBorderWidth(layer->platformLayer())) { builder.append('\n'); printIndent(builder, indent + 1); builder.append("(borderWidth "); builder.appendNumber(borderWidth); builder.append(')'); } // Print backgroundColor if needed printColor(builder, indent + 1, "backgroundColor", CACFLayerGetBackgroundColor(layer->platformLayer())); // Print borderColor if needed printColor(builder, indent + 1, "borderColor", CACFLayerGetBorderColor(layer->platformLayer())); // Print masksToBounds if needed if (bool layerMasksToBounds = layer->masksToBounds()) { builder.append('\n'); printIndent(builder, indent + 1); builder.append("(masksToBounds true)"); } if (bool geometryFlipped = layer->geometryFlipped()) { builder.append('\n'); printIndent(builder, indent + 1); builder.append("(geometryFlipped true)"); } // Print opacity if needed float layerOpacity = layer->opacity(); if (layerOpacity != 1) { builder.append('\n'); printIndent(builder, indent + 1); builder.append("(opacity "); builder.appendNumber(layerOpacity); builder.append(')'); } // Print sublayerTransform if needed TransformationMatrix layerTransform = layer->sublayerTransform(); if (!layerTransform.isIdentity()) { builder.append('\n'); printIndent(builder, indent + 1); builder.append("(sublayerTransform "); printTransform(builder, layerTransform); builder.append(')'); } // Print transform if needed layerTransform = layer->transform(); if (!layerTransform.isIdentity()) { builder.append('\n'); printIndent(builder, indent + 1); builder.append("(transform "); printTransform(builder, layerTransform); builder.append(')'); } // Print contents if needed if (CFTypeRef layerContents = layer->contents()) { if (CFGetTypeID(layerContents) == CGImageGetTypeID()) { CGImageRef imageContents = static_cast<CGImageRef>(const_cast<void*>(layerContents)); builder.append('\n'); printIndent(builder, indent + 1); builder.append("(contents (image ["); builder.appendNumber(CGImageGetWidth(imageContents)); builder.append(' '); builder.appendNumber(CGImageGetHeight(imageContents)); builder.append("]))"); } if (CFGetTypeID(layerContents) == CABackingStoreGetTypeID()) { CABackingStoreRef backingStore = static_cast<CABackingStoreRef>(const_cast<void*>(layerContents)); CGImageRef imageContents = CABackingStoreGetCGImage(backingStore); builder.append('\n'); printIndent(builder, indent + 1); builder.append("(contents (backing-store ["); builder.appendNumber(CGImageGetWidth(imageContents)); builder.append(' '); builder.appendNumber(CGImageGetHeight(imageContents)); builder.append("]))"); } } // Print sublayers if needed int n = intern(layer)->sublayerCount(); if (n > 0) { builder.append('\n'); printIndent(builder, indent + 1); builder.append("(sublayers"); PlatformCALayerList sublayers; intern(layer)->getSublayers(sublayers); ASSERT(n == sublayers.size()); for (int i = 0; i < n; ++i) printLayer(builder, sublayers[i].get(), indent + 2); builder.append(')'); } builder.append(')'); }