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

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

Issue 1170523002: Removing GraphicsContext from ImageBuffer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix for shape bug Created 5 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 | Annotate | Revision Log
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 25 matching lines...) Expand all
36 #include "core/fetch/ImageResource.h" 36 #include "core/fetch/ImageResource.h"
37 #include "core/layout/shapes/BoxShape.h" 37 #include "core/layout/shapes/BoxShape.h"
38 #include "core/layout/shapes/PolygonShape.h" 38 #include "core/layout/shapes/PolygonShape.h"
39 #include "core/layout/shapes/RasterShape.h" 39 #include "core/layout/shapes/RasterShape.h"
40 #include "core/layout/shapes/RectangleShape.h" 40 #include "core/layout/shapes/RectangleShape.h"
41 #include "core/style/ComputedStyle.h" 41 #include "core/style/ComputedStyle.h"
42 #include "core/svg/graphics/SVGImage.h" 42 #include "core/svg/graphics/SVGImage.h"
43 #include "platform/LengthFunctions.h" 43 #include "platform/LengthFunctions.h"
44 #include "platform/geometry/FloatRoundedRect.h" 44 #include "platform/geometry/FloatRoundedRect.h"
45 #include "platform/geometry/FloatSize.h" 45 #include "platform/geometry/FloatSize.h"
46 #include "platform/graphics/GraphicsContext.h"
47 #include "platform/graphics/GraphicsTypes.h" 46 #include "platform/graphics/GraphicsTypes.h"
48 #include "platform/graphics/ImageBuffer.h" 47 #include "platform/graphics/ImageBuffer.h"
49 #include "wtf/ArrayBufferContents.h" 48 #include "wtf/ArrayBufferContents.h"
50 #include "wtf/MathExtras.h" 49 #include "wtf/MathExtras.h"
51 #include "wtf/OwnPtr.h" 50 #include "wtf/OwnPtr.h"
52 51
53 namespace blink { 52 namespace blink {
54 53
55 static PassOwnPtr<Shape> createInsetShape(const FloatRoundedRect& bounds) 54 static PassOwnPtr<Shape> createInsetShape(const FloatRoundedRect& bounds)
56 { 55 {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 191
193 PassOwnPtr<Shape> Shape::createRasterShape(Image* image, float threshold, const LayoutRect& imageR, const LayoutRect& marginR, WritingMode writingMode, float ma rgin) 192 PassOwnPtr<Shape> Shape::createRasterShape(Image* image, float threshold, const LayoutRect& imageR, const LayoutRect& marginR, WritingMode writingMode, float ma rgin)
194 { 193 {
195 IntRect imageRect = pixelSnappedIntRect(imageR); 194 IntRect imageRect = pixelSnappedIntRect(imageR);
196 IntRect marginRect = pixelSnappedIntRect(marginR); 195 IntRect marginRect = pixelSnappedIntRect(marginR);
197 196
198 OwnPtr<RasterShapeIntervals> intervals = adoptPtr(new RasterShapeIntervals(m arginRect.height(), -marginRect.y())); 197 OwnPtr<RasterShapeIntervals> intervals = adoptPtr(new RasterShapeIntervals(m arginRect.height(), -marginRect.y()));
199 OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(imageRect.size()); 198 OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(imageRect.size());
200 199
201 if (image && imageBuffer) { 200 if (image && imageBuffer) {
202 GraphicsContext* graphicsContext = imageBuffer->context();
203 // FIXME: This is not totally correct but it is needed to prevent shapes 201 // FIXME: This is not totally correct but it is needed to prevent shapes
204 // that loads SVG Images during paint invalidations to mark layoutObject s for 202 // that loads SVG Images during paint invalidations to mark layoutObject s for
205 // layout, which is not allowed. See https://crbug.com/429346 203 // layout, which is not allowed. See https://crbug.com/429346
206 ImageObserverDisabler disabler(image); 204 ImageObserverDisabler disabler(image);
207 graphicsContext->drawImage(image, IntRect(IntPoint(), imageRect.size())) ; 205 SkPaint paint;
206 IntRect imageSourceRect(IntPoint(), image->size());
207 IntRect imageDestRect(IntPoint(), imageRect.size());
208 image->draw(imageBuffer->canvas(), paint, imageDestRect, imageSourceRect , DoNotRespectImageOrientation, Image::DoNotClampImageToSourceRect);
208 209
209 WTF::ArrayBufferContents contents; 210 WTF::ArrayBufferContents contents;
210 imageBuffer->getImageData(Unmultiplied, IntRect(IntPoint(), imageRect.si ze()), contents); 211 imageBuffer->getImageData(Unmultiplied, IntRect(IntPoint(), imageRect.si ze()), contents);
211 RefPtr<DOMArrayBuffer> arrayBuffer = DOMArrayBuffer::create(contents); 212 RefPtr<DOMArrayBuffer> arrayBuffer = DOMArrayBuffer::create(contents);
212 RefPtr<DOMUint8ClampedArray> pixelArray = DOMUint8ClampedArray::create(a rrayBuffer, 0, arrayBuffer->byteLength()); 213 RefPtr<DOMUint8ClampedArray> pixelArray = DOMUint8ClampedArray::create(a rrayBuffer, 0, arrayBuffer->byteLength());
213 unsigned pixelArrayOffset = 3; // Each pixel is four bytes: RGBA. 214 unsigned pixelArrayOffset = 3; // Each pixel is four bytes: RGBA.
214 uint8_t alphaPixelThreshold = threshold * 255; 215 uint8_t alphaPixelThreshold = threshold * 255;
215 216
216 ASSERT(static_cast<unsigned>(imageRect.width() * imageRect.height() * 4) == pixelArray->length()); 217 ASSERT(static_cast<unsigned>(imageRect.width() * imageRect.height() * 4) == pixelArray->length());
217 218
(...skipping 27 matching lines...) Expand all
245 FloatRect rect(0, 0, roundedRect.rect().width(), roundedRect.rect().height() ); 246 FloatRect rect(0, 0, roundedRect.rect().width(), roundedRect.rect().height() );
246 FloatRoundedRect bounds(rect, roundedRect.radii()); 247 FloatRoundedRect bounds(rect, roundedRect.radii());
247 OwnPtr<Shape> shape = createInsetShape(bounds); 248 OwnPtr<Shape> shape = createInsetShape(bounds);
248 shape->m_writingMode = writingMode; 249 shape->m_writingMode = writingMode;
249 shape->m_margin = margin; 250 shape->m_margin = margin;
250 251
251 return shape.release(); 252 return shape.release();
252 } 253 }
253 254
254 } // namespace blink 255 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/html/canvas/WebGLRenderingContextBase.cpp ('k') | Source/core/paint/ThemePainterMac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698