<commit_before>/*
   Copyright (c) 2003 <NAME>, All rights reserved.

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.
*/

#include <gfx/convert.h>
#include "unichrome.h"
#include "uc_state.h"
#include "uc_accel.h"
#include "uc_hw.h"

enum uc_state_type {
    UC_TYPE_UNSUPPORTED,
    UC_TYPE_2D,
    UC_TYPE_3D
};

/// GPU selecting functions --------------------------------------------------

inline bool uc_is_destination_supported(DFBSurfacePixelFormat format)
{
    switch (format)
    {
        //case DSPF_RGB15:
    case DSPF_RGB16:
    case DSPF_RGB32:
    case DSPF_LUT8:
    case DSPF_ARGB:
    case DSPF_ARGB1555:
        return true;
    default:
        return false;
    }
}

inline enum uc_state_type uc_select_drawtype(CardState* state,
                                             DFBAccelerationMask accel)
{
    if (!(state->drawingflags & ~UC_DRAWING_FLAGS_2D) &&
        !(accel & DFXL_FILLTRIANGLE)) return UC_TYPE_2D;

    if (!(state->drawingflags & ~UC_DRAWING_FLAGS_3D)) return UC_TYPE_3D;

    return UC_TYPE_UNSUPPORTED;
}

inline enum uc_state_type uc_select_blittype(CardState* state,
                                             DFBAccelerationMask accel)
{
    if (!(state->blittingflags & ~UC_BLITTING_FLAGS_2D))
    {
        if ((state->source->format == state->destination->format) &&
            !((state->blittingflags & DSBLIT_SRC_COLORKEY) &&
            (state->blittingflags & DSBLIT_DST_COLORKEY)) &&
            !(accel & DFXL_STRETCHBLIT)) return UC_TYPE_2D;
    }

// 3d blitting is broken
/*
    if (!(state->blittingflags & ~UC_BLITTING_FLAGS_3D)) {
        if (uc_map_src_format_3d(state->source->format) >= 0) 
            return UC_TYPE_3D;
    }
*/
    return UC_TYPE_UNSUPPORTED;
}

// DirectFB interfacing functions --------------------------------------------

void uc_check_state(void *drv, void *dev,
                    CardState *state, DFBAccelerationMask accel)<commit_msg>Fixed LUT8 blit bug. The driver erroneously tried to do a LUT8->LUT8 stretch blit, which isn't supported.<commit_after>/*
   Copyright (c) 2003 <NAME>, All rights reserved.

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.
*/

#include <gfx/convert.h>
#include "unichrome.h"
#include "uc_state.h"
#include "uc_accel.h"
#include "uc_hw.h"

enum uc_state_type {
    UC_TYPE_UNSUPPORTED,
    UC_TYPE_2D,
    UC_TYPE_3D
};

/// GPU selecting functions --------------------------------------------------

inline bool uc_is_destination_supported(DFBSurfacePixelFormat format)
{
    switch (format)
    {
        //case DSPF_RGB15:
    case DSPF_RGB16:
    case DSPF_RGB32:
    case DSPF_LUT8:
    case DSPF_ARGB:
    case DSPF_ARGB1555:
        return true;
    default:
        return false;
    }
}

inline enum uc_state_type uc_select_drawtype(CardState* state,
                                             DFBAccelerationMask accel)
{
    if (!(state->drawingflags & ~UC_DRAWING_FLAGS_2D) &&
        !(accel & DFXL_FILLTRIANGLE)) return UC_TYPE_2D;

    if (!(state->drawingflags & ~UC_DRAWING_FLAGS_3D)) return UC_TYPE_3D;

    return UC_TYPE_UNSUPPORTED;
}

inline enum uc_state_type uc_select_blittype(CardState* state,
                                             DFBAccelerationMask accel)
{
    __u32 tmp;

    if (!(state->blittingflags & ~UC_BLITTING_FLAGS_2D))
    {
        if ((state->source->format == state->destination->format) &&
            !((state->blittingflags & DSBLIT_SRC_COLORKEY) &&
            (state->blittingflags & DSBLIT_DST_COLORKEY)) &&
            !(accel & DFXL_STRETCHBLIT)) return UC_TYPE_2D;
    }

// 3d blitting is broken
/*
    if (!(state->blittingflags & ~UC_BLITTING_FLAGS_3D)) {
        if ((uc_map_src_format_3d(state->source->format) >= 0) &&
            (uc_map_dst_format(state->destination->format, &tmp, &tmp) >= 0))
            return UC_TYPE_3D;
    }
*/
    return UC_TYPE_UNSUPPORTED;
}

// DirectFB interfacing functions --------------------------------------------

void uc_check_state(void *drv, void *dev,
                    CardState *state, DFBAccelerationMask accel)
{'fraction_non_alphanumeric': 0.134568176746262, 'fraction_numerical': 0.014282526221825485, 'mean_word_length': 2.3800904977375565, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4525898', 'n_tokens_mistral': 1521, 'n_tokens_neox': 1430, 'n_words': 339}