void GraphicsLayerChromium::setupContentsLayer(WebLayer* contentsLayer) { m_contentsLayer = contentsLayer; m_contentsLayerId = m_contentsLayer->id(); if (m_contentsLayer) { m_contentsLayer->setAnchorPoint(FloatPoint(0, 0)); m_contentsLayer->setUseParentBackfaceVisibility(true); // It is necessary to call setDrawsContent as soon as we receive the new contentsLayer, for // the correctness of early exit conditions in setDrawsContent() and setContentsVisible(). m_contentsLayer->setDrawsContent(m_contentsVisible); // Insert the content layer first. Video elements require this, because they have // shadow content that must display in front of the video. m_layer->layer()->insertChild(m_contentsLayer, 0); if (isShowingDebugBorder()) { m_contentsLayer->setDebugBorderColor(Color(0, 0, 128, 180).rgb()); m_contentsLayer->setDebugBorderWidth(1); } } updateDebugIndicators(); updateNames(); }
void GraphicsLayerTextureMapper::drawRepaintCounter(GraphicsContext* context) { cairo_t* cr = context->platformContext()->cr(); cairo_save(cr); CString repaintCount = String::format("%i", this->repaintCount()).utf8(); cairo_select_font_face(cr, "sans-serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); cairo_set_font_size(cr, 18); cairo_text_extents_t repaintTextExtents; cairo_text_extents(cr, repaintCount.data(), &repaintTextExtents); static const int repaintCountBorderWidth = 10; setSourceRGBAFromColor(cr, isShowingDebugBorder() ? m_debugBorderColor : Color(0, 255, 0, 127)); cairo_rectangle(cr, 0, 0, repaintTextExtents.width + (repaintCountBorderWidth * 2), repaintTextExtents.height + (repaintCountBorderWidth * 2)); cairo_fill(cr); cairo_set_source_rgb(cr, 1, 1, 1); cairo_move_to(cr, repaintCountBorderWidth, repaintTextExtents.height + repaintCountBorderWidth); cairo_show_text(cr, repaintCount.data()); cairo_restore(cr); }
void CoordinatedGraphicsLayer::syncLayerState() { if (!m_shouldSyncLayerState) return; m_shouldSyncLayerState = false; m_layerState.childrenTransform = childrenTransform(); m_layerState.contentsRect = contentsRect(); m_layerState.mask = toCoordinatedLayerID(maskLayer()); m_layerState.opacity = opacity(); m_layerState.replica = toCoordinatedLayerID(replicaLayer()); m_layerState.transform = transform(); m_layerState.anchorPoint = m_adjustedAnchorPoint; m_layerState.pos = m_adjustedPosition; m_layerState.size = m_adjustedSize; if (m_layerState.flagsChanged) { m_layerState.drawsContent = drawsContent(); m_layerState.contentsVisible = contentsAreVisible(); m_layerState.backfaceVisible = backfaceVisibility(); m_layerState.masksToBounds = masksToBounds(); m_layerState.preserves3D = preserves3D(); m_layerState.fixedToViewport = fixedToViewport(); m_layerState.showDebugBorders = isShowingDebugBorder(); m_layerState.showRepaintCounter = isShowingRepaintCounter(); m_layerState.isScrollable = isScrollable(); } if (m_layerState.showDebugBorders) updateDebugIndicators(); }
void GraphicsLayerTextureMapper::setShowDebugBorder(bool show) { if (isShowingDebugBorder() == show) return; GraphicsLayer::setShowDebugBorder(show); notifyChange(DebugVisualsChange); }
void GraphicsLayerTextureMapper::prepareBackingStore() { TextureMapper* textureMapper = m_layer->textureMapper(); if (!textureMapper) return; if (!shouldHaveBackingStore()) { m_backingStore.clear(); return; } IntRect dirtyRect = enclosingIntRect(FloatRect(FloatPoint::zero(), m_size)); if (!m_needsDisplay) dirtyRect.intersect(enclosingIntRect(m_needsDisplayRect)); if (dirtyRect.isEmpty()) return; if (!m_backingStore) m_backingStore = TextureMapperTiledBackingStore::create(); #if PLATFORM(QT) ASSERT(dynamic_cast<TextureMapperTiledBackingStore*>(m_backingStore.get())); #endif TextureMapperTiledBackingStore* backingStore = static_cast<TextureMapperTiledBackingStore*>(m_backingStore.get()); if (isShowingRepaintCounter()) incrementRepaintCount(); // Paint into an intermediate buffer to avoid painting content more than once. bool paintOnce = true; const IntSize maxTextureSize = textureMapper->maxTextureSize(); // We need to paint directly if the dirty rect exceeds one of the maximum dimensions. if (dirtyRect.width() > maxTextureSize.width() || dirtyRect.height() > maxTextureSize.height()) paintOnce = false; if (paintOnce) { OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(dirtyRect.size()); GraphicsContext* context = imageBuffer->context(); context->setImageInterpolationQuality(textureMapper->imageInterpolationQuality()); context->setTextDrawingMode(textureMapper->textDrawingMode()); context->translate(-dirtyRect.x(), -dirtyRect.y()); paintGraphicsLayerContents(*context, dirtyRect); if (isShowingRepaintCounter()) drawRepaintCounter(context); RefPtr<Image> image = imageBuffer->copyImage(DontCopyBackingStore); backingStore->updateContents(textureMapper, image.get(), m_size, dirtyRect, BitmapTexture::UpdateCanModifyOriginalImageData); } else backingStore->updateContents(textureMapper, this, m_size, dirtyRect, BitmapTexture::UpdateCanModifyOriginalImageData); backingStore->setShowDebugBorders(isShowingDebugBorder()); backingStore->setDebugBorder(m_debugBorderColor, m_debugBorderWidth); m_needsDisplay = false; m_needsDisplayRect = IntRect(); }
void GraphicsLayer::updateDebugIndicators() { if (!isShowingDebugBorder()) return; Color borderColor; float width = 0; getDebugBorderInfo(borderColor, width); setDebugBorder(borderColor, width); }
void CoordinatedGraphicsLayer::setShowDebugBorder(bool show) { if (isShowingDebugBorder() == show) return; GraphicsLayer::setShowDebugBorder(show); m_layerState.showDebugBorders = true; m_layerState.flagsChanged = true; didChangeLayerState(); }
void GraphicsLayerTextureMapper::updateDebugBorderAndRepaintCount() { if (isShowingDebugBorder()) updateDebugIndicators(); // When this has its own backing store (e.g. Qt WK1), update the repaint count before calling TextureMapperLayer::flushCompositingStateForThisLayerOnly(). bool needsToRepaint = shouldHaveBackingStore() && (m_needsDisplay || !m_needsDisplayRect.isEmpty()); if (isShowingRepaintCounter() && needsToRepaint) { incrementRepaintCount(); m_changeMask |= RepaintCountChange; } }
void GraphicsLayerTextureMapper::commitLayerChanges() { if (m_changeMask == NoChanges) return; if (m_changeMask & ChildrenChange) { Vector<TextureMapperLayer*> textureMapperLayerChildren; toTextureMapperLayerVector(children(), textureMapperLayerChildren); m_layer->setChildren(textureMapperLayerChildren); } if (m_changeMask & MaskLayerChange) m_layer->setMaskLayer(toTextureMapperLayer(maskLayer())); if (m_changeMask & ReplicaLayerChange) m_layer->setReplicaLayer(toTextureMapperLayer(replicaLayer())); if (m_changeMask & PositionChange) m_layer->setPosition(position()); if (m_changeMask & AnchorPointChange) m_layer->setAnchorPoint(anchorPoint()); if (m_changeMask & SizeChange) m_layer->setSize(size()); if (m_changeMask & TransformChange) m_layer->setTransform(transform()); if (m_changeMask & ChildrenTransformChange) m_layer->setChildrenTransform(childrenTransform()); if (m_changeMask & Preserves3DChange) m_layer->setPreserves3D(preserves3D()); if (m_changeMask & ContentsRectChange) m_layer->setContentsRect(contentsRect()); if (m_changeMask & MasksToBoundsChange) m_layer->setMasksToBounds(masksToBounds()); if (m_changeMask & DrawsContentChange) m_layer->setDrawsContent(drawsContent()); if (m_changeMask & ContentsVisibleChange) m_layer->setContentsVisible(contentsAreVisible()); if (m_changeMask & ContentsOpaqueChange) m_layer->setContentsOpaque(contentsOpaque()); if (m_changeMask & BackfaceVisibilityChange) m_layer->setBackfaceVisibility(backfaceVisibility()); if (m_changeMask & OpacityChange) m_layer->setOpacity(opacity()); if (m_changeMask & BackgroundColorChange) m_layer->setSolidColor(solidColor()); #if ENABLE(CSS_FILTERS) if (m_changeMask & FilterChange) m_layer->setFilters(filters()); #endif if (m_changeMask & BackingStoreChange) m_layer->setBackingStore(m_backingStore); if (m_changeMask & DebugVisualsChange) m_layer->setDebugVisuals(isShowingDebugBorder(), debugBorderColor(), debugBorderWidth(), isShowingRepaintCounter()); if (m_changeMask & RepaintCountChange) m_layer->setRepaintCount(repaintCount()); if (m_changeMask & ContentChange) m_layer->setContentsLayer(platformLayer()); if (m_changeMask & AnimationChange) m_layer->setAnimations(m_animations); if (m_changeMask & AnimationStarted) client()->notifyAnimationStarted(this, m_animationStartTime); if (m_changeMask & FixedToViewporChange) m_layer->setFixedToViewport(fixedToViewport()); if (m_changeMask & IsScrollableChange) m_layer->setIsScrollable(isScrollable()); if (m_changeMask & CommittedScrollOffsetChange) m_layer->didCommitScrollOffset(m_committedScrollOffset); m_changeMask = NoChanges; }