Home | History | Annotate | Download | only in effects
      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"
      9 #include "SkPM4f.h"
     10 #include "SkColorData.h"
     11 #include "SkRasterPipeline.h"
     12 #include "SkString.h"
     13 
     14 #if SK_SUPPORT_GPU
     15 #include "GrContext.h"
     16 #include "effects/GrLumaColorFilterEffect.h"
     17 #include "glsl/GrGLSLFragmentProcessor.h"
     18 #include "glsl/GrGLSLFragmentShaderBuilder.h"
     19 #endif
     20 
     21 void SkLumaColorFilter::onAppendStages(SkRasterPipeline* p,
     22                                        SkColorSpace* dst,
     23                                        SkArenaAlloc* scratch,
     24                                        bool shaderIsOpaque) const {
     25     p->append(SkRasterPipeline::luminance_to_alpha);
     26 }
     27 
     28 sk_sp<SkColorFilter> SkLumaColorFilter::Make() {
     29     return sk_sp<SkColorFilter>(new SkLumaColorFilter);
     30 }
     31 
     32 SkLumaColorFilter::SkLumaColorFilter() : INHERITED() {}
     33 
     34 sk_sp<SkFlattenable> SkLumaColorFilter::CreateProc(SkReadBuffer&) {
     35     return Make();
     36 }
     37 
     38 void SkLumaColorFilter::flatten(SkWriteBuffer&) const {}
     39 
     40 #ifndef SK_IGNORE_TO_STRING
     41 void SkLumaColorFilter::toString(SkString* str) const {
     42     str->append("SkLumaColorFilter ");
     43 }
     44 #endif
     45 
     46 #if SK_SUPPORT_GPU
     47 std::unique_ptr<GrFragmentProcessor> SkLumaColorFilter::asFragmentProcessor(
     48         GrContext*, const GrColorSpaceInfo&) const {
     49     return GrLumaColorFilterEffect::Make();
     50 }
     51 #endif
     52