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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 ASSERT(gradient); | 284 ASSERT(gradient); |
285 if (!gradient) { | 285 if (!gradient) { |
286 setFillColor(Color::black); | 286 setFillColor(Color::black); |
287 return; | 287 return; |
288 } | 288 } |
289 | 289 |
290 mutableState()->setFillGradient(gradient); | 290 mutableState()->setFillGradient(gradient); |
291 } | 291 } |
292 | 292 |
293 void GraphicsContext::setShadow(const FloatSize& offset, float blur, const Color
& color, | 293 void GraphicsContext::setShadow(const FloatSize& offset, float blur, const Color
& color, |
294 DrawLooper::ShadowTransformMode shadowTransformMode, | 294 DrawLooperBuilder::ShadowTransformMode shadowTransformMode, |
295 DrawLooper::ShadowAlphaMode shadowAlphaMode) | 295 DrawLooperBuilder::ShadowAlphaMode shadowAlphaMode) |
296 { | 296 { |
297 if (paintingDisabled()) | 297 if (paintingDisabled()) |
298 return; | 298 return; |
299 | 299 |
300 if (!color.alpha() || (!offset.width() && !offset.height() && !blur)) { | 300 if (!color.alpha() || (!offset.width() && !offset.height() && !blur)) { |
301 clearShadow(); | 301 clearShadow(); |
302 return; | 302 return; |
303 } | 303 } |
304 | 304 |
305 DrawLooper drawLooper; | 305 OwnPtr<DrawLooperBuilder> drawLooperBuilder = DrawLooperBuilder::create(); |
306 drawLooper.addShadow(offset, blur, color, shadowTransformMode, shadowAlphaMo
de); | 306 drawLooperBuilder->addShadow(offset, blur, color, shadowTransformMode, shado
wAlphaMode); |
307 drawLooper.addUnmodifiedContent(); | 307 drawLooperBuilder->addUnmodifiedContent(); |
308 setDrawLooper(drawLooper); | 308 setDrawLooper(drawLooperBuilder.release()); |
309 } | 309 } |
310 | 310 |
311 void GraphicsContext::setDrawLooper(const DrawLooper& drawLooper) | 311 void GraphicsContext::setDrawLooper(PassOwnPtr<DrawLooperBuilder> drawLooperBuil
der) |
312 { | 312 { |
313 if (paintingDisabled()) | 313 if (paintingDisabled()) |
314 return; | 314 return; |
315 | 315 |
316 mutableState()->setDrawLooper(drawLooper); | 316 mutableState()->setDrawLooper(drawLooperBuilder->detachDrawLooper()); |
317 } | 317 } |
318 | 318 |
319 void GraphicsContext::clearDrawLooper() | 319 void GraphicsContext::clearDrawLooper() |
320 { | 320 { |
321 if (paintingDisabled()) | 321 if (paintingDisabled()) |
322 return; | 322 return; |
323 | 323 |
324 mutableState()->clearDrawLooper(); | 324 mutableState()->clearDrawLooper(); |
325 } | 325 } |
326 | 326 |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 save(); | 703 save(); |
704 if (rect.isRounded()) { | 704 if (rect.isRounded()) { |
705 Path path; | 705 Path path; |
706 path.addRoundedRect(rect); | 706 path.addRoundedRect(rect); |
707 clipPath(path); | 707 clipPath(path); |
708 roundedHole.shrinkRadii(shadowSpread); | 708 roundedHole.shrinkRadii(shadowSpread); |
709 } else { | 709 } else { |
710 clip(rect.rect()); | 710 clip(rect.rect()); |
711 } | 711 } |
712 | 712 |
713 DrawLooper drawLooper; | 713 OwnPtr<DrawLooperBuilder> drawLooperBuilder = DrawLooperBuilder::create(); |
714 drawLooper.addShadow(shadowOffset, shadowBlur, shadowColor, | 714 drawLooperBuilder->addShadow(shadowOffset, shadowBlur, shadowColor, |
715 DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowIgnoresAlpha); | 715 DrawLooperBuilder::ShadowRespectsTransforms, DrawLooperBuilder::ShadowIg
noresAlpha); |
716 setDrawLooper(drawLooper); | 716 setDrawLooper(drawLooperBuilder.release()); |
717 fillRectWithRoundedHole(outerRect, roundedHole, fillColor); | 717 fillRectWithRoundedHole(outerRect, roundedHole, fillColor); |
718 restore(); | 718 restore(); |
719 clearDrawLooper(); | 719 clearDrawLooper(); |
720 } | 720 } |
721 | 721 |
722 void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2) | 722 void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2) |
723 { | 723 { |
724 if (paintingDisabled()) | 724 if (paintingDisabled()) |
725 return; | 725 return; |
726 | 726 |
(...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1906 | 1906 |
1907 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) | 1907 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) |
1908 { | 1908 { |
1909 if (m_trackTextRegion) { | 1909 if (m_trackTextRegion) { |
1910 TRACE_EVENT0("skia", "PlatformContextSkia::trackTextRegion"); | 1910 TRACE_EVENT0("skia", "PlatformContextSkia::trackTextRegion"); |
1911 m_textRegion.join(textRect); | 1911 m_textRegion.join(textRect); |
1912 } | 1912 } |
1913 } | 1913 } |
1914 | 1914 |
1915 } | 1915 } |
OLD | NEW |