//
//  SDLTexture.h
//  Meteor
//
//  Created by Cesar Parent on 14/07/2015.
//  Copyright (c) 2015 Cesar Parent. All rights reserved.
//

#ifndef __Meteor__SDLTexture__
#define __Meteor__SDLTexture__

#include "../CPFoundation.h"
#include "../sdl_includes.h"
#include "TextureProtocol.h"

NS_BEGIN

class SDLTextureRef;

class SDLTexture : public CPObject, public TextureProtocol {
    
    friend class SDLRenderer;
    
public:
    
    ~SDLTexture();
    
    // MARK: -
    // MARK: Getters
    
    /*!
     * @brief       <code>Texture</code>s cannot be created by calling the constructor. Instead,
     *              they can be requested to the renderer, which will cache them appropriately.
     */
    SDLTexture(ARC<SDLTextureRef> hwTexture);
    
    /*!
     * @brief       Returns the texture's opacity.
     * @return      <code>this</code>'s opacity, between <code>0.0</code> and <code>1.0</code>.
     */
    virtual float
    alpha() const { return _alpha; }
    
    /*!
     * @brief       Returns the texture's color blending mode.
     * @return      <code>this</code>'s blending mode.
     */
    virtual BlendMode
    blendMode() const { return _blendMode; }
    
    /*!
     * @brief       Returns the texture's color.
     * @return      <code>this</code>'s color.
     */
    virtual Color
    color() const { return _color; }
    
    /*!
     * @brief       Returns the portion of <code>this</code> that will be drawn.
     * @return      <code>this</code>'s clipping quad.
     */
    virtual Rect
    clippingQuad() const { return _clippingQuad; }
    
    /*!
     * @brief       Returns the size of <code>this</code> in pixels.
     * @return      <code>size2</code> containing <code>this</code>'s dimensions.
     */
    virtual size2
    size() const { return _size; }
    
    // MARK: -
    // MARK: Setters
    
    /*!
     * @brief       Set <code>this</code>'s opacity.
     * @param       opacity     New opacity.
     */
    virtual void
    setAlpha(float alpha) { _alpha = alpha; }
    
    /*!
     * @brief       Set <code>this</code>'s blending mode.
     * @param       opacity     New blending mode.
     */
    virtual void
    setBlendMode(BlendMode blendMode) { _blendMode = blendMode; }
    
    /*!
     * @brief       Set <code>this</code>'s color.
     * @param       opacity     New color.
     */
    virtual void
    setColor(const Color& color) { _color = color; }
    
    /*!
     * @brief       Set <code>this</code>'s clipping quad.
     * @param       opacity     New clipping quad.
     */
    virtual void
    setClippingQuad(const Rect& quad) { _clippingQuad = quad; }
    
private:
    
    /*!
     * @brief       Hardware <code>SDL_Texture</code> object.
     */
    ARC<SDLTextureRef> _hwTexture;
    
    /*!
     * @brief       Texture's opacity
     */
    float           _alpha;
    
    /*!
     * @brief       Texture's blending mode.
     */
    BlendMode       _blendMode;
    
    /*!
     * @brief       Texture's color.
     */
    Color           _color;
    
    /*!
     * @brief       Texture's clipping quad.
     */
    Rect            _clippingQuad;
    
    /*!
     * @brief       Texture's size in pixel.
     */
    size2          _size;
};

NS_END

#endif /* defined(__Meteor__SDLTexture__) */
