OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. |
3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 DrawLooper::ShadowAlphaMode shadowAlphaMode) | 275 DrawLooper::ShadowAlphaMode shadowAlphaMode) |
276 { | 276 { |
277 if (paintingDisabled()) | 277 if (paintingDisabled()) |
278 return; | 278 return; |
279 | 279 |
280 if (!color.alpha() || (!offset.width() && !offset.height() && !blur)) { | 280 if (!color.alpha() || (!offset.width() && !offset.height() && !blur)) { |
281 clearShadow(); | 281 clearShadow(); |
282 return; | 282 return; |
283 } | 283 } |
284 | 284 |
285 DrawLooper drawLooper; | 285 RefPtr<DrawLooper> drawLooper = adoptRef(new DrawLooper); |
286 drawLooper.addShadow(offset, blur, color, shadowTransformMode, shadowAlphaMo
de); | 286 drawLooper->addShadow(offset, blur, color, shadowTransformMode, shadowAlphaM
ode); |
287 drawLooper.addUnmodifiedContent(); | 287 drawLooper->addUnmodifiedContent(); |
288 setDrawLooper(drawLooper); | 288 setDrawLooper(drawLooper.release()); |
289 } | 289 } |
290 | 290 |
291 void GraphicsContext::setDrawLooper(const DrawLooper& drawLooper) | 291 void GraphicsContext::setDrawLooper(PassRefPtr<DrawLooper> drawLooper) |
292 { | 292 { |
293 if (paintingDisabled()) | 293 if (paintingDisabled()) |
294 return; | 294 return; |
295 | 295 |
296 m_state->m_looper = drawLooper.skDrawLooper(); | 296 m_state->m_looper = drawLooper; |
297 } | 297 } |
298 | 298 |
299 void GraphicsContext::clearDrawLooper() | 299 void GraphicsContext::clearDrawLooper() |
300 { | 300 { |
301 if (paintingDisabled()) | 301 if (paintingDisabled()) |
302 return; | 302 return; |
303 | 303 |
304 m_state->m_looper.clear(); | 304 m_state->m_looper.clear(); |
305 } | 305 } |
306 | 306 |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 save(); | 631 save(); |
632 if (rect.isRounded()) { | 632 if (rect.isRounded()) { |
633 Path path; | 633 Path path; |
634 path.addRoundedRect(rect); | 634 path.addRoundedRect(rect); |
635 clipPath(path); | 635 clipPath(path); |
636 roundedHole.shrinkRadii(shadowSpread); | 636 roundedHole.shrinkRadii(shadowSpread); |
637 } else { | 637 } else { |
638 clip(rect.rect()); | 638 clip(rect.rect()); |
639 } | 639 } |
640 | 640 |
641 DrawLooper drawLooper; | 641 RefPtr<DrawLooper> drawLooper = adoptRef(new DrawLooper); |
642 drawLooper.addShadow(shadowOffset, shadowBlur, shadowColor, | 642 drawLooper->addShadow(shadowOffset, shadowBlur, shadowColor, |
643 DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowIgnoresAlpha); | 643 DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowIgnoresAlpha); |
644 setDrawLooper(drawLooper); | 644 setDrawLooper(drawLooper); |
645 fillRectWithRoundedHole(outerRect, roundedHole, fillColor); | 645 fillRectWithRoundedHole(outerRect, roundedHole, fillColor); |
646 restore(); | 646 restore(); |
647 clearDrawLooper(); | 647 clearDrawLooper(); |
648 } | 648 } |
649 | 649 |
650 // This is only used to draw borders. | 650 // This is only used to draw borders. |
651 void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2) | 651 void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2) |
652 { | 652 { |
(...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1711 { | 1711 { |
1712 #if defined(SK_DEBUG) | 1712 #if defined(SK_DEBUG) |
1713 { | 1713 { |
1714 SkPaint defaultPaint; | 1714 SkPaint defaultPaint; |
1715 SkASSERT(*paint == defaultPaint); | 1715 SkASSERT(*paint == defaultPaint); |
1716 } | 1716 } |
1717 #endif | 1717 #endif |
1718 | 1718 |
1719 paint->setAntiAlias(m_state->m_shouldAntialias); | 1719 paint->setAntiAlias(m_state->m_shouldAntialias); |
1720 paint->setXfermodeMode(m_state->m_xferMode); | 1720 paint->setXfermodeMode(m_state->m_xferMode); |
1721 paint->setLooper(m_state->m_looper.get()); | 1721 paint->setLooper(m_state->m_looper ? m_state->m_looper->skDrawLooper() : 0); |
1722 } | 1722 } |
1723 | 1723 |
1724 void GraphicsContext::drawOuterPath(const SkPath& path, SkPaint& paint, int widt
h) | 1724 void GraphicsContext::drawOuterPath(const SkPath& path, SkPaint& paint, int widt
h) |
1725 { | 1725 { |
1726 #if OS(DARWIN) | 1726 #if OS(DARWIN) |
1727 paint.setAlpha(64); | 1727 paint.setAlpha(64); |
1728 paint.setStrokeWidth(width); | 1728 paint.setStrokeWidth(width); |
1729 paint.setPathEffect(new SkCornerPathEffect((width - 1) * 0.5f))->unref(); | 1729 paint.setPathEffect(new SkCornerPathEffect((width - 1) * 0.5f))->unref(); |
1730 #else | 1730 #else |
1731 paint.setStrokeWidth(1); | 1731 paint.setStrokeWidth(1); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1889 | 1889 |
1890 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) | 1890 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) |
1891 { | 1891 { |
1892 if (m_trackTextRegion) { | 1892 if (m_trackTextRegion) { |
1893 TRACE_EVENT0("skia", "PlatformContextSkia::trackTextRegion"); | 1893 TRACE_EVENT0("skia", "PlatformContextSkia::trackTextRegion"); |
1894 m_textRegion.join(textRect); | 1894 m_textRegion.join(textRect); |
1895 } | 1895 } |
1896 } | 1896 } |
1897 | 1897 |
1898 } | 1898 } |
OLD | NEW |