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

Side by Side Diff: third_party/WebKit/Source/core/layout/shapes/Shape.cpp

Issue 2523673004: [NOT FOR COMMIT] Fully replace SkCanvas uses.
Patch Set: Support Android build. Created 4 years 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
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 26 matching lines...) Expand all
37 #include "core/layout/shapes/PolygonShape.h" 37 #include "core/layout/shapes/PolygonShape.h"
38 #include "core/layout/shapes/RasterShape.h" 38 #include "core/layout/shapes/RasterShape.h"
39 #include "core/layout/shapes/RectangleShape.h" 39 #include "core/layout/shapes/RectangleShape.h"
40 #include "core/style/ComputedStyle.h" 40 #include "core/style/ComputedStyle.h"
41 #include "core/svg/graphics/SVGImage.h" 41 #include "core/svg/graphics/SVGImage.h"
42 #include "platform/LengthFunctions.h" 42 #include "platform/LengthFunctions.h"
43 #include "platform/geometry/FloatRoundedRect.h" 43 #include "platform/geometry/FloatRoundedRect.h"
44 #include "platform/geometry/FloatSize.h" 44 #include "platform/geometry/FloatSize.h"
45 #include "platform/graphics/GraphicsTypes.h" 45 #include "platform/graphics/GraphicsTypes.h"
46 #include "platform/graphics/ImageBuffer.h" 46 #include "platform/graphics/ImageBuffer.h"
47 #include "skia/ext/cdl_paint.h"
47 #include "wtf/MathExtras.h" 48 #include "wtf/MathExtras.h"
48 #include "wtf/PtrUtil.h" 49 #include "wtf/PtrUtil.h"
49 #include "wtf/typed_arrays/ArrayBufferContents.h" 50 #include "wtf/typed_arrays/ArrayBufferContents.h"
50 #include <memory> 51 #include <memory>
51 52
52 namespace blink { 53 namespace blink {
53 54
54 static std::unique_ptr<Shape> createInsetShape(const FloatRoundedRect& bounds) { 55 static std::unique_ptr<Shape> createInsetShape(const FloatRoundedRect& bounds) {
55 ASSERT(bounds.rect().width() >= 0 && bounds.rect().height() >= 0); 56 ASSERT(bounds.rect().width() >= 0 && bounds.rect().height() >= 0);
56 return makeUnique<BoxShape>(bounds); 57 return makeUnique<BoxShape>(bounds);
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 std::unique_ptr<RasterShapeIntervals> intervals = wrapUnique( 234 std::unique_ptr<RasterShapeIntervals> intervals = wrapUnique(
234 new RasterShapeIntervals(marginRect.height(), -marginRect.y())); 235 new RasterShapeIntervals(marginRect.height(), -marginRect.y()));
235 std::unique_ptr<ImageBuffer> imageBuffer = 236 std::unique_ptr<ImageBuffer> imageBuffer =
236 ImageBuffer::create(imageRect.size()); 237 ImageBuffer::create(imageRect.size());
237 238
238 if (image && imageBuffer) { 239 if (image && imageBuffer) {
239 // FIXME: This is not totally correct but it is needed to prevent shapes 240 // FIXME: This is not totally correct but it is needed to prevent shapes
240 // that loads SVG Images during paint invalidations to mark layoutObjects 241 // that loads SVG Images during paint invalidations to mark layoutObjects
241 // for layout, which is not allowed. See https://crbug.com/429346 242 // for layout, which is not allowed. See https://crbug.com/429346
242 ImageObserverDisabler disabler(image); 243 ImageObserverDisabler disabler(image);
243 SkPaint paint; 244 CdlPaint paint;
244 IntRect imageSourceRect(IntPoint(), image->size()); 245 IntRect imageSourceRect(IntPoint(), image->size());
245 IntRect imageDestRect(IntPoint(), imageRect.size()); 246 IntRect imageDestRect(IntPoint(), imageRect.size());
247
246 image->draw(imageBuffer->canvas(), paint, imageDestRect, imageSourceRect, 248 image->draw(imageBuffer->canvas(), paint, imageDestRect, imageSourceRect,
247 DoNotRespectImageOrientation, 249 DoNotRespectImageOrientation,
248 Image::DoNotClampImageToSourceRect); 250 Image::DoNotClampImageToSourceRect);
249 251
250 WTF::ArrayBufferContents contents; 252 WTF::ArrayBufferContents contents;
251 imageBuffer->getImageData(Unmultiplied, 253 imageBuffer->getImageData(Unmultiplied,
252 IntRect(IntPoint(), imageRect.size()), contents); 254 IntRect(IntPoint(), imageRect.size()), contents);
253 DOMArrayBuffer* arrayBuffer = DOMArrayBuffer::create(contents); 255 DOMArrayBuffer* arrayBuffer = DOMArrayBuffer::create(contents);
254 DOMUint8ClampedArray* pixelArray = 256 DOMUint8ClampedArray* pixelArray =
255 DOMUint8ClampedArray::create(arrayBuffer, 0, arrayBuffer->byteLength()); 257 DOMUint8ClampedArray::create(arrayBuffer, 0, arrayBuffer->byteLength());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 FloatRect rect(0, 0, roundedRect.rect().width(), roundedRect.rect().height()); 298 FloatRect rect(0, 0, roundedRect.rect().width(), roundedRect.rect().height());
297 FloatRoundedRect bounds(rect, roundedRect.getRadii()); 299 FloatRoundedRect bounds(rect, roundedRect.getRadii());
298 std::unique_ptr<Shape> shape = createInsetShape(bounds); 300 std::unique_ptr<Shape> shape = createInsetShape(bounds);
299 shape->m_writingMode = writingMode; 301 shape->m_writingMode = writingMode;
300 shape->m_margin = margin; 302 shape->m_margin = margin;
301 303
302 return shape; 304 return shape;
303 } 305 }
304 306
305 } // namespace blink 307 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698