| 1 | // Aseprite | 
|---|---|
| 2 | // Copyright (C) 2001-2015 David Capello | 
| 3 | // | 
| 4 | // This program is distributed under the terms of | 
| 5 | // the End-User License Agreement for Aseprite. | 
| 6 | |
| 7 | #ifndef APP_COLOR_TARGET_H_INCLUDED | 
| 8 | #define APP_COLOR_TARGET_H_INCLUDED | 
| 9 | #pragma once | 
| 10 | |
| 11 | #include "doc/color.h" | 
| 12 | #include "doc/layer.h" | 
| 13 | #include "doc/pixel_format.h" | 
| 14 | #include "doc/sprite.h" | 
| 15 | |
| 16 | namespace app { | 
| 17 | |
| 18 | // Represents the kind of surface where we'll use a color. | 
| 19 | class ColorTarget { | 
| 20 | public: | 
| 21 | enum LayerType { | 
| 22 | BackgroundLayer, | 
| 23 | TransparentLayer | 
| 24 | }; | 
| 25 | |
| 26 | ColorTarget(LayerType layerType, doc::PixelFormat pixelFormat, doc::color_t maskColor) : | 
| 27 | m_layerType(layerType), | 
| 28 | m_pixelFormat(pixelFormat), | 
| 29 | m_maskColor(maskColor) { | 
| 30 | } | 
| 31 | |
| 32 | ColorTarget(doc::Layer* layer) : | 
| 33 | m_layerType(layer->isBackground() ? BackgroundLayer: TransparentLayer), | 
| 34 | m_pixelFormat(layer->sprite()->pixelFormat()), | 
| 35 | m_maskColor(layer->sprite()->transparentColor()) { | 
| 36 | } | 
| 37 | |
| 38 | bool isBackground() const { return m_layerType == BackgroundLayer; } | 
| 39 | bool isTransparent() const { return m_layerType == TransparentLayer; } | 
| 40 | LayerType layerType() const { return m_layerType; } | 
| 41 | doc::PixelFormat pixelFormat() const { return m_pixelFormat; } | 
| 42 | doc::color_t maskColor() const { return m_maskColor; } | 
| 43 | |
| 44 | private: | 
| 45 | LayerType m_layerType; | 
| 46 | doc::PixelFormat m_pixelFormat; | 
| 47 | doc::color_t m_maskColor; | 
| 48 | }; | 
| 49 | |
| 50 | } // namespace app | 
| 51 | |
| 52 | #endif | 
| 53 | 
