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

Side by Side Diff: Source/core/svg/graphics/SVGImage.cpp

Issue 16357011: Remove support for -webkit-color-correction (which we've never supported on (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: resolve merge conflicts, obey brace style changes Created 7 years, 6 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
« no previous file with comments | « Source/core/svg/graphics/SVGImage.h ('k') | Source/core/svg/graphics/SVGImageForContainer.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) 2006 Eric Seidel <eric@webkit.org> 2 * Copyright (C) 2006 Eric Seidel <eric@webkit.org>
3 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. 3 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
4 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 4 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 currentSize = rootElement->currentViewBoxRect().size(); 108 currentSize = rootElement->currentViewBoxRect().size();
109 109
110 if (!currentSize.isEmpty()) 110 if (!currentSize.isEmpty())
111 return IntSize(static_cast<int>(ceilf(currentSize.width())), static_cast <int>(ceilf(currentSize.height()))); 111 return IntSize(static_cast<int>(ceilf(currentSize.width())), static_cast <int>(ceilf(currentSize.height())));
112 112
113 // As last resort, use CSS default intrinsic size. 113 // As last resort, use CSS default intrinsic size.
114 return IntSize(300, 150); 114 return IntSize(300, 150);
115 } 115 }
116 116
117 void SVGImage::drawForContainer(GraphicsContext* context, const FloatSize contai nerSize, float zoom, const FloatRect& dstRect, 117 void SVGImage::drawForContainer(GraphicsContext* context, const FloatSize contai nerSize, float zoom, const FloatRect& dstRect,
118 const FloatRect& srcRect, ColorSpace colorSpace, CompositeOperator composite Op, BlendMode blendMode) 118 const FloatRect& srcRect, CompositeOperator compositeOp, BlendMode blendMode )
119 { 119 {
120 if (!m_page) 120 if (!m_page)
121 return; 121 return;
122 122
123 ImageObserver* observer = imageObserver(); 123 ImageObserver* observer = imageObserver();
124 ASSERT(observer); 124 ASSERT(observer);
125 125
126 // Temporarily reset image observer, we don't want to receive any changeInRe ct() calls due to this relayout. 126 // Temporarily reset image observer, we don't want to receive any changeInRe ct() calls due to this relayout.
127 setImageObserver(0); 127 setImageObserver(0);
128 128
129 IntSize roundedContainerSize = roundedIntSize(containerSize); 129 IntSize roundedContainerSize = roundedIntSize(containerSize);
130 setContainerSize(roundedContainerSize); 130 setContainerSize(roundedContainerSize);
131 131
132 FloatRect scaledSrc = srcRect; 132 FloatRect scaledSrc = srcRect;
133 scaledSrc.scale(1 / zoom); 133 scaledSrc.scale(1 / zoom);
134 134
135 // Compensate for the container size rounding by adjusting the source rect. 135 // Compensate for the container size rounding by adjusting the source rect.
136 FloatSize adjustedSrcSize = scaledSrc.size(); 136 FloatSize adjustedSrcSize = scaledSrc.size();
137 adjustedSrcSize.scale(roundedContainerSize.width() / containerSize.width(), roundedContainerSize.height() / containerSize.height()); 137 adjustedSrcSize.scale(roundedContainerSize.width() / containerSize.width(), roundedContainerSize.height() / containerSize.height());
138 scaledSrc.setSize(adjustedSrcSize); 138 scaledSrc.setSize(adjustedSrcSize);
139 139
140 draw(context, dstRect, scaledSrc, colorSpace, compositeOp, blendMode); 140 draw(context, dstRect, scaledSrc, compositeOp, blendMode);
141 141
142 setImageObserver(observer); 142 setImageObserver(observer);
143 } 143 }
144 144
145 // Passes ownership of the native image to the caller so PassNativeImagePtr need s 145 // Passes ownership of the native image to the caller so PassNativeImagePtr need s
146 // to be a smart pointer type. 146 // to be a smart pointer type.
147 PassNativeImagePtr SVGImage::nativeImageForCurrentFrame() 147 PassNativeImagePtr SVGImage::nativeImageForCurrentFrame()
148 { 148 {
149 if (!m_page) 149 if (!m_page)
150 return 0; 150 return 0;
151 151
152 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(size(), 1); 152 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(size(), 1);
153 if (!buffer) // failed to allocate image 153 if (!buffer) // failed to allocate image
154 return 0; 154 return 0;
155 155
156 draw(buffer->context(), rect(), rect(), ColorSpaceDeviceRGB, CompositeSource Over, BlendModeNormal); 156 draw(buffer->context(), rect(), rect(), CompositeSourceOver, BlendModeNormal );
157 157
158 // FIXME: WK(Bug 113657): We should use DontCopyBackingStore here. 158 // FIXME: WK(Bug 113657): We should use DontCopyBackingStore here.
159 return buffer->copyImage(CopyBackingStore)->nativeImageForCurrentFrame(); 159 return buffer->copyImage(CopyBackingStore)->nativeImageForCurrentFrame();
160 } 160 }
161 161
162 void SVGImage::drawPatternForContainer(GraphicsContext* context, const FloatSize containerSize, float zoom, const FloatRect& srcRect, 162 void SVGImage::drawPatternForContainer(GraphicsContext* context, const FloatSize containerSize, float zoom, const FloatRect& srcRect,
163 const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace colorSpace, CompositeOperator compositeOp, const FloatRect& dstRect) 163 const AffineTransform& patternTransform, const FloatPoint& phase, CompositeO perator compositeOp, const FloatRect& dstRect)
164 { 164 {
165 FloatRect zoomedContainerRect = FloatRect(FloatPoint(), containerSize); 165 FloatRect zoomedContainerRect = FloatRect(FloatPoint(), containerSize);
166 zoomedContainerRect.scale(zoom); 166 zoomedContainerRect.scale(zoom);
167 167
168 // The ImageBuffer size needs to be scaled to match the final resolution. 168 // The ImageBuffer size needs to be scaled to match the final resolution.
169 AffineTransform transform = context->getCTM(); 169 AffineTransform transform = context->getCTM();
170 FloatSize imageBufferScale = FloatSize(transform.xScale(), transform.yScale( )); 170 FloatSize imageBufferScale = FloatSize(transform.xScale(), transform.yScale( ));
171 ASSERT(imageBufferScale.width()); 171 ASSERT(imageBufferScale.width());
172 ASSERT(imageBufferScale.height()); 172 ASSERT(imageBufferScale.height());
173 173
174 FloatRect imageBufferSize = zoomedContainerRect; 174 FloatRect imageBufferSize = zoomedContainerRect;
175 imageBufferSize.scale(imageBufferScale.width(), imageBufferScale.height()); 175 imageBufferSize.scale(imageBufferScale.width(), imageBufferScale.height());
176 176
177 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(expandedIntSize(imageBuffer Size.size()), 1); 177 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(expandedIntSize(imageBuffer Size.size()), 1);
178 drawForContainer(buffer->context(), containerSize, zoom, imageBufferSize, zo omedContainerRect, ColorSpaceDeviceRGB, CompositeSourceOver, BlendModeNormal); 178 drawForContainer(buffer->context(), containerSize, zoom, imageBufferSize, zo omedContainerRect, CompositeSourceOver, BlendModeNormal);
179 RefPtr<Image> image = buffer->copyImage(DontCopyBackingStore, Unscaled); 179 RefPtr<Image> image = buffer->copyImage(DontCopyBackingStore, Unscaled);
180 180
181 // Adjust the source rect and transform due to the image buffer's scaling. 181 // Adjust the source rect and transform due to the image buffer's scaling.
182 FloatRect scaledSrcRect = srcRect; 182 FloatRect scaledSrcRect = srcRect;
183 scaledSrcRect.scale(imageBufferScale.width(), imageBufferScale.height()); 183 scaledSrcRect.scale(imageBufferScale.width(), imageBufferScale.height());
184 AffineTransform unscaledPatternTransform(patternTransform); 184 AffineTransform unscaledPatternTransform(patternTransform);
185 unscaledPatternTransform.scale(1 / imageBufferScale.width(), 1 / imageBuffer Scale.height()); 185 unscaledPatternTransform.scale(1 / imageBufferScale.width(), 1 / imageBuffer Scale.height());
186 186
187 image->drawPattern(context, scaledSrcRect, unscaledPatternTransform, phase, colorSpace, compositeOp, dstRect); 187 image->drawPattern(context, scaledSrcRect, unscaledPatternTransform, phase, compositeOp, dstRect);
188 } 188 }
189 189
190 void SVGImage::draw(GraphicsContext* context, const FloatRect& dstRect, const Fl oatRect& srcRect, ColorSpace, CompositeOperator compositeOp, BlendMode) 190 void SVGImage::draw(GraphicsContext* context, const FloatRect& dstRect, const Fl oatRect& srcRect, CompositeOperator compositeOp, BlendMode)
191 { 191 {
192 if (!m_page) 192 if (!m_page)
193 return; 193 return;
194 194
195 FrameView* view = frameView(); 195 FrameView* view = frameView();
196 196
197 GraphicsContextStateSaver stateSaver(*context); 197 GraphicsContextStateSaver stateSaver(*context);
198 context->setCompositeOperation(compositeOp); 198 context->setCompositeOperation(compositeOp);
199 context->clip(enclosingIntRect(dstRect)); 199 context->clip(enclosingIntRect(dstRect));
200 if (compositeOp != CompositeSourceOver) 200 if (compositeOp != CompositeSourceOver)
201 context->beginTransparencyLayer(1); 201 context->beginTransparencyLayer(1);
202 202
203 FloatSize scale(dstRect.width() / srcRect.width(), dstRect.height() / srcRec t.height()); 203 FloatSize scale(dstRect.width() / srcRect.width(), dstRect.height() / srcRec t.height());
204 204
205 // We can only draw the entire frame, clipped to the rect we want. So comput e where the top left 205 // We can only draw the entire frame, clipped to the rect we want. So comput e where the top left
206 // of the image would be if we were drawing without clipping, and translate accordingly. 206 // of the image would be if we were drawing without clipping, and translate accordingly.
207 FloatSize topLeftOffset(srcRect.location().x() * scale.width(), srcRect.loca tion().y() * scale.height()); 207 FloatSize topLeftOffset(srcRect.location().x() * scale.width(), srcRect.loca tion().y() * scale.height());
208 FloatPoint destOffset = dstRect.location() - topLeftOffset; 208 FloatPoint destOffset = dstRect.location() - topLeftOffset;
209 209
210 context->translate(destOffset.x(), destOffset.y()); 210 context->translate(destOffset.x(), destOffset.y());
211 context->scale(scale); 211 context->scale(scale);
212 212
213 view->resize(containerSize()); 213 view->resize(containerSize());
214 214
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 void SVGImage::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const 371 void SVGImage::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
372 { 372 {
373 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CachedResou rceImage); 373 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CachedResou rceImage);
374 Image::reportMemoryUsage(memoryObjectInfo); 374 Image::reportMemoryUsage(memoryObjectInfo);
375 info.addMember(m_chromeClient, "chromeClient"); 375 info.addMember(m_chromeClient, "chromeClient");
376 info.addMember(m_page, "page"); 376 info.addMember(m_page, "page");
377 } 377 }
378 378
379 } 379 }
380 380
OLDNEW
« no previous file with comments | « Source/core/svg/graphics/SVGImage.h ('k') | Source/core/svg/graphics/SVGImageForContainer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698