LayerAndroid::LayerAndroid(const LayerAndroid& layer) : SkLayer(layer), m_isRootLayer(layer.m_isRootLayer), m_haveClip(layer.m_haveClip), m_extra(0), // deliberately not copied m_uniqueId(layer.m_uniqueId) { m_doRotation = layer.m_doRotation; m_isFixed = layer.m_isFixed; m_angleTransform = layer.m_angleTransform; m_translation = layer.m_translation; m_scale = layer.m_scale; m_backgroundColor = layer.m_backgroundColor; m_fixedLeft = layer.m_fixedLeft; m_fixedTop = layer.m_fixedTop; m_fixedRight = layer.m_fixedRight; m_fixedBottom = layer.m_fixedBottom; m_fixedMarginLeft = layer.m_fixedMarginLeft; m_fixedMarginTop = layer.m_fixedMarginTop; m_fixedMarginRight = layer.m_fixedMarginRight; m_fixedMarginBottom = layer.m_fixedMarginBottom; m_fixedOffset = layer.m_fixedOffset; m_fixedWidth = layer.m_fixedWidth; m_fixedHeight = layer.m_fixedHeight; m_recordingPicture = layer.m_recordingPicture; SkSafeRef(m_recordingPicture); #if ENABLE(WEBGL) m_context = layer.m_context; #endif for (int i = 0; i < layer.countChildren(); i++) addChild(new LayerAndroid(*layer.getChild(i)))->unref(); KeyframesMap::const_iterator end = layer.m_animations.end(); for (KeyframesMap::const_iterator it = layer.m_animations.begin(); it != end; ++it) m_animations.add((it->second)->name(), (it->second)->copy()); gDebugLayerAndroidInstances++; }
LayerAndroid::LayerAndroid(const LayerAndroid& layer) : Layer(layer), m_uniqueId(layer.m_uniqueId), m_haveClip(layer.m_haveClip), m_backfaceVisibility(layer.m_backfaceVisibility), m_visible(layer.m_visible), m_backgroundColor(layer.m_backgroundColor), m_preserves3D(layer.m_preserves3D), m_anchorPointZ(layer.m_anchorPointZ), m_isPositionAbsolute(layer.m_isPositionAbsolute), m_fixedPosition(0), m_zValue(layer.m_zValue), m_content(layer.m_content), m_imageCRC(layer.m_imageCRC), m_scale(layer.m_scale), m_lastComputeTextureSize(0), m_owningLayer(layer.m_owningLayer), m_type(LayerAndroid::UILayer), m_intrinsicallyComposited(layer.m_intrinsicallyComposited), m_surface(0), m_replicatedLayer(0), m_originalLayer(0), m_maskLayer(0) { if (m_imageCRC) ImagesManager::instance()->retainImage(m_imageCRC); SkSafeRef(m_content); if (layer.m_fixedPosition) { m_fixedPosition = layer.m_fixedPosition->copy(this); Layer::setShouldInheritFromRootTransform(true); } m_transform = layer.m_transform; m_drawTransform = layer.m_drawTransform; m_drawTransformUnfudged = layer.m_drawTransformUnfudged; m_childrenTransform = layer.m_childrenTransform; m_dirtyRegion = layer.m_dirtyRegion; m_replicatedLayerPosition = layer.m_replicatedLayerPosition; #ifdef ABSOLUTE_POSITION // If we have absolute elements, we may need to reorder them if they // are followed by another layer that is not also absolutely positioned. // (as absolutely positioned elements are out of the normal flow) bool hasAbsoluteChildren = false; bool hasOnlyAbsoluteFollowers = true; for (int i = 0; i < layer.countChildren(); i++) { if (layer.getChild(i)->isPositionAbsolute()) { hasAbsoluteChildren = true; continue; } if (hasAbsoluteChildren && !layer.getChild(i)->isPositionAbsolute()) { hasOnlyAbsoluteFollowers = false; break; } } if (hasAbsoluteChildren && !hasOnlyAbsoluteFollowers) { Vector<LayerAndroid*> normalLayers; Vector<LayerAndroid*> absoluteLayers; for (int i = 0; i < layer.countChildren(); i++) { LayerAndroid* child = layer.getChild(i); if (child->isPositionAbsolute() || child->isPositionFixed()) absoluteLayers.append(child); else normalLayers.append(child); } for (unsigned int i = 0; i < normalLayers.size(); i++) addChild(normalLayers[i]->copy())->unref(); for (unsigned int i = 0; i < absoluteLayers.size(); i++) addChild(absoluteLayers[i]->copy())->unref(); } else { for (int i = 0; i < layer.countChildren(); i++) addChild(layer.getChild(i)->copy())->unref(); } #else for (int i = 0; i < layer.countChildren(); i++) addChild(layer.getChild(i)->copy())->unref(); #endif KeyframesMap::const_iterator end = layer.m_animations.end(); for (KeyframesMap::const_iterator it = layer.m_animations.begin(); it != end; ++it) { m_animations.add(it->first, it->second); } if (layer.m_replicatedLayer) { // The replicated layer is always the first child m_replicatedLayer = getChild(0); m_replicatedLayer->setOriginalLayer(this); } if (layer.m_maskLayer) m_maskLayer = layer.m_maskLayer->copy(); #ifdef DEBUG_COUNT ClassTracker::instance()->increment("LayerAndroid - recopy (UI)"); ClassTracker::instance()->add(this); #endif }