| 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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 paint->setPathEffect(m_state->m_dash); | 304 paint->setPathEffect(m_state->m_dash); |
| 305 else { | 305 else { |
| 306 switch (m_state->m_strokeStyle) { | 306 switch (m_state->m_strokeStyle) { |
| 307 case WebCore::NoStroke: | 307 case WebCore::NoStroke: |
| 308 case WebCore::SolidStroke: | 308 case WebCore::SolidStroke: |
| 309 break; | 309 break; |
| 310 case WebCore::DashedStroke: | 310 case WebCore::DashedStroke: |
| 311 width = m_state->m_dashRatio * width; | 311 width = m_state->m_dashRatio * width; |
| 312 // Fall through. | 312 // Fall through. |
| 313 case WebCore::DottedStroke: | 313 case WebCore::DottedStroke: |
| 314 SkScalar dashLength; | 314 SkScalar dashLength = SkFloatToScalar(width); |
| 315 if (length) { | |
| 316 // Determine about how many dashes or dots we should have. | |
| 317 int numDashes = length / roundf(width); | |
| 318 if (!(numDashes & 1)) | |
| 319 numDashes++; // Make it odd so we end on a dash/dot. | |
| 320 // Use the number of dashes to determine the length of a | |
| 321 // dash/dot, which will be approximately width | |
| 322 dashLength = SkScalarDiv(SkIntToScalar(length), SkIntToScalar(nu
mDashes)); | |
| 323 } else | |
| 324 dashLength = SkFloatToScalar(width); | |
| 325 SkScalar intervals[2] = { dashLength, dashLength }; | 315 SkScalar intervals[2] = { dashLength, dashLength }; |
| 326 paint->setPathEffect(new SkDashPathEffect(intervals, 2, 0))->unref()
; | 316 paint->setPathEffect(new SkDashPathEffect(intervals, 2, 0))->unref()
; |
| 327 } | 317 } |
| 328 } | 318 } |
| 329 | 319 |
| 330 return width; | 320 return width; |
| 331 } | 321 } |
| 332 | 322 |
| 333 void PlatformContextSkia::setDrawLooper(SkDrawLooper* dl) | 323 void PlatformContextSkia::setDrawLooper(SkDrawLooper* dl) |
| 334 { | 324 { |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 #if defined(__linux__) || PLATFORM(WIN_OS) | 475 #if defined(__linux__) || PLATFORM(WIN_OS) |
| 486 void PlatformContextSkia::applyClipFromImage(const WebCore::FloatRect& rect, con
st SkBitmap& imageBuffer) | 476 void PlatformContextSkia::applyClipFromImage(const WebCore::FloatRect& rect, con
st SkBitmap& imageBuffer) |
| 487 { | 477 { |
| 488 // NOTE: this assumes the image mask contains opaque black for the portions
that are to be shown, as such we | 478 // NOTE: this assumes the image mask contains opaque black for the portions
that are to be shown, as such we |
| 489 // only look at the alpha when compositing. I'm not 100% sure this is what W
ebKit expects for image clipping. | 479 // only look at the alpha when compositing. I'm not 100% sure this is what W
ebKit expects for image clipping. |
| 490 SkPaint paint; | 480 SkPaint paint; |
| 491 paint.setPorterDuffXfermode(SkPorterDuff::kDstIn_Mode); | 481 paint.setPorterDuffXfermode(SkPorterDuff::kDstIn_Mode); |
| 492 m_canvas->drawBitmap(imageBuffer, SkFloatToScalar(rect.x()), SkFloatToScalar
(rect.y()), &paint); | 482 m_canvas->drawBitmap(imageBuffer, SkFloatToScalar(rect.x()), SkFloatToScalar
(rect.y()), &paint); |
| 493 } | 483 } |
| 494 #endif | 484 #endif |
| OLD | NEW |