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

Side by Side Diff: Source/core/platform/graphics/CrossfadeGeneratedImage.cpp

Issue 22596003: Fix background blending for some cases where it did not work at all. The fix adds the blendMode par… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: adding TestExpectation lines for rebaselining Created 7 years, 4 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 /* 1 /*
2 * Copyright (C) 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 if (m_crossfadeSize != toImageSize) 73 if (m_crossfadeSize != toImageSize)
74 context->scale(FloatSize(static_cast<float>(m_crossfadeSize.width()) / t oImageSize.width(), 74 context->scale(FloatSize(static_cast<float>(m_crossfadeSize.width()) / t oImageSize.width(),
75 static_cast<float>(m_crossfadeSize.height()) / toImageSize.height())); 75 static_cast<float>(m_crossfadeSize.height()) / toImageSize.height()));
76 context->setAlpha(m_percentage); 76 context->setAlpha(m_percentage);
77 context->drawImage(m_toImage, IntPoint(), CompositePlusLighter); 77 context->drawImage(m_toImage, IntPoint(), CompositePlusLighter);
78 context->restore(); 78 context->restore();
79 79
80 context->endTransparencyLayer(); 80 context->endTransparencyLayer();
81 } 81 }
82 82
83 void CrossfadeGeneratedImage::draw(GraphicsContext* context, const FloatRect& ds tRect, const FloatRect& srcRect, CompositeOperator compositeOp, BlendMode) 83 void CrossfadeGeneratedImage::draw(GraphicsContext* context, const FloatRect& ds tRect, const FloatRect& srcRect, CompositeOperator compositeOp, BlendMode blendM ode)
84 { 84 {
85 GraphicsContextStateSaver stateSaver(*context); 85 GraphicsContextStateSaver stateSaver(*context);
86 context->setCompositeOperation(compositeOp); 86 context->setCompositeOperation(compositeOp, blendMode);
87 context->clip(dstRect); 87 context->clip(dstRect);
88 context->translate(dstRect.x(), dstRect.y()); 88 context->translate(dstRect.x(), dstRect.y());
89 if (dstRect.size() != srcRect.size()) 89 if (dstRect.size() != srcRect.size())
90 context->scale(FloatSize(dstRect.width() / srcRect.width(), dstRect.heig ht() / srcRect.height())); 90 context->scale(FloatSize(dstRect.width() / srcRect.width(), dstRect.heig ht() / srcRect.height()));
91 context->translate(-srcRect.x(), -srcRect.y()); 91 context->translate(-srcRect.x(), -srcRect.y());
92 92
93 drawCrossfade(context); 93 drawCrossfade(context);
94 } 94 }
95 95
96 void CrossfadeGeneratedImage::drawPattern(GraphicsContext* context, const FloatR ect& srcRect, const FloatSize& scale, const FloatPoint& phase, CompositeOperator compositeOp, const FloatRect& dstRect, BlendMode) 96 void CrossfadeGeneratedImage::drawPattern(GraphicsContext* context, const FloatR ect& srcRect, const FloatSize& scale, const FloatPoint& phase, CompositeOperator compositeOp, const FloatRect& dstRect, BlendMode blendMode)
97 { 97 {
98 OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(m_size, 1, context->is Accelerated() ? Accelerated : Unaccelerated); 98 OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(m_size, 1, context->is Accelerated() ? Accelerated : Unaccelerated);
99 if (!imageBuffer) 99 if (!imageBuffer)
100 return; 100 return;
101 101
102 // Fill with the cross-faded image. 102 // Fill with the cross-faded image.
103 GraphicsContext* graphicsContext = imageBuffer->context(); 103 GraphicsContext* graphicsContext = imageBuffer->context();
104 drawCrossfade(graphicsContext); 104 drawCrossfade(graphicsContext);
105 105
106 // Tile the image buffer into the context. 106 // Tile the image buffer into the context.
107 imageBuffer->drawPattern(context, srcRect, scale, phase, compositeOp, dstRec t); 107 imageBuffer->drawPattern(context, srcRect, scale, phase, compositeOp, dstRec t, blendMode);
108 } 108 }
109 109
110 } 110 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698