| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2008, Google Inc. All rights reserved. | 2 * Copyright (c) 2008, Google Inc. 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 paint->setLooper(m_state->m_looper); | 336 paint->setLooper(m_state->m_looper); |
| 337 } | 337 } |
| 338 | 338 |
| 339 void PlatformContextSkia::setupPaintForFilling(SkPaint* paint) const | 339 void PlatformContextSkia::setupPaintForFilling(SkPaint* paint) const |
| 340 { | 340 { |
| 341 setupPaintCommon(paint); | 341 setupPaintCommon(paint); |
| 342 paint->setColor(m_state->applyAlpha(m_state->m_fillColor)); | 342 paint->setColor(m_state->applyAlpha(m_state->m_fillColor)); |
| 343 paint->setShader(m_state->m_fillShader); | 343 paint->setShader(m_state->m_fillShader); |
| 344 } | 344 } |
| 345 | 345 |
| 346 static SkScalar scalarBound(SkScalar v, SkScalar min, SkScalar max) |
| 347 { |
| 348 if (v < min) |
| 349 return min; |
| 350 if (v > max) |
| 351 return max; |
| 352 return v; |
| 353 } |
| 354 |
| 346 float PlatformContextSkia::setupPaintForStroking(SkPaint* paint, SkRect* rect, i
nt length) const | 355 float PlatformContextSkia::setupPaintForStroking(SkPaint* paint, SkRect* rect, i
nt length) const |
| 347 { | 356 { |
| 348 setupPaintCommon(paint); | 357 setupPaintCommon(paint); |
| 349 float width = m_state->m_strokeThickness; | 358 float width = m_state->m_strokeThickness; |
| 350 | 359 |
| 351 paint->setColor(m_state->applyAlpha(m_state->m_strokeColor)); | 360 paint->setColor(m_state->applyAlpha(m_state->m_strokeColor)); |
| 352 paint->setShader(m_state->m_strokeShader); | 361 paint->setShader(m_state->m_strokeShader); |
| 353 paint->setStyle(SkPaint::kStroke_Style); | 362 paint->setStyle(SkPaint::kStroke_Style); |
| 354 paint->setStrokeWidth(SkFloatToScalar(width)); | 363 // The limits here (512 and 256) were made up but are hopefully large |
| 364 // enough to be reasonable. They are, empirically, small enough not to |
| 365 // cause overflows in Skia. |
| 366 paint->setStrokeWidth(scalarBound(SkFloatToScalar(width), 0, 512)); |
| 355 paint->setStrokeCap(m_state->m_lineCap); | 367 paint->setStrokeCap(m_state->m_lineCap); |
| 356 paint->setStrokeJoin(m_state->m_lineJoin); | 368 paint->setStrokeJoin(m_state->m_lineJoin); |
| 357 paint->setStrokeMiter(SkFloatToScalar(m_state->m_miterLimit)); | 369 paint->setStrokeMiter(scalarBound(SkFloatToScalar(m_state->m_miterLimit), 0,
256)); |
| 358 | 370 |
| 359 if (m_state->m_dash) | 371 if (m_state->m_dash) |
| 360 paint->setPathEffect(m_state->m_dash); | 372 paint->setPathEffect(m_state->m_dash); |
| 361 else { | 373 else { |
| 362 switch (m_state->m_strokeStyle) { | 374 switch (m_state->m_strokeStyle) { |
| 363 case WebCore::NoStroke: | 375 case WebCore::NoStroke: |
| 364 case WebCore::SolidStroke: | 376 case WebCore::SolidStroke: |
| 365 break; | 377 break; |
| 366 case WebCore::DashedStroke: | 378 case WebCore::DashedStroke: |
| 367 width = m_state->m_dashRatio * width; | 379 width = m_state->m_dashRatio * width; |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 paint.setAntiAlias(true); | 614 paint.setAntiAlias(true); |
| 603 paint.setStyle(SkPaint::kFill_Style); | 615 paint.setStyle(SkPaint::kFill_Style); |
| 604 | 616 |
| 605 for (size_t i = paths.size() - 1; i < paths.size(); --i) { | 617 for (size_t i = paths.size() - 1; i < paths.size(); --i) { |
| 606 paths[i].setFillType(SkPath::kInverseWinding_FillType); | 618 paths[i].setFillType(SkPath::kInverseWinding_FillType); |
| 607 m_canvas->drawPath(paths[i], paint); | 619 m_canvas->drawPath(paths[i], paint); |
| 608 } | 620 } |
| 609 | 621 |
| 610 m_canvas->restore(); | 622 m_canvas->restore(); |
| 611 } | 623 } |
| OLD | NEW |