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

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

Issue 212223006: [CSS Shapes] Simplify RasterShape implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix style errors Created 6 years, 8 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
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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 int maxBufferY = std::min(imageRect.height(), marginRect.maxY() - imageR ect.y()); 195 int maxBufferY = std::min(imageRect.height(), marginRect.maxY() - imageR ect.y());
196 196
197 for (int y = minBufferY; y < maxBufferY; ++y) { 197 for (int y = minBufferY; y < maxBufferY; ++y) {
198 int startX = -1; 198 int startX = -1;
199 for (int x = 0; x < imageRect.width(); ++x, pixelArrayOffset += 4) { 199 for (int x = 0; x < imageRect.width(); ++x, pixelArrayOffset += 4) {
200 uint8_t alpha = pixelArray->item(pixelArrayOffset); 200 uint8_t alpha = pixelArray->item(pixelArrayOffset);
201 bool alphaAboveThreshold = alpha > alphaPixelThreshold; 201 bool alphaAboveThreshold = alpha > alphaPixelThreshold;
202 if (startX == -1 && alphaAboveThreshold) { 202 if (startX == -1 && alphaAboveThreshold) {
203 startX = x; 203 startX = x;
204 } else if (startX != -1 && (!alphaAboveThreshold || x == imageRe ct.width() - 1)) { 204 } else if (startX != -1 && (!alphaAboveThreshold || x == imageRe ct.width() - 1)) {
205 intervals->appendInterval(y + imageRect.y(), startX + imageR ect.x(), x + imageRect.x()); 205 intervals->intervalAt(y + imageRect.y()).unite(IntShapeInter val(startX + imageRect.x(), x + imageRect.x()));
206 startX = -1; 206 startX = -1;
207 } 207 }
208 } 208 }
209 } 209 }
210 } 210 }
211 211
212 OwnPtr<RasterShape> rasterShape = adoptPtr(new RasterShape(intervals.release (), marginRect.size())); 212 OwnPtr<RasterShape> rasterShape = adoptPtr(new RasterShape(intervals.release (), marginRect.size()));
213 rasterShape->m_writingMode = writingMode; 213 rasterShape->m_writingMode = writingMode;
214 rasterShape->m_margin = floatValueForLength(margin, 0); 214 rasterShape->m_margin = floatValueForLength(margin, 0);
215 return rasterShape.release(); 215 return rasterShape.release();
216 } 216 }
217 217
218 PassOwnPtr<Shape> Shape::createLayoutBoxShape(const RoundedRect& roundedRect, Wr itingMode writingMode, const Length& margin) 218 PassOwnPtr<Shape> Shape::createLayoutBoxShape(const RoundedRect& roundedRect, Wr itingMode writingMode, const Length& margin)
219 { 219 {
220 FloatRect rect(0, 0, roundedRect.rect().width(), roundedRect.rect().height() ); 220 FloatRect rect(0, 0, roundedRect.rect().width(), roundedRect.rect().height() );
221 FloatRoundedRect bounds(rect, roundedRect.radii()); 221 FloatRoundedRect bounds(rect, roundedRect.radii());
222 OwnPtr<Shape> shape = createInsetShape(bounds); 222 OwnPtr<Shape> shape = createInsetShape(bounds);
223 shape->m_writingMode = writingMode; 223 shape->m_writingMode = writingMode;
224 shape->m_margin = floatValueForLength(margin, 0); 224 shape->m_margin = floatValueForLength(margin, 0);
225 225
226 return shape.release(); 226 return shape.release();
227 } 227 }
228 228
229 } // namespace WebCore 229 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/shapes/RasterShape.cpp ('k') | Source/core/rendering/shapes/ShapeInterval.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698