OLD | NEW |
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 static_cast<float>(m_crossfadeSize.width()) / toImageSize.width(), | 77 static_cast<float>(m_crossfadeSize.width()) / toImageSize.width(), |
78 static_cast<float>(m_crossfadeSize.height()) / toImageSize.height())
; | 78 static_cast<float>(m_crossfadeSize.height()) / toImageSize.height())
; |
79 } | 79 } |
80 context->setAlphaAsFloat(m_percentage); | 80 context->setAlphaAsFloat(m_percentage); |
81 context->drawImage(m_toImage, IntPoint(), CompositePlusLighter); | 81 context->drawImage(m_toImage, IntPoint(), CompositePlusLighter); |
82 context->restore(); | 82 context->restore(); |
83 | 83 |
84 context->endLayer(); | 84 context->endLayer(); |
85 } | 85 } |
86 | 86 |
87 void CrossfadeGeneratedImage::draw(GraphicsContext* context, const FloatRect& ds
tRect, const FloatRect& srcRect, CompositeOperator compositeOp, blink::WebBlendM
ode blendMode) | 87 void CrossfadeGeneratedImage::draw(GraphicsContext* context, const FloatRect& ds
tRect, const FloatRect& srcRect, CompositeOperator compositeOp, WebBlendMode ble
ndMode) |
88 { | 88 { |
89 GraphicsContextStateSaver stateSaver(*context); | 89 GraphicsContextStateSaver stateSaver(*context); |
90 context->setCompositeOperation(compositeOp, blendMode); | 90 context->setCompositeOperation(compositeOp, blendMode); |
91 context->clip(dstRect); | 91 context->clip(dstRect); |
92 context->translate(dstRect.x(), dstRect.y()); | 92 context->translate(dstRect.x(), dstRect.y()); |
93 if (dstRect.size() != srcRect.size()) | 93 if (dstRect.size() != srcRect.size()) |
94 context->scale(dstRect.width() / srcRect.width(), dstRect.height() / src
Rect.height()); | 94 context->scale(dstRect.width() / srcRect.width(), dstRect.height() / src
Rect.height()); |
95 context->translate(-srcRect.x(), -srcRect.y()); | 95 context->translate(-srcRect.x(), -srcRect.y()); |
96 | 96 |
97 drawCrossfade(context); | 97 drawCrossfade(context); |
98 } | 98 } |
99 | 99 |
100 void CrossfadeGeneratedImage::drawPattern(GraphicsContext* context, const FloatR
ect& srcRect, const FloatSize& scale, const FloatPoint& phase, CompositeOperator
compositeOp, const FloatRect& dstRect, blink::WebBlendMode blendMode, const Int
Size& repeatSpacing) | 100 void CrossfadeGeneratedImage::drawPattern(GraphicsContext* context, const FloatR
ect& srcRect, const FloatSize& scale, const FloatPoint& phase, CompositeOperator
compositeOp, const FloatRect& dstRect, WebBlendMode blendMode, const IntSize& r
epeatSpacing) |
101 { | 101 { |
102 OwnPtr<ImageBuffer> imageBuffer = context->createRasterBuffer(m_size); | 102 OwnPtr<ImageBuffer> imageBuffer = context->createRasterBuffer(m_size); |
103 if (!imageBuffer) | 103 if (!imageBuffer) |
104 return; | 104 return; |
105 | 105 |
106 // Fill with the cross-faded image. | 106 // Fill with the cross-faded image. |
107 GraphicsContext* graphicsContext = imageBuffer->context(); | 107 GraphicsContext* graphicsContext = imageBuffer->context(); |
108 drawCrossfade(graphicsContext); | 108 drawCrossfade(graphicsContext); |
109 | 109 |
110 // Tile the image buffer into the context. | 110 // Tile the image buffer into the context. |
111 imageBuffer->drawPattern(context, srcRect, scale, phase, compositeOp, dstRec
t, blendMode, repeatSpacing); | 111 imageBuffer->drawPattern(context, srcRect, scale, phase, compositeOp, dstRec
t, blendMode, repeatSpacing); |
112 } | 112 } |
113 | 113 |
114 } | 114 } // namespace blink |
OLD | NEW |