| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 m_percentage(percentage), | 41 m_percentage(percentage), |
| 42 m_crossfadeSize(crossfadeSize) {} | 42 m_crossfadeSize(crossfadeSize) {} |
| 43 | 43 |
| 44 void CrossfadeGeneratedImage::drawCrossfade(SkCanvas* canvas, | 44 void CrossfadeGeneratedImage::drawCrossfade(SkCanvas* canvas, |
| 45 const SkPaint& paint, | 45 const SkPaint& paint, |
| 46 ImageClampingMode clampMode) { | 46 ImageClampingMode clampMode) { |
| 47 FloatRect fromImageRect(FloatPoint(), FloatSize(m_fromImage->size())); | 47 FloatRect fromImageRect(FloatPoint(), FloatSize(m_fromImage->size())); |
| 48 FloatRect toImageRect(FloatPoint(), FloatSize(m_toImage->size())); | 48 FloatRect toImageRect(FloatPoint(), FloatSize(m_toImage->size())); |
| 49 FloatRect destRect((FloatPoint()), FloatSize(m_crossfadeSize)); | 49 FloatRect destRect((FloatPoint()), FloatSize(m_crossfadeSize)); |
| 50 | 50 |
| 51 // TODO(junov): The various effects encoded into paint should probably be appl
ied here | 51 // TODO(junov): The various effects encoded into paint should probably be |
| 52 // instead of inside the layer. This probably faulty behavior was maintained
in order | 52 // applied here instead of inside the layer. This probably faulty behavior |
| 53 // to preserve pre-existing behavior while refactoring this code. This should
be | 53 // was maintained in order to preserve pre-existing behavior while refactoring |
| 54 // investigated further. crbug.com/472634 | 54 // this code. This should be investigated further. crbug.com/472634 |
| 55 SkPaint layerPaint; | 55 SkPaint layerPaint; |
| 56 layerPaint.setXfermode(sk_ref_sp(paint.getXfermode())); | 56 layerPaint.setXfermode(sk_ref_sp(paint.getXfermode())); |
| 57 SkAutoCanvasRestore ar(canvas, false); | 57 SkAutoCanvasRestore ar(canvas, false); |
| 58 canvas->saveLayer(nullptr, &layerPaint); | 58 canvas->saveLayer(nullptr, &layerPaint); |
| 59 | 59 |
| 60 SkPaint imagePaint(paint); | 60 SkPaint imagePaint(paint); |
| 61 imagePaint.setXfermodeMode(SkXfermode::kSrcOver_Mode); | 61 imagePaint.setXfermodeMode(SkXfermode::kSrcOver_Mode); |
| 62 int imageAlpha = clampedAlphaForBlending(1 - m_percentage); | 62 int imageAlpha = clampedAlphaForBlending(1 - m_percentage); |
| 63 imagePaint.setAlpha(imageAlpha > 255 ? 255 : imageAlpha); | 63 imagePaint.setAlpha(imageAlpha > 255 ? 255 : imageAlpha); |
| 64 imagePaint.setAntiAlias(paint.isAntiAlias()); | 64 imagePaint.setAntiAlias(paint.isAntiAlias()); |
| 65 // TODO(junov): This code should probably be propagating the RespectImageOrien
tationEnum | 65 // TODO(junov): This code should probably be propagating the |
| 66 // form CrossfadeGeneratedImage::draw. Code was written this way during refact
oring to | 66 // RespectImageOrientationEnum from CrossfadeGeneratedImage::draw(). Code was |
| 67 // avoid modifying existing behavior, but this warrants further investigation.
crbug.com/472634 | 67 // written this way during refactoring to avoid modifying existing behavior, |
| 68 // but this warrants further investigation. crbug.com/472634 |
| 68 m_fromImage->draw(canvas, imagePaint, destRect, fromImageRect, | 69 m_fromImage->draw(canvas, imagePaint, destRect, fromImageRect, |
| 69 DoNotRespectImageOrientation, clampMode); | 70 DoNotRespectImageOrientation, clampMode); |
| 70 imagePaint.setXfermodeMode(SkXfermode::kPlus_Mode); | 71 imagePaint.setXfermodeMode(SkXfermode::kPlus_Mode); |
| 71 imageAlpha = clampedAlphaForBlending(m_percentage); | 72 imageAlpha = clampedAlphaForBlending(m_percentage); |
| 72 imagePaint.setAlpha(imageAlpha > 255 ? 255 : imageAlpha); | 73 imagePaint.setAlpha(imageAlpha > 255 ? 255 : imageAlpha); |
| 73 m_toImage->draw(canvas, imagePaint, destRect, toImageRect, | 74 m_toImage->draw(canvas, imagePaint, destRect, toImageRect, |
| 74 DoNotRespectImageOrientation, clampMode); | 75 DoNotRespectImageOrientation, clampMode); |
| 75 } | 76 } |
| 76 | 77 |
| 77 void CrossfadeGeneratedImage::draw(SkCanvas* canvas, | 78 void CrossfadeGeneratedImage::draw(SkCanvas* canvas, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 103 | 104 |
| 104 SkPaint paint = context.fillPaint(); | 105 SkPaint paint = context.fillPaint(); |
| 105 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); | 106 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); |
| 106 paint.setAntiAlias(context.shouldAntialias()); | 107 paint.setAntiAlias(context.shouldAntialias()); |
| 107 FloatRect destRect((FloatPoint()), FloatSize(m_crossfadeSize)); | 108 FloatRect destRect((FloatPoint()), FloatSize(m_crossfadeSize)); |
| 108 paint.setFilterQuality(context.computeFilterQuality(this, destRect, srcRect)); | 109 paint.setFilterQuality(context.computeFilterQuality(this, destRect, srcRect)); |
| 109 drawCrossfade(context.canvas(), paint, ClampImageToSourceRect); | 110 drawCrossfade(context.canvas(), paint, ClampImageToSourceRect); |
| 110 } | 111 } |
| 111 | 112 |
| 112 } // namespace blink | 113 } // namespace blink |
| OLD | NEW |