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

Side by Side Diff: Source/core/rendering/shapes/Shape.cpp

Issue 665673004: Move selection invalidation to the invalidation phase (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated after Xianzhu's comments. Created 6 years, 1 month 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/rendering/RenderView.cpp ('k') | Source/core/svg/graphics/SVGImage.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) 2012 Adobe Systems Incorporated. All rights reserved. 2 * Copyright (C) 2012 Adobe Systems Incorporated. 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 * 7 *
8 * 1. Redistributions of source code must retain the above 8 * 1. Redistributions of source code must retain the above
9 * copyright notice, this list of conditions and the following 9 * copyright notice, this list of conditions and the following
10 * disclaimer. 10 * disclaimer.
(...skipping 19 matching lines...) Expand all
30 #include "config.h" 30 #include "config.h"
31 #include "core/rendering/shapes/Shape.h" 31 #include "core/rendering/shapes/Shape.h"
32 32
33 #include "core/css/BasicShapeFunctions.h" 33 #include "core/css/BasicShapeFunctions.h"
34 #include "core/fetch/ImageResource.h" 34 #include "core/fetch/ImageResource.h"
35 #include "core/rendering/shapes/BoxShape.h" 35 #include "core/rendering/shapes/BoxShape.h"
36 #include "core/rendering/shapes/PolygonShape.h" 36 #include "core/rendering/shapes/PolygonShape.h"
37 #include "core/rendering/shapes/RasterShape.h" 37 #include "core/rendering/shapes/RasterShape.h"
38 #include "core/rendering/shapes/RectangleShape.h" 38 #include "core/rendering/shapes/RectangleShape.h"
39 #include "core/rendering/style/RenderStyle.h" 39 #include "core/rendering/style/RenderStyle.h"
40 #include "core/svg/graphics/SVGImage.h"
40 #include "platform/LengthFunctions.h" 41 #include "platform/LengthFunctions.h"
41 #include "platform/geometry/FloatSize.h" 42 #include "platform/geometry/FloatSize.h"
42 #include "platform/graphics/GraphicsContext.h" 43 #include "platform/graphics/GraphicsContext.h"
43 #include "platform/graphics/GraphicsTypes.h" 44 #include "platform/graphics/GraphicsTypes.h"
44 #include "platform/graphics/ImageBuffer.h" 45 #include "platform/graphics/ImageBuffer.h"
45 #include "wtf/MathExtras.h" 46 #include "wtf/MathExtras.h"
46 #include "wtf/OwnPtr.h" 47 #include "wtf/OwnPtr.h"
47 48
48 namespace blink { 49 namespace blink {
49 50
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 } 186 }
186 187
187 PassOwnPtr<Shape> Shape::createRasterShape(Image* image, float threshold, const LayoutRect& imageR, const LayoutRect& marginR, WritingMode writingMode, float ma rgin) 188 PassOwnPtr<Shape> Shape::createRasterShape(Image* image, float threshold, const LayoutRect& imageR, const LayoutRect& marginR, WritingMode writingMode, float ma rgin)
188 { 189 {
189 IntRect imageRect = pixelSnappedIntRect(imageR); 190 IntRect imageRect = pixelSnappedIntRect(imageR);
190 IntRect marginRect = pixelSnappedIntRect(marginR); 191 IntRect marginRect = pixelSnappedIntRect(marginR);
191 192
192 OwnPtr<RasterShapeIntervals> intervals = adoptPtr(new RasterShapeIntervals(m arginRect.height(), -marginRect.y())); 193 OwnPtr<RasterShapeIntervals> intervals = adoptPtr(new RasterShapeIntervals(m arginRect.height(), -marginRect.y()));
193 OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(imageRect.size()); 194 OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(imageRect.size());
194 195
195 if (imageBuffer) { 196 if (image && imageBuffer) {
196 GraphicsContext* graphicsContext = imageBuffer->context(); 197 GraphicsContext* graphicsContext = imageBuffer->context();
198 // FIXME: This is not totally correct but it is needed to prevent shapes
199 // that loads SVG Images during paint invalidations to mark renderers fo r
200 // layout, which is not allowed. See https://crbug.com/429346
201 ImageObserverDisabler disabler(image);
197 graphicsContext->drawImage(image, IntRect(IntPoint(), imageRect.size())) ; 202 graphicsContext->drawImage(image, IntRect(IntPoint(), imageRect.size())) ;
198 203
199 RefPtr<Uint8ClampedArray> pixelArray = imageBuffer->getImageData(Unmulti plied, IntRect(IntPoint(), imageRect.size())); 204 RefPtr<Uint8ClampedArray> pixelArray = imageBuffer->getImageData(Unmulti plied, IntRect(IntPoint(), imageRect.size()));
200 unsigned pixelArrayOffset = 3; // Each pixel is four bytes: RGBA. 205 unsigned pixelArrayOffset = 3; // Each pixel is four bytes: RGBA.
201 uint8_t alphaPixelThreshold = threshold * 255; 206 uint8_t alphaPixelThreshold = threshold * 255;
202 207
203 ASSERT(static_cast<unsigned>(imageRect.width() * imageRect.height() * 4) == pixelArray->length()); 208 ASSERT(static_cast<unsigned>(imageRect.width() * imageRect.height() * 4) == pixelArray->length());
204 209
205 int minBufferY = std::max(0, marginRect.y() - imageRect.y()); 210 int minBufferY = std::max(0, marginRect.y() - imageRect.y());
206 int maxBufferY = std::min(imageRect.height(), marginRect.maxY() - imageR ect.y()); 211 int maxBufferY = std::min(imageRect.height(), marginRect.maxY() - imageR ect.y());
(...skipping 25 matching lines...) Expand all
232 FloatRect rect(0, 0, roundedRect.rect().width(), roundedRect.rect().height() ); 237 FloatRect rect(0, 0, roundedRect.rect().width(), roundedRect.rect().height() );
233 FloatRoundedRect bounds(rect, roundedRect.radii()); 238 FloatRoundedRect bounds(rect, roundedRect.radii());
234 OwnPtr<Shape> shape = createInsetShape(bounds); 239 OwnPtr<Shape> shape = createInsetShape(bounds);
235 shape->m_writingMode = writingMode; 240 shape->m_writingMode = writingMode;
236 shape->m_margin = margin; 241 shape->m_margin = margin;
237 242
238 return shape.release(); 243 return shape.release();
239 } 244 }
240 245
241 } // namespace blink 246 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderView.cpp ('k') | Source/core/svg/graphics/SVGImage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698