| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkBlitter.h" | 8 #include "SkBlitter.h" |
| 9 #include "SkAntiRun.h" | 9 #include "SkAntiRun.h" |
| 10 #include "SkColor.h" | 10 #include "SkColor.h" |
| (...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 } | 837 } |
| 838 | 838 |
| 839 /* | 839 /* |
| 840 * If the xfermode is CLEAR, then we can completely ignore the installed | 840 * If the xfermode is CLEAR, then we can completely ignore the installed |
| 841 * color/shader/colorfilter, and just pretend we're SRC + color==0. This | 841 * color/shader/colorfilter, and just pretend we're SRC + color==0. This |
| 842 * will fall into our optimizations for SRC mode. | 842 * will fall into our optimizations for SRC mode. |
| 843 */ | 843 */ |
| 844 if (SkXfermode::IsMode(mode, SkXfermode::kClear_Mode)) { | 844 if (SkXfermode::IsMode(mode, SkXfermode::kClear_Mode)) { |
| 845 SkPaint* p = paint.writable(); | 845 SkPaint* p = paint.writable(); |
| 846 shader = p->setShader(nullptr); | 846 shader = p->setShader(nullptr); |
| 847 p->setColorFilter(nullptr); | 847 cf = p->setColorFilter(nullptr); |
| 848 cf = nullptr; | |
| 849 mode = p->setXfermodeMode(SkXfermode::kSrc_Mode); | 848 mode = p->setXfermodeMode(SkXfermode::kSrc_Mode); |
| 850 p->setColor(0); | 849 p->setColor(0); |
| 851 } | 850 } |
| 852 | 851 |
| 853 if (nullptr == shader) { | 852 if (nullptr == shader) { |
| 854 if (mode) { | 853 if (mode) { |
| 855 // xfermodes (and filters) require shaders for our current blitters | 854 // xfermodes (and filters) require shaders for our current blitters |
| 856 shader = new SkColorShader(paint->getColor()); | 855 shader = new SkColorShader(paint->getColor()); |
| 857 paint.writable()->setShader(shader)->unref(); | 856 paint.writable()->setShader(shader)->unref(); |
| 858 paint.writable()->setAlpha(0xFF); | 857 paint.writable()->setAlpha(0xFF); |
| 859 } else if (cf) { | 858 } else if (cf) { |
| 860 // if no shader && no xfermode, we just apply the colorfilter to | 859 // if no shader && no xfermode, we just apply the colorfilter to |
| 861 // our color and move on. | 860 // our color and move on. |
| 862 SkPaint* writablePaint = paint.writable(); | 861 SkPaint* writablePaint = paint.writable(); |
| 863 writablePaint->setColor(cf->filterColor(paint->getColor())); | 862 writablePaint->setColor(cf->filterColor(paint->getColor())); |
| 864 writablePaint->setColorFilter(nullptr); | 863 writablePaint->setColorFilter(nullptr); |
| 865 cf = nullptr; | 864 cf = nullptr; |
| 866 } | 865 } |
| 867 } | 866 } |
| 868 | 867 |
| 869 if (cf) { | 868 if (cf) { |
| 870 SkASSERT(shader); | 869 SkASSERT(shader); |
| 871 paint.writable()->setShader(shader->makeWithColorFilter(sk_ref_sp(cf))); | 870 paint.writable()->setShader(shader->makeWithColorFilter(cf)); |
| 872 shader = paint->getShader(); | 871 shader = paint->getShader(); |
| 873 // blitters should ignore the presence/absence of a filter, since | 872 // blitters should ignore the presence/absence of a filter, since |
| 874 // if there is one, the shader will take care of it. | 873 // if there is one, the shader will take care of it. |
| 875 } | 874 } |
| 876 | 875 |
| 877 /* | 876 /* |
| 878 * We create a SkShader::Context object, and store it on the blitter. | 877 * We create a SkShader::Context object, and store it on the blitter. |
| 879 */ | 878 */ |
| 880 SkShader::Context* shaderContext = nullptr; | 879 SkShader::Context* shaderContext = nullptr; |
| 881 if (shader) { | 880 if (shader) { |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1003 fShaderContext->~Context(); | 1002 fShaderContext->~Context(); |
| 1004 SkShader::Context* ctx = fShader->createContext(rec, (void*)fShaderContext); | 1003 SkShader::Context* ctx = fShader->createContext(rec, (void*)fShaderContext); |
| 1005 if (nullptr == ctx) { | 1004 if (nullptr == ctx) { |
| 1006 // Need a valid context in fShaderContext's storage, so we can later (or
our caller) call | 1005 // Need a valid context in fShaderContext's storage, so we can later (or
our caller) call |
| 1007 // the in-place destructor. | 1006 // the in-place destructor. |
| 1008 new (fShaderContext) SkZeroShaderContext(*fShader, rec); | 1007 new (fShaderContext) SkZeroShaderContext(*fShader, rec); |
| 1009 return false; | 1008 return false; |
| 1010 } | 1009 } |
| 1011 return true; | 1010 return true; |
| 1012 } | 1011 } |
| OLD | NEW |