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

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

Issue 169283008: Maintain SkPaint in GraphicsContextState. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: A couple more optimizations. Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « Source/platform/blink_platform.gypi ('k') | Source/platform/graphics/Gradient.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(FloatSize(
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->setAlpha(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(FloatSize(
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->setAlpha(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);
(...skipping 14 matching lines...) Expand all
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 }
OLDNEW
« no previous file with comments | « Source/platform/blink_platform.gypi ('k') | Source/platform/graphics/Gradient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698