<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 "SkCanvas.h"
#include "SkImageDecoder.h"
#include "SkStream.h"

namespace skiagm {

/** Draw a CMYK encoded jpeg - libjpeg doesn't support CMYK->RGB
    conversion so this tests Skia's internal processing
*/
class CMYKJpegGM : public GM {
public:
    CMYKJpegGM() {

        // parameters to the "decode" call
        bool dither = false;
        SkBitmap::Config prefConfig = SkBitmap::kARGB_8888_Config;

        SkString filename(INHERITED::gResourcePath);
        if (!filename.endsWith("/") && !filename.endsWith("\\")) {
            filename.append("/");
        }

        filename.append("CMYK.jpg");

        SkFILEStream stream(filename.c_str());
        SkImageDecoder* codec = SkImageDecoder::Factory(&stream);
        if (codec) {
            stream.rewind();
            codec->setDitherImage(dither);
            codec->decode(&stream, &fBitmap, prefConfig,
                          SkImageDecoder::kDecodePixels_Mode);
        }
    }

protected:
    virtual SkString onShortName() {
        return SkString("cmykjpeg");
    }

    virtual SkISize onISize() {
        return make_isize(640, 480);
    }

    virtual void onDraw(SkCanvas* canvas) {

        canvas->translate(20*SK_Scalar1, 20*SK_Scalar1);
        canvas->drawBitmap(fBitmap, 0, 0);
    }

private:
    SkBitmap fBitmap;

    typedef GM INHERITED;
};

void forceLinking();
<commit_msg>Fix a memory leak in cmykjpeg GM.<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 "SkCanvas.h"
#include "SkImageDecoder.h"
#include "SkStream.h"

namespace skiagm {

/** Draw a CMYK encoded jpeg - libjpeg doesn't support CMYK->RGB
    conversion so this tests Skia's internal processing
*/
class CMYKJpegGM : public GM {
public:
    CMYKJpegGM() {

        // parameters to the "decode" call
        bool dither = false;
        SkBitmap::Config prefConfig = SkBitmap::kARGB_8888_Config;

        SkString filename(INHERITED::gResourcePath);
        if (!filename.endsWith("/") && !filename.endsWith("\\")) {
            filename.append("/");
        }

        filename.append("CMYK.jpg");

        SkFILEStream stream(filename.c_str());
        SkImageDecoder* codec = SkImageDecoder::Factory(&stream);
        if (codec) {
            stream.rewind();
            codec->setDitherImage(dither);
            codec->decode(&stream, &fBitmap, prefConfig,
                          SkImageDecoder::kDecodePixels_Mode);
            SkDELETE(codec);
        }
    }

protected:
    virtual SkString onShortName() {
        return SkString("cmykjpeg");
    }

    virtual SkISize onISize() {
        return make_isize(640, 480);
    }

    virtual void onDraw(SkCanvas* canvas) {

        canvas->translate(20*SK_Scalar1, 20*SK_Scalar1);
        canvas->drawBitmap(fBitmap, 0, 0);
    }

private:
    SkBitmap fBitmap;

    typedef GM INHERITED;
};

void forceLinking();

{'fraction_non_alphanumeric': 0.11854199683042789, 'fraction_numerical': 0.013946117274167988, 'mean_word_length': 2.5661016949152544, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '864850', 'n_tokens_mistral': 1022, 'n_tokens_neox': 954, 'n_words': 239}