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

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

Issue 661053003: Make beginLayer() and CanvasRenderingContext2D use SkXfermode::Mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase to ToT Created 5 years, 11 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
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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 paint->setLCDRenderText(couldUseLCDRenderedText()); 431 paint->setLCDRenderText(couldUseLCDRenderedText());
432 } 432 }
433 433
434 bool GraphicsContext::couldUseLCDRenderedText() const 434 bool GraphicsContext::couldUseLCDRenderedText() const
435 { 435 {
436 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) 436 if (RuntimeEnabledFeatures::slimmingPaintEnabled())
437 return true; 437 return true;
438 return m_isCertainlyOpaque && m_shouldSmoothFonts; 438 return m_isCertainlyOpaque && m_shouldSmoothFonts;
439 } 439 }
440 440
441 void GraphicsContext::setCompositeOperation(SkXfermode::Mode xferMode)
442 {
443 if (contextDisabled())
444 return;
445 mutableState()->setCompositeOperation(xferMode);
446 }
447
441 void GraphicsContext::setCompositeOperation(CompositeOperator compositeOperation , WebBlendMode blendMode) 448 void GraphicsContext::setCompositeOperation(CompositeOperator compositeOperation , WebBlendMode blendMode)
442 { 449 {
443 if (contextDisabled()) 450 SkXfermode::Mode xferMode = WebCoreCompositeToSkiaComposite(compositeOperati on, blendMode);
444 return; 451 setCompositeOperation(xferMode);
445 mutableState()->setCompositeOperation(compositeOperation, blendMode); 452 }
453
454 CompositeOperator GraphicsContext::compositeOperation() const
455 {
456 return compositeOperatorFromSkia(immutableState()->compositeOperation());
457 }
458
459 WebBlendMode GraphicsContext::blendModeOperation() const
460 {
461 return blendModeFromSkia(immutableState()->compositeOperation());
446 } 462 }
447 463
448 SkColorFilter* GraphicsContext::colorFilter() const 464 SkColorFilter* GraphicsContext::colorFilter() const
449 { 465 {
450 return immutableState()->colorFilter(); 466 return immutableState()->colorFilter();
451 } 467 }
452 468
453 void GraphicsContext::setColorFilter(ColorFilter colorFilter) 469 void GraphicsContext::setColorFilter(ColorFilter colorFilter)
454 { 470 {
455 GraphicsContextState* stateToSet = mutableState(); 471 GraphicsContextState* stateToSet = mutableState();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 if (matrix.isIdentity()) 503 if (matrix.isIdentity())
488 return; 504 return;
489 505
490 ASSERT(m_canvas); 506 ASSERT(m_canvas);
491 507
492 m_canvas->concat(matrix); 508 m_canvas->concat(matrix);
493 } 509 }
494 510
495 void GraphicsContext::beginTransparencyLayer(float opacity, const FloatRect* bou nds) 511 void GraphicsContext::beginTransparencyLayer(float opacity, const FloatRect* bou nds)
496 { 512 {
497 beginLayer(opacity, immutableState()->compositeOperator(), bounds); 513 beginLayer(opacity, immutableState()->compositeOperation(), bounds);
498 } 514 }
499 515
500 void GraphicsContext::beginLayer(float opacity, CompositeOperator op, const Floa tRect* bounds, ColorFilter colorFilter, ImageFilter* imageFilter) 516 void GraphicsContext::beginLayer(float opacity, SkXfermode::Mode xfermode, const FloatRect* bounds, ColorFilter colorFilter, ImageFilter* imageFilter)
501 { 517 {
502 if (contextDisabled()) 518 if (contextDisabled())
503 return; 519 return;
504 520
505 SkPaint layerPaint; 521 SkPaint layerPaint;
506 layerPaint.setAlpha(static_cast<unsigned char>(opacity * 255)); 522 layerPaint.setAlpha(static_cast<unsigned char>(opacity * 255));
507 layerPaint.setXfermodeMode(WebCoreCompositeToSkiaComposite(op, m_paintState- >blendMode())); 523 layerPaint.setXfermodeMode(xfermode);
508 layerPaint.setColorFilter(WebCoreColorFilterToSkiaColorFilter(colorFilter).g et()); 524 layerPaint.setColorFilter(WebCoreColorFilterToSkiaColorFilter(colorFilter).g et());
509 layerPaint.setImageFilter(imageFilter); 525 layerPaint.setImageFilter(imageFilter);
510 526
511 if (bounds) { 527 if (bounds) {
512 SkRect skBounds = WebCoreFloatRectToSKRect(*bounds); 528 SkRect skBounds = WebCoreFloatRectToSKRect(*bounds);
513 saveLayer(&skBounds, &layerPaint); 529 saveLayer(&skBounds, &layerPaint);
514 } else { 530 } else {
515 saveLayer(0, &layerPaint); 531 saveLayer(0, &layerPaint);
516 } 532 }
517 533
(...skipping 1484 matching lines...) Expand 10 before | Expand all | Expand 10 after
2002 // being returned from computeInterpolationQuality. 2018 // being returned from computeInterpolationQuality.
2003 resampling = InterpolationLow; 2019 resampling = InterpolationLow;
2004 } 2020 }
2005 resampling = limitInterpolationQuality(this, resampling); 2021 resampling = limitInterpolationQuality(this, resampling);
2006 paint->setFilterLevel(static_cast<SkPaint::FilterLevel>(resampling)); 2022 paint->setFilterLevel(static_cast<SkPaint::FilterLevel>(resampling));
2007 2023
2008 return initialSaveCount; 2024 return initialSaveCount;
2009 } 2025 }
2010 2026
2011 } // namespace blink 2027 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/graphics/GraphicsContext.h ('k') | Source/platform/graphics/GraphicsContextState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698