Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: Source/core/paint/BoxPainter.cpp

Issue 840733004: Replace setCompositeOperation(CompositeOperator, WebBlendMode) with setCompositeOperation(SkXfermod… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rename compositeOperationDeprecated Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/paint/BoxPainter.h" 6 #include "core/paint/BoxPainter.h"
7 7
8 #include "core/HTMLNames.h" 8 #include "core/HTMLNames.h"
9 #include "core/frame/Settings.h" 9 #include "core/frame/Settings.h"
10 #include "core/html/HTMLFrameOwnerElement.h" 10 #include "core/html/HTMLFrameOwnerElement.h"
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 if (!boxShadowShouldBeAppliedToBackground) 457 if (!boxShadowShouldBeAppliedToBackground)
458 backgroundRect.intersect(paintInfo.rect); 458 backgroundRect.intersect(paintInfo.rect);
459 459
460 GraphicsContextStateSaver shadowStateSaver(*context, boxShadowShould BeAppliedToBackground); 460 GraphicsContextStateSaver shadowStateSaver(*context, boxShadowShould BeAppliedToBackground);
461 if (boxShadowShouldBeAppliedToBackground) 461 if (boxShadowShouldBeAppliedToBackground)
462 BoxPainter::applyBoxShadowForBackground(context, obj); 462 BoxPainter::applyBoxShadowForBackground(context, obj);
463 463
464 if (isOpaqueRoot && !skipBaseColor) { 464 if (isOpaqueRoot && !skipBaseColor) {
465 paintRootBackgroundColor(obj, paintInfo, rect, bgColor); 465 paintRootBackgroundColor(obj, paintInfo, rect, bgColor);
466 } else if (bgColor.alpha()) { 466 } else if (bgColor.alpha()) {
467 context->fillRect(backgroundRect, bgColor, context->compositeOpe ration()); 467 context->fillRect(backgroundRect, bgColor, context->compositeOpe rationDeprecated());
468 } 468 }
469 } 469 }
470 } 470 }
471 471
472 // no progressive loading of the background image 472 // no progressive loading of the background image
473 if (shouldPaintBackgroundImage) { 473 if (shouldPaintBackgroundImage) {
474 BackgroundImageGeometry geometry; 474 BackgroundImageGeometry geometry;
475 calculateBackgroundImageGeometry(obj, paintInfo.paintContainer(), bgLaye r, scrolledPaintRect, geometry, backgroundObject); 475 calculateBackgroundImageGeometry(obj, paintInfo.paintContainer(), bgLaye r, scrolledPaintRect, geometry, backgroundObject);
476 if (!geometry.destRect().isEmpty()) { 476 if (!geometry.destRect().isEmpty()) {
477 CompositeOperator compositeOp = op == CompositeSourceOver ? bgLayer. composite() : op; 477 CompositeOperator compositeOp = op == CompositeSourceOver ? bgLayer. composite() : op;
478 RenderObject* clientForBackgroundImage = backgroundObject ? backgrou ndObject : &obj; 478 RenderObject* clientForBackgroundImage = backgroundObject ? backgrou ndObject : &obj;
479 RefPtr<Image> image = bgImage->image(clientForBackgroundImage, geome try.tileSize()); 479 RefPtr<Image> image = bgImage->image(clientForBackgroundImage, geome try.tileSize());
480 InterpolationQuality interpolationQuality = chooseInterpolationQuali ty(obj, context, image.get(), &bgLayer, LayoutSize(geometry.tileSize())); 480 InterpolationQuality interpolationQuality = chooseInterpolationQuali ty(obj, context, image.get(), &bgLayer, LayoutSize(geometry.tileSize()));
481 if (bgLayer.maskSourceType() == MaskLuminance) 481 if (bgLayer.maskSourceType() == MaskLuminance)
482 context->setColorFilter(ColorFilterLuminanceToAlpha); 482 context->setColorFilter(ColorFilterLuminanceToAlpha);
483 InterpolationQuality previousInterpolationQuality = context->imageIn terpolationQuality(); 483 InterpolationQuality previousInterpolationQuality = context->imageIn terpolationQuality();
484 context->setImageInterpolationQuality(interpolationQuality); 484 context->setImageInterpolationQuality(interpolationQuality);
485 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "PaintI mage", "data", InspectorPaintImageEvent::data(obj, *bgImage)); 485 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "PaintI mage", "data", InspectorPaintImageEvent::data(obj, *bgImage));
486 context->drawTiledImage(image.get(), geometry.destRect(), geometry.p hase(), geometry.tileSize(), 486 context->drawTiledImage(image.get(), geometry.destRect(), geometry.p hase(), geometry.tileSize(),
487 compositeOp, bgLayer.blendMode(), geometry.spaceSize()); 487 compositeOp, bgLayer.blendMode(), geometry.spaceSize());
488 context->setImageInterpolationQuality(previousInterpolationQuality); 488 context->setImageInterpolationQuality(previousInterpolationQuality);
489 } 489 }
490 } 490 }
491 491
492 if (bgLayer.clip() == TextFillBox) { 492 if (bgLayer.clip() == TextFillBox) {
493 // Create the text mask layer. 493 // Create the text mask layer.
494 context->setCompositeOperation(CompositeDestinationIn); 494 context->setCompositeOperation(SkXfermode::kDstIn_Mode);
495 context->beginTransparencyLayer(1); 495 context->beginTransparencyLayer(1);
496 496
497 // FIXME: Workaround for https://code.google.com/p/skia/issues/detail?id =1291. 497 // FIXME: Workaround for https://code.google.com/p/skia/issues/detail?id =1291.
498 context->clearRect(maskRect); 498 context->clearRect(maskRect);
499 499
500 // Now draw the text into the mask. We do this by painting using a speci al paint phase that signals to 500 // Now draw the text into the mask. We do this by painting using a speci al paint phase that signals to
501 // InlineTextBoxes that they should just add their contents to the clip. 501 // InlineTextBoxes that they should just add their contents to the clip.
502 PaintInfo info(context, maskRect, PaintPhaseTextClip, PaintBehaviorForce BlackText, 0); 502 PaintInfo info(context, maskRect, PaintPhaseTextClip, PaintBehaviorForce BlackText, 0);
503 context->setCompositeOperation(CompositeSourceOver); 503 context->setCompositeOperation(SkXfermode::kSrcOver_Mode);
504 if (box) { 504 if (box) {
505 RootInlineBox& root = box->root(); 505 RootInlineBox& root = box->root();
506 box->paint(info, LayoutPoint(scrolledPaintRect.x() - box->x(), scrol ledPaintRect.y() - box->y()), root.lineTop(), root.lineBottom()); 506 box->paint(info, LayoutPoint(scrolledPaintRect.x() - box->x(), scrol ledPaintRect.y() - box->y()), root.lineTop(), root.lineBottom());
507 } else { 507 } else {
508 // FIXME: this should only have an effect for the line box list with in |obj|. Change this to create a LineBoxListPainter directly. 508 // FIXME: this should only have an effect for the line box list with in |obj|. Change this to create a LineBoxListPainter directly.
509 LayoutSize localOffset = obj.isBox() ? toRenderBox(&obj)->locationOf fset() : LayoutSize(); 509 LayoutSize localOffset = obj.isBox() ? toRenderBox(&obj)->locationOf fset() : LayoutSize();
510 obj.paint(info, scrolledPaintRect.location() - localOffset); 510 obj.paint(info, scrolledPaintRect.location() - localOffset);
511 } 511 }
512 512
513 context->endLayer(); 513 context->endLayer();
(...skipping 12 matching lines...) Expand all
526 526
527 void BoxPainter::paintMaskImages(const PaintInfo& paintInfo, const LayoutRect& p aintRect) 527 void BoxPainter::paintMaskImages(const PaintInfo& paintInfo, const LayoutRect& p aintRect)
528 { 528 {
529 // Figure out if we need to push a transparency layer to render our mask. 529 // Figure out if we need to push a transparency layer to render our mask.
530 bool pushTransparencyLayer = false; 530 bool pushTransparencyLayer = false;
531 bool compositedMask = m_renderBox.hasLayer() && m_renderBox.layer()->hasComp ositedMask(); 531 bool compositedMask = m_renderBox.hasLayer() && m_renderBox.layer()->hasComp ositedMask();
532 bool flattenCompositingLayers = m_renderBox.view()->frameView() && m_renderB ox.view()->frameView()->paintBehavior() & PaintBehaviorFlattenCompositingLayers; 532 bool flattenCompositingLayers = m_renderBox.view()->frameView() && m_renderB ox.view()->frameView()->paintBehavior() & PaintBehaviorFlattenCompositingLayers;
533 533
534 bool allMaskImagesLoaded = true; 534 bool allMaskImagesLoaded = true;
535 535
536 CompositeOperator previousCompositeOperator = paintInfo.context->compositeOp eration(); 536 SkXfermode::Mode previousCompositeOperation = paintInfo.context->compositeOp eration();
537 537
538 if (!compositedMask || flattenCompositingLayers) { 538 if (!compositedMask || flattenCompositingLayers) {
539 pushTransparencyLayer = true; 539 pushTransparencyLayer = true;
540 StyleImage* maskBoxImage = m_renderBox.style()->maskBoxImage().image(); 540 StyleImage* maskBoxImage = m_renderBox.style()->maskBoxImage().image();
541 const FillLayer& maskLayers = m_renderBox.style()->maskLayers(); 541 const FillLayer& maskLayers = m_renderBox.style()->maskLayers();
542 542
543 // Don't render a masked element until all the mask images have loaded, to prevent a flash of unmasked content. 543 // Don't render a masked element until all the mask images have loaded, to prevent a flash of unmasked content.
544 if (maskBoxImage) 544 if (maskBoxImage)
545 allMaskImagesLoaded &= maskBoxImage->isLoaded(); 545 allMaskImagesLoaded &= maskBoxImage->isLoaded();
546 546
547 allMaskImagesLoaded &= maskLayers.imagesAreLoaded(); 547 allMaskImagesLoaded &= maskLayers.imagesAreLoaded();
548 548
549 paintInfo.context->setCompositeOperation(CompositeDestinationIn); 549 paintInfo.context->setCompositeOperation(SkXfermode::kDstIn_Mode);
550 paintInfo.context->beginTransparencyLayer(1); 550 paintInfo.context->beginTransparencyLayer(1);
551 } 551 }
552 552
553 if (allMaskImagesLoaded) { 553 if (allMaskImagesLoaded) {
554 paintFillLayers(paintInfo, Color::transparent, m_renderBox.style()->mask Layers(), paintRect, BackgroundBleedNone, CompositeSourceOver); 554 paintFillLayers(paintInfo, Color::transparent, m_renderBox.style()->mask Layers(), paintRect, BackgroundBleedNone, CompositeSourceOver);
555 paintNinePieceImage(m_renderBox, paintInfo.context, paintRect, m_renderB ox.style(), m_renderBox.style()->maskBoxImage(), CompositeSourceOver); 555 paintNinePieceImage(m_renderBox, paintInfo.context, paintRect, m_renderB ox.style(), m_renderBox.style()->maskBoxImage(), CompositeSourceOver);
556 } 556 }
557 557
558 if (pushTransparencyLayer) { 558 if (pushTransparencyLayer) {
559 paintInfo.context->endLayer(); 559 paintInfo.context->endLayer();
560 paintInfo.context->setCompositeOperation(previousCompositeOperator); 560 paintInfo.context->setCompositeOperation(previousCompositeOperation);
561 } 561 }
562 } 562 }
563 563
564 void BoxPainter::paintClippingMask(const PaintInfo& paintInfo, const LayoutPoint & paintOffset) 564 void BoxPainter::paintClippingMask(const PaintInfo& paintInfo, const LayoutPoint & paintOffset)
565 { 565 {
566 if (!paintInfo.shouldPaintWithinRoot(&m_renderBox) || m_renderBox.style()->v isibility() != VISIBLE || paintInfo.phase != PaintPhaseClippingMask) 566 if (!paintInfo.shouldPaintWithinRoot(&m_renderBox) || m_renderBox.style()->v isibility() != VISIBLE || paintInfo.phase != PaintPhaseClippingMask)
567 return; 567 return;
568 568
569 if (!m_renderBox.layer() || m_renderBox.layer()->compositingState() != Paint sIntoOwnBacking) 569 if (!m_renderBox.layer() || m_renderBox.layer()->compositingState() != Paint sIntoOwnBacking)
570 return; 570 return;
571 571
572 LayoutRect paintRect = LayoutRect(paintOffset, m_renderBox.size()); 572 LayoutRect paintRect = LayoutRect(paintOffset, m_renderBox.size());
573 paintInfo.context->fillRect(pixelSnappedIntRect(paintRect), Color::black); 573 paintInfo.context->fillRect(pixelSnappedIntRect(paintRect), Color::black);
574 } 574 }
575 575
576 void BoxPainter::paintRootBackgroundColor(RenderObject& obj, const PaintInfo& pa intInfo, const LayoutRect& rect, const Color& bgColor) 576 void BoxPainter::paintRootBackgroundColor(RenderObject& obj, const PaintInfo& pa intInfo, const LayoutRect& rect, const Color& bgColor)
577 { 577 {
578 GraphicsContext* context = paintInfo.context; 578 GraphicsContext* context = paintInfo.context;
579 if (rect.isEmpty()) 579 if (rect.isEmpty())
580 return; 580 return;
581 581
582 ASSERT(obj.isDocumentElement()); 582 ASSERT(obj.isDocumentElement());
583 583
584 IntRect backgroundRect(pixelSnappedIntRect(rect)); 584 IntRect backgroundRect(pixelSnappedIntRect(rect));
585 backgroundRect.intersect(paintInfo.rect); 585 backgroundRect.intersect(paintInfo.rect);
586 586
587 Color baseColor = obj.view()->frameView()->baseBackgroundColor(); 587 Color baseColor = obj.view()->frameView()->baseBackgroundColor();
588 bool shouldClearDocumentBackground = obj.document().settings() && obj.docume nt().settings()->shouldClearDocumentBackground(); 588 bool shouldClearDocumentBackground = obj.document().settings() && obj.docume nt().settings()->shouldClearDocumentBackground();
589 CompositeOperator operation = shouldClearDocumentBackground ? CompositeCopy : context->compositeOperation(); 589 CompositeOperator operation = shouldClearDocumentBackground ? CompositeCopy : context->compositeOperationDeprecated();
590 590
591 // If we have an alpha go ahead and blend with the base background color. 591 // If we have an alpha go ahead and blend with the base background color.
592 if (baseColor.alpha()) { 592 if (baseColor.alpha()) {
593 if (bgColor.alpha()) 593 if (bgColor.alpha())
594 baseColor = baseColor.blend(bgColor); 594 baseColor = baseColor.blend(bgColor);
595 context->fillRect(backgroundRect, baseColor, operation); 595 context->fillRect(backgroundRect, baseColor, operation);
596 } else if (bgColor.alpha()) { 596 } else if (bgColor.alpha()) {
597 context->fillRect(backgroundRect, bgColor, operation); 597 context->fillRect(backgroundRect, bgColor, operation);
598 } else if (shouldClearDocumentBackground) { 598 } else if (shouldClearDocumentBackground) {
599 context->clearRect(backgroundRect); 599 context->clearRect(backgroundRect);
(...skipping 1602 matching lines...) Expand 10 before | Expand all | Expand 10 after
2202 2202
2203 FloatPoint secondQuad[4]; 2203 FloatPoint secondQuad[4];
2204 secondQuad[0] = quad[0]; 2204 secondQuad[0] = quad[0];
2205 secondQuad[1] = FloatPoint(quad[0].x() - r1 * cx, quad[0].y() - r1 * cy); 2205 secondQuad[1] = FloatPoint(quad[0].x() - r1 * cx, quad[0].y() - r1 * cy);
2206 secondQuad[2] = quad[2]; 2206 secondQuad[2] = quad[2];
2207 secondQuad[3] = quad[3]; 2207 secondQuad[3] = quad[3];
2208 graphicsContext->clipPolygon(4, secondQuad, !secondEdgeMatches); 2208 graphicsContext->clipPolygon(4, secondQuad, !secondEdgeMatches);
2209 } 2209 }
2210 2210
2211 } // namespace blink 2211 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/html/canvas/CanvasRenderingContext2D.cpp ('k') | Source/core/paint/InlineFlowBoxPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698