Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(858)

Side by Side Diff: Source/platform/graphics/GraphicsContext.cpp

Issue 658603002: 2D canvas: fix shadow rendering with compositing modes that require temp layers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rehash Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 if (!gradient) { 292 if (!gradient) {
293 setFillColor(Color::black); 293 setFillColor(Color::black);
294 return; 294 return;
295 } 295 }
296 296
297 mutableState()->setFillGradient(gradient); 297 mutableState()->setFillGradient(gradient);
298 } 298 }
299 299
300 void GraphicsContext::setShadow(const FloatSize& offset, float blur, const Color & color, 300 void GraphicsContext::setShadow(const FloatSize& offset, float blur, const Color & color,
301 DrawLooperBuilder::ShadowTransformMode shadowTransformMode, 301 DrawLooperBuilder::ShadowTransformMode shadowTransformMode,
302 DrawLooperBuilder::ShadowAlphaMode shadowAlphaMode) 302 DrawLooperBuilder::ShadowAlphaMode shadowAlphaMode, ShadowMode shadowMode)
303 { 303 {
304 if (contextDisabled()) 304 if (contextDisabled())
305 return; 305 return;
306 306
307 if (!color.alpha() || (!offset.width() && !offset.height() && !blur)) { 307 OwnPtr<DrawLooperBuilder> drawLooperBuilder = DrawLooperBuilder::create();
308 if (shadowMode == DrawForegroundOnly || (!color.alpha() || (!offset.width() && !offset.height() && !blur))) {
309 if (shadowMode == DrawShadowOnly) {
310 // shadow only, but there is no shadow: use an empty draw looper to silence rendering.
Stephen White 2014/10/14 21:02:12 Not sure I understand this comment. "silence rende
311 setDrawLooper(drawLooperBuilder.release());
312 return;
313 }
314 // Drawing foreground only, or drawing shadow and forground with no shad ow.
308 clearShadow(); 315 clearShadow();
309 return; 316 return;
310 } 317 }
311 318
312 OwnPtr<DrawLooperBuilder> drawLooperBuilder = DrawLooperBuilder::create();
313 drawLooperBuilder->addShadow(offset, blur, color, shadowTransformMode, shado wAlphaMode); 319 drawLooperBuilder->addShadow(offset, blur, color, shadowTransformMode, shado wAlphaMode);
314 drawLooperBuilder->addUnmodifiedContent(); 320 if (shadowMode == DrawShadowAndForeground) {
321 drawLooperBuilder->addUnmodifiedContent();
322 }
315 setDrawLooper(drawLooperBuilder.release()); 323 setDrawLooper(drawLooperBuilder.release());
316 } 324 }
317 325
326
jbroman 2014/10/14 21:09:48 nit: spurious newline
318 void GraphicsContext::setDrawLooper(PassOwnPtr<DrawLooperBuilder> drawLooperBuil der) 327 void GraphicsContext::setDrawLooper(PassOwnPtr<DrawLooperBuilder> drawLooperBuil der)
319 { 328 {
320 if (contextDisabled()) 329 if (contextDisabled())
321 return; 330 return;
322 331
323 mutableState()->setDrawLooper(drawLooperBuilder->detachDrawLooper()); 332 mutableState()->setDrawLooper(drawLooperBuilder->detachDrawLooper());
324 } 333 }
325 334
326 void GraphicsContext::clearDrawLooper() 335 void GraphicsContext::clearDrawLooper()
327 { 336 {
(...skipping 1685 matching lines...) Expand 10 before | Expand all | Expand 10 after
2013 // FIXME: This is to not break tests (it results in the filter bitmap fl ag 2022 // FIXME: This is to not break tests (it results in the filter bitmap fl ag
2014 // being set to true). We need to decide if we respect InterpolationNone 2023 // being set to true). We need to decide if we respect InterpolationNone
2015 // being returned from computeInterpolationQuality. 2024 // being returned from computeInterpolationQuality.
2016 resampling = InterpolationLow; 2025 resampling = InterpolationLow;
2017 } 2026 }
2018 resampling = limitInterpolationQuality(this, resampling); 2027 resampling = limitInterpolationQuality(this, resampling);
2019 paint->setFilterLevel(static_cast<SkPaint::FilterLevel>(resampling)); 2028 paint->setFilterLevel(static_cast<SkPaint::FilterLevel>(resampling));
2020 } 2029 }
2021 2030
2022 } // namespace blink 2031 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698