| /* |
| * Copyright 2013 Google Inc. |
| * |
| * Use of this source code is governed by a BSD-style license that can be |
| * found in the LICENSE file. |
| */ |
| |
| #include "SkLumaColorFilter.h" |
| #include "SkPM4f.h" |
| #include "SkColorData.h" |
| #include "SkRasterPipeline.h" |
| #include "SkString.h" |
| |
| #if SK_SUPPORT_GPU |
| #include "GrContext.h" |
| #include "effects/GrLumaColorFilterEffect.h" |
| #include "glsl/GrGLSLFragmentProcessor.h" |
| #include "glsl/GrGLSLFragmentShaderBuilder.h" |
| #endif |
| |
| void SkLumaColorFilter::onAppendStages(SkRasterPipeline* p, |
| SkColorSpace* dst, |
| SkArenaAlloc* scratch, |
| bool shaderIsOpaque) const { |
| p->append(SkRasterPipeline::luminance_to_alpha); |
| } |
| |
| sk_sp<SkColorFilter> SkLumaColorFilter::Make() { |
| return sk_sp<SkColorFilter>(new SkLumaColorFilter); |
| } |
| |
| SkLumaColorFilter::SkLumaColorFilter() : INHERITED() {} |
| |
| sk_sp<SkFlattenable> SkLumaColorFilter::CreateProc(SkReadBuffer&) { |
| return Make(); |
| } |
| |
| void SkLumaColorFilter::flatten(SkWriteBuffer&) const {} |
| |
| #ifndef SK_IGNORE_TO_STRING |
| void SkLumaColorFilter::toString(SkString* str) const { |
| str->append("SkLumaColorFilter "); |
| } |
| #endif |
| |
| #if SK_SUPPORT_GPU |
| std::unique_ptr<GrFragmentProcessor> SkLumaColorFilter::asFragmentProcessor( |
| GrContext*, const GrColorSpaceInfo&) const { |
| return GrLumaColorFilterEffect::Make(); |
| } |
| #endif |