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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 return; | 55 return; |
56 | 56 |
57 GraphicsContextStateSaver stateSaver(*context); | 57 GraphicsContextStateSaver stateSaver(*context); |
58 | 58 |
59 context->clip(IntRect(IntPoint(), m_crossfadeSize)); | 59 context->clip(IntRect(IntPoint(), m_crossfadeSize)); |
60 context->beginTransparencyLayer(1); | 60 context->beginTransparencyLayer(1); |
61 | 61 |
62 // Draw the image we're fading away from. | 62 // Draw the image we're fading away from. |
63 context->save(); | 63 context->save(); |
64 if (m_crossfadeSize != fromImageSize) { | 64 if (m_crossfadeSize != fromImageSize) { |
65 context->scale(FloatSize( | 65 context->scale( |
66 static_cast<float>(m_crossfadeSize.width()) / fromImageSize.width(), | 66 static_cast<float>(m_crossfadeSize.width()) / fromImageSize.width(), |
67 static_cast<float>(m_crossfadeSize.height()) / fromImageSize.height(
))); | 67 static_cast<float>(m_crossfadeSize.height()) / fromImageSize.height(
)); |
68 } | 68 } |
69 context->setAlphaAsFloat(inversePercentage); | 69 context->setAlphaAsFloat(inversePercentage); |
70 context->drawImage(m_fromImage, IntPoint()); | 70 context->drawImage(m_fromImage, IntPoint()); |
71 context->restore(); | 71 context->restore(); |
72 | 72 |
73 // Draw the image we're fading towards. | 73 // Draw the image we're fading towards. |
74 context->save(); | 74 context->save(); |
75 if (m_crossfadeSize != toImageSize) { | 75 if (m_crossfadeSize != toImageSize) { |
76 context->scale(FloatSize( | 76 context->scale( |
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, blink::WebBlendM
ode blendMode) |
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(FloatSize(dstRect.width() / srcRect.width(), dstRect.heig
ht() / srcRect.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, blink::WebBlendMode blendMode, const Int
Size& repeatSpacing) |
101 { | 101 { |
102 OwnPtr<ImageBuffer> imageBuffer = context->createCompatibleBuffer(m_size); | 102 OwnPtr<ImageBuffer> imageBuffer = context->createCompatibleBuffer(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 } |
OLD | NEW |