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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 setFillColor(Color::black); | 319 setFillColor(Color::black); |
320 return; | 320 return; |
321 } | 321 } |
322 | 322 |
323 GraphicsContextState* stateToSet = mutableState(); | 323 GraphicsContextState* stateToSet = mutableState(); |
324 stateToSet->m_fillGradient = gradient; | 324 stateToSet->m_fillGradient = gradient; |
325 stateToSet->m_fillPattern.clear(); | 325 stateToSet->m_fillPattern.clear(); |
326 } | 326 } |
327 | 327 |
328 void GraphicsContext::setShadow(const FloatSize& offset, float blur, const Color
& color, | 328 void GraphicsContext::setShadow(const FloatSize& offset, float blur, const Color
& color, |
329 DrawLooper::ShadowTransformMode shadowTransformMode, | 329 DrawLooperBuilder::ShadowTransformMode shadowTransformMode, |
330 DrawLooper::ShadowAlphaMode shadowAlphaMode) | 330 DrawLooperBuilder::ShadowAlphaMode shadowAlphaMode) |
331 { | 331 { |
332 if (paintingDisabled()) | 332 if (paintingDisabled()) |
333 return; | 333 return; |
334 | 334 |
335 if (!color.alpha() || (!offset.width() && !offset.height() && !blur)) { | 335 if (!color.alpha() || (!offset.width() && !offset.height() && !blur)) { |
336 clearShadow(); | 336 clearShadow(); |
337 return; | 337 return; |
338 } | 338 } |
339 | 339 |
340 DrawLooper drawLooper; | 340 OwnPtr<DrawLooperBuilder> drawLooperBuilder = DrawLooperBuilder::create(); |
341 drawLooper.addShadow(offset, blur, color, shadowTransformMode, shadowAlphaMo
de); | 341 drawLooperBuilder->addShadow(offset, blur, color, shadowTransformMode, shado
wAlphaMode); |
342 drawLooper.addUnmodifiedContent(); | 342 drawLooperBuilder->addUnmodifiedContent(); |
343 setDrawLooper(drawLooper); | 343 setDrawLooper(drawLooperBuilder.release()); |
344 } | 344 } |
345 | 345 |
346 void GraphicsContext::setDrawLooper(const DrawLooper& drawLooper) | 346 void GraphicsContext::setDrawLooper(PassOwnPtr<DrawLooperBuilder> drawLooperBuil
der) |
347 { | 347 { |
348 if (paintingDisabled()) | 348 if (paintingDisabled()) |
349 return; | 349 return; |
350 | 350 |
351 mutableState()->m_looper = drawLooper.skDrawLooper(); | 351 mutableState()->m_looper = drawLooperBuilder->detachDrawLooper(); |
352 } | 352 } |
353 | 353 |
354 void GraphicsContext::clearDrawLooper() | 354 void GraphicsContext::clearDrawLooper() |
355 { | 355 { |
356 if (paintingDisabled()) | 356 if (paintingDisabled()) |
357 return; | 357 return; |
358 | 358 |
359 mutableState()->m_looper.clear(); | 359 mutableState()->m_looper.clear(); |
360 } | 360 } |
361 | 361 |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 save(); | 765 save(); |
766 if (rect.isRounded()) { | 766 if (rect.isRounded()) { |
767 Path path; | 767 Path path; |
768 path.addRoundedRect(rect); | 768 path.addRoundedRect(rect); |
769 clipPath(path); | 769 clipPath(path); |
770 roundedHole.shrinkRadii(shadowSpread); | 770 roundedHole.shrinkRadii(shadowSpread); |
771 } else { | 771 } else { |
772 clip(rect.rect()); | 772 clip(rect.rect()); |
773 } | 773 } |
774 | 774 |
775 DrawLooper drawLooper; | 775 OwnPtr<DrawLooperBuilder> drawLooperBuilder = DrawLooperBuilder::create(); |
776 drawLooper.addShadow(shadowOffset, shadowBlur, shadowColor, | 776 drawLooperBuilder->addShadow(shadowOffset, shadowBlur, shadowColor, |
777 DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowIgnoresAlpha); | 777 DrawLooperBuilder::ShadowRespectsTransforms, DrawLooperBuilder::ShadowIg
noresAlpha); |
778 setDrawLooper(drawLooper); | 778 setDrawLooper(drawLooperBuilder.release()); |
779 fillRectWithRoundedHole(outerRect, roundedHole, fillColor); | 779 fillRectWithRoundedHole(outerRect, roundedHole, fillColor); |
780 restore(); | 780 restore(); |
781 clearDrawLooper(); | 781 clearDrawLooper(); |
782 } | 782 } |
783 | 783 |
784 // This is only used to draw borders. | 784 // This is only used to draw borders. |
785 void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2) | 785 void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2) |
786 { | 786 { |
787 if (paintingDisabled()) | 787 if (paintingDisabled()) |
788 return; | 788 return; |
(...skipping 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2032 | 2032 |
2033 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) | 2033 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) |
2034 { | 2034 { |
2035 if (m_trackTextRegion) { | 2035 if (m_trackTextRegion) { |
2036 TRACE_EVENT0("skia", "PlatformContextSkia::trackTextRegion"); | 2036 TRACE_EVENT0("skia", "PlatformContextSkia::trackTextRegion"); |
2037 m_textRegion.join(textRect); | 2037 m_textRegion.join(textRect); |
2038 } | 2038 } |
2039 } | 2039 } |
2040 | 2040 |
2041 } | 2041 } |
OLD | NEW |