commit-bot@chromium.org | 6c1ee2d | 2013-10-07 18:00:17 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "SkLumaColorFilter.h" |
Mike Reed | b9641bd | 2017-05-04 10:57:40 -0400 | [diff] [blame] | 9 | #include "SkPM4f.h" |
Cary Clark | a4083c9 | 2017-09-15 11:59:23 -0400 | [diff] [blame] | 10 | #include "SkColorData.h" |
Mike Klein | 1f49f26 | 2016-10-31 19:49:27 -0400 | [diff] [blame] | 11 | #include "SkRasterPipeline.h" |
commit-bot@chromium.org | 6c1ee2d | 2013-10-07 18:00:17 +0000 | [diff] [blame] | 12 | #include "SkString.h" |
commit-bot@chromium.org | 6c1ee2d | 2013-10-07 18:00:17 +0000 | [diff] [blame] | 13 | |
| 14 | #if SK_SUPPORT_GPU |
commit-bot@chromium.org | 6c1ee2d | 2013-10-07 18:00:17 +0000 | [diff] [blame] | 15 | #include "GrContext.h" |
Ethan Nicholas | 14efcbf | 2017-11-07 09:23:38 -0500 | [diff] [blame] | 16 | #include "effects/GrLumaColorFilterEffect.h" |
egdaniel | 64c4728 | 2015-11-13 06:54:19 -0800 | [diff] [blame] | 17 | #include "glsl/GrGLSLFragmentProcessor.h" |
egdaniel | 2d721d3 | 2015-11-11 13:06:05 -0800 | [diff] [blame] | 18 | #include "glsl/GrGLSLFragmentShaderBuilder.h" |
commit-bot@chromium.org | 6c1ee2d | 2013-10-07 18:00:17 +0000 | [diff] [blame] | 19 | #endif |
| 20 | |
Mike Klein | fdf3103 | 2017-05-09 14:57:58 -0400 | [diff] [blame] | 21 | void SkLumaColorFilter::onAppendStages(SkRasterPipeline* p, |
Mike Klein | 744908e | 2016-11-11 12:51:36 -0500 | [diff] [blame] | 22 | SkColorSpace* dst, |
Herb Derby | ac04fef | 2017-01-13 17:34:33 -0500 | [diff] [blame] | 23 | SkArenaAlloc* scratch, |
Mike Klein | 744908e | 2016-11-11 12:51:36 -0500 | [diff] [blame] | 24 | bool shaderIsOpaque) const { |
Mike Klein | 1f49f26 | 2016-10-31 19:49:27 -0400 | [diff] [blame] | 25 | p->append(SkRasterPipeline::luminance_to_alpha); |
Mike Klein | 1f49f26 | 2016-10-31 19:49:27 -0400 | [diff] [blame] | 26 | } |
| 27 | |
reed | d053ce9 | 2016-03-22 10:17:23 -0700 | [diff] [blame] | 28 | sk_sp<SkColorFilter> SkLumaColorFilter::Make() { |
| 29 | return sk_sp<SkColorFilter>(new SkLumaColorFilter); |
| 30 | } |
commit-bot@chromium.org | 6c1ee2d | 2013-10-07 18:00:17 +0000 | [diff] [blame] | 31 | |
reed | 9fa60da | 2014-08-21 07:59:51 -0700 | [diff] [blame] | 32 | SkLumaColorFilter::SkLumaColorFilter() : INHERITED() {} |
| 33 | |
reed | 60c9b58 | 2016-04-03 09:11:13 -0700 | [diff] [blame] | 34 | sk_sp<SkFlattenable> SkLumaColorFilter::CreateProc(SkReadBuffer&) { |
| 35 | return Make(); |
| 36 | } |
commit-bot@chromium.org | 6c1ee2d | 2013-10-07 18:00:17 +0000 | [diff] [blame] | 37 | |
reed | 9fa60da | 2014-08-21 07:59:51 -0700 | [diff] [blame] | 38 | void SkLumaColorFilter::flatten(SkWriteBuffer&) const {} |
commit-bot@chromium.org | 6c1ee2d | 2013-10-07 18:00:17 +0000 | [diff] [blame] | 39 | |
commit-bot@chromium.org | 0f10f7b | 2014-03-13 18:02:17 +0000 | [diff] [blame] | 40 | #ifndef SK_IGNORE_TO_STRING |
commit-bot@chromium.org | 6c1ee2d | 2013-10-07 18:00:17 +0000 | [diff] [blame] | 41 | void SkLumaColorFilter::toString(SkString* str) const { |
| 42 | str->append("SkLumaColorFilter "); |
| 43 | } |
| 44 | #endif |
| 45 | |
| 46 | #if SK_SUPPORT_GPU |
Brian Salomon | 4cbb6e6 | 2017-10-25 15:12:19 -0400 | [diff] [blame] | 47 | std::unique_ptr<GrFragmentProcessor> SkLumaColorFilter::asFragmentProcessor( |
| 48 | GrContext*, const GrColorSpaceInfo&) const { |
Ethan Nicholas | 14efcbf | 2017-11-07 09:23:38 -0500 | [diff] [blame] | 49 | return GrLumaColorFilterEffect::Make(); |
commit-bot@chromium.org | 6c1ee2d | 2013-10-07 18:00:17 +0000 | [diff] [blame] | 50 | } |
| 51 | #endif |