/*
 * Copyright (C) 2020-2021 Aloysius Indrayanto
 *
 * This file is part of the eCxx library, see LICENSE file for the license details.
 */


#ifndef ECXX_CTL_GFX_COLOR_BUFFER_POLICY_H
#define ECXX_CTL_GFX_COLOR_BUFFER_POLICY_H


#include "ColorInterpolator.h"


namespace eCxx {


//
// Integer data types used by color buffer
//
namespace CBP {

    using SSInt =   int8_t;
    using SUInt =  uint8_t;

    using DSInt =  int16_t;
    using DUInt = uint16_t;

    using QSInt =  int32_t;
    using QUInt = uint32_t;

} // namespace CBP


//
// Color buffer layout element size exchanger
//
namespace internal {

    template <CBP::SUInt XSizeN, CBP::SUInt YSizeN>
    struct CBEZNormal : public Uninstantiable {
        static constexpr CBP::SUInt XSize = XSizeN;
        static constexpr CBP::SUInt YSize = YSizeN;
    };

    template <CBP::SUInt XSizeN, CBP::SUInt YSizeN>
    struct CBEZSwap : public Uninstantiable {
        static constexpr CBP::SUInt XSize = YSizeN;
        static constexpr CBP::SUInt YSize = XSizeN;
    };

} // namespace internal

// The default is not to swap the XSize and YSize
template <CBP::SUInt XSizeN, CBP::SUInt YSizeN, typename LayoutPolicyT>
struct ColorBufferLayoutElementSizeExchanger : internal::CBEZNormal<XSizeN, YSizeN> {};


//
// Declaration of color buffer layout policy structure
//
template <CBP::SUInt XSizeN, CBP::SUInt YSizeN, CBP::SUInt BlockXSizeN, CBP::SUInt BlockYSizeN, CBP::SUInt InterYSizeN, typename LayoutPolicyT>
struct ColorBufferLayoutPolicy;


} // namespace eCxx


//
// Include the remaining color buffer policy header files
//
#include "ColorBufferStoragePolicy.h"

#include "ColorBufferLayoutPolicyPlainStd.h"
#include "ColorBufferLayoutPolicyPlainAlt.h"

#include "ColorBufferLayoutPolicyBlockRowMajor.h"
#include "ColorBufferLayoutPolicyInterRowMajor.h"

#include "ColorBufferLayoutPolicyBlockRowMajorInterRowMajor.h"


//
// Define the default color buffer layout policy
//
namespace eCxx {

namespace CBP {

    struct UndefinedLayout;

    using DefaultLayout = StandardLayout;

} // namespace CBP

} // namespace eCxx


#endif
