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

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: fix rebase 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 OwnPtr<DrawLooperBuilder> drawLooperBuilder = DrawLooperBuilder::create();
307 if (!color.alpha() || (!offset.width() && !offset.height() && !blur)) { 308 if (!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/15 17:15:30 Nit: suggest "silence rendering" -> "disable rende
311 setDrawLooper(drawLooperBuilder.release());
312 return;
313 }
308 clearShadow(); 314 clearShadow();
309 return; 315 return;
310 } 316 }
311 317
312 OwnPtr<DrawLooperBuilder> drawLooperBuilder = DrawLooperBuilder::create();
313 drawLooperBuilder->addShadow(offset, blur, color, shadowTransformMode, shado wAlphaMode); 318 drawLooperBuilder->addShadow(offset, blur, color, shadowTransformMode, shado wAlphaMode);
314 drawLooperBuilder->addUnmodifiedContent(); 319 if (shadowMode == DrawShadowAndForeground) {
320 drawLooperBuilder->addUnmodifiedContent();
321 }
315 setDrawLooper(drawLooperBuilder.release()); 322 setDrawLooper(drawLooperBuilder.release());
316 } 323 }
317 324
318 void GraphicsContext::setDrawLooper(PassOwnPtr<DrawLooperBuilder> drawLooperBuil der) 325 void GraphicsContext::setDrawLooper(PassOwnPtr<DrawLooperBuilder> drawLooperBuil der)
319 { 326 {
320 if (contextDisabled()) 327 if (contextDisabled())
321 return; 328 return;
322 329
323 mutableState()->setDrawLooper(drawLooperBuilder->detachDrawLooper()); 330 mutableState()->setDrawLooper(drawLooperBuilder->detachDrawLooper());
324 } 331 }
(...skipping 1688 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 2020 // 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 2021 // being set to true). We need to decide if we respect InterpolationNone
2015 // being returned from computeInterpolationQuality. 2022 // being returned from computeInterpolationQuality.
2016 resampling = InterpolationLow; 2023 resampling = InterpolationLow;
2017 } 2024 }
2018 resampling = limitInterpolationQuality(this, resampling); 2025 resampling = limitInterpolationQuality(this, resampling);
2019 paint->setFilterLevel(static_cast<SkPaint::FilterLevel>(resampling)); 2026 paint->setFilterLevel(static_cast<SkPaint::FilterLevel>(resampling));
2020 } 2027 }
2021 2028
2022 } // namespace blink 2029 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698