<commit_before>/*
 * Copyright 2012 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "gm.h"

#include "SkBitmapSource.h"
#include "SkBlurImageFilter.h"
#include "SkMorphologyImageFilter.h"

#include "SkTestImageFilters.h"

///////////////////////////////////////////////////////////////////////////////

class ImageFiltersGraphGM : public skiagm::GM {
public:
    ImageFiltersGraphGM() : fInitialized(false) {}

protected:

    virtual SkString onShortName() {
        return SkString("imagefiltersgraph");
    }

    void make_bitmap() {
        fBitmap.setConfig(SkBitmap::kARGB_8888_Config, 100, 100);
        fBitmap.allocPixels();
        SkDevice device(fBitmap);
        SkCanvas canvas(&device);
        canvas.clear(0x00000000);
        SkPaint paint;
        paint.setAntiAlias(true);
        paint.setColor(0xFFFFFFFF);
        paint.setTextSize(SkIntToScalar(96));
        const char* str = "e";
        canvas.drawText(str, strlen(str), SkIntToScalar(20), SkIntToScalar(70), paint);
    }

    virtual SkISize onISize() { return SkISize::Make(500, 500); }

    virtual void onDraw(SkCanvas* canvas) {
        if (!fInitialized) {
            this->make_bitmap();
            fInitialized = true;
        }
        canvas->clear(0x00000000);
        
        SkAutoTUnref<SkImageFilter> bitmapSource(new SkBitmapSource(fBitmap));

        SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(SK_ColorRED,
                                                     SkXfermode::kSrcIn_Mode));
        SkAutoTUnref<SkImageFilter> blur(new SkBlurImageFilter(4.0f, 4.0f, bitmapSource));
        SkAutoTUnref<SkImageFilter> erode(new SkErodeImageFilter(4, 4, blur));
        SkAutoTUnref<SkImageFilter> color(new SkColorFilterImageFilter(cf, erode));
        SkAutoTUnref<SkImageFilter> merge(new SkMergeImageFilter(blur, color));

        SkPaint paint;
        paint.setImageFilter(merge);
        canvas->drawPaint(paint);
    }

private:
    typedef GM INHERITED;
    SkBitmap fBitmap;
    bool fInitialized;
};

///////////////////////////////////////////////////////////////////////////////

static skiagm::GM* MyFactory(void*) { return new ImageFiltersGraphGM; }
static skiagm::GMRegistry reg(MyFactory);


<commit_msg>Disable imagefiltersgraph from running through pipe on android<commit_after>/*
 * Copyright 2012 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "gm.h"

#include "SkBitmapSource.h"
#include "SkBlurImageFilter.h"
#include "SkMorphologyImageFilter.h"

#include "SkTestImageFilters.h"

///////////////////////////////////////////////////////////////////////////////

class ImageFiltersGraphGM : public skiagm::GM {
public:
    ImageFiltersGraphGM() : fInitialized(false) {}

protected:
#ifdef SK_BUILD_FOR_ANDROID
    // This test is currently broken when using pipe on Android
    virtual uint32_t onGetFlags() const SK_OVERRIDE {
        return this->INHERITED::onGetFlags() | skiagm::GM::kSkipPipe_Flag;
    }
#endif

    virtual SkString onShortName() {
        return SkString("imagefiltersgraph");
    }

    void make_bitmap() {
        fBitmap.setConfig(SkBitmap::kARGB_8888_Config, 100, 100);
        fBitmap.allocPixels();
        SkDevice device(fBitmap);
        SkCanvas canvas(&device);
        canvas.clear(0x00000000);
        SkPaint paint;
        paint.setAntiAlias(true);
        paint.setColor(0xFFFFFFFF);
        paint.setTextSize(SkIntToScalar(96));
        const char* str = "e";
        canvas.drawText(str, strlen(str), SkIntToScalar(20), SkIntToScalar(70), paint);
    }

    virtual SkISize onISize() { return SkISize::Make(500, 500); }

    virtual void onDraw(SkCanvas* canvas) {
        if (!fInitialized) {
            this->make_bitmap();
            fInitialized = true;
        }
        canvas->clear(0x00000000);
        
        SkAutoTUnref<SkImageFilter> bitmapSource(new SkBitmapSource(fBitmap));

        SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(SK_ColorRED,
                                                     SkXfermode::kSrcIn_Mode));
        SkAutoTUnref<SkImageFilter> blur(new SkBlurImageFilter(4.0f, 4.0f, bitmapSource));
        SkAutoTUnref<SkImageFilter> erode(new SkErodeImageFilter(4, 4, blur));
        SkAutoTUnref<SkImageFilter> color(new SkColorFilterImageFilter(cf, erode));
        SkAutoTUnref<SkImageFilter> merge(new SkMergeImageFilter(blur, color));

        SkPaint paint;
        paint.setImageFilter(merge);
        canvas->drawPaint(paint);
    }

private:
    typedef GM INHERITED;
    SkBitmap fBitmap;
    bool fInitialized;
};

///////////////////////////////////////////////////////////////////////////////

static skiagm::GM* MyFactory(void*) { return new ImageFiltersGraphGM; }
static skiagm::GMRegistry reg(MyFactory);



{'fraction_non_alphanumeric': 0.16331505179768435, 'fraction_numerical': 0.021125330083282552, 'mean_word_length': 2.457865168539326, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 6, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '204903', 'n_tokens_mistral': 1509, 'n_tokens_neox': 1431, 'n_words': 294}