1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     font_DispStringBuffer.h
4 
5   Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law.  They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Revision: 30103 $
14  *---------------------------------------------------------------------------*/
15 
16 #ifndef NN_FONT_CTR_FONT_DISP_STRING_BUFFER_H_
17 #define NN_FONT_CTR_FONT_DISP_STRING_BUFFER_H_
18 
19 #include <nn/font/font_Types.h>
20 
21 namespace nn {
22 namespace font {
23 namespace CTR {
24 
25 struct CharAttribute
26 {
27     math::VEC4          pos;
28     util::Color8        color[internal::TEXTCOLOR_MAX];
29     math::VEC4          tex;
30     const internal::TextureObject*
31                         pTexObj;        //!< テクスチャオブジェクトへのポインタ
32 };
33 
34 //---------------------------------------------------------------------------
35 //! @brief        文字列表示用バッファを管理するクラスです。
36 //---------------------------------------------------------------------------
37 struct DispStringBuffer
38 {
39     const u32           charCountMax;           //!< 格納可能な文字数
40 
41     u16                 charCount;              //!< 格納した文字数
42     u16                 drawCharCount;          //!< 描画コマンドを生成する文字数
43 
44     u8                  generatedCommand;       //!< コマンドが生成された。
45     u8                  padding[3];
46 
47     u8*                 drawFlags;              //!< フラグ配列
48     u32*                commandBuffer;          //!< コマンドバッファ
49     u32                 commandBufferSize;      //!< 使用しているコマンドバッファサイズ
50     u32                 commandBufferCapacity;  //!< コマンドバッファのキャパシティ
51     u32                 textColorCommandOffset; //!< テキストカラーのコマンドのオフセット
52 
53     //! 頂点属性配列
GetCharAttrsDispStringBuffer54     CharAttribute* GetCharAttrs() const
55     {
56         return reinterpret_cast<CharAttribute*>( reinterpret_cast<uptr>(this) + sizeof(*this) );
57     }
58 
59     static u32          CalcCommandBufferCapacity(u32 charNum);
60 
61     //! コンストラクタです。
62                         DispStringBuffer(u32 charNum);
63 
64     //! コマンドをクリアします。
ClearCommandDispStringBuffer65     void                ClearCommand()
66     {
67         generatedCommand = false;
68     }
69 
70     //! コマンドが生成済みかどうかを判定します。
IsGeneratedCommandDispStringBuffer71     bool                IsGeneratedCommand()
72     {
73         return 0 != generatedCommand;
74     }
75 
76     //! コマンドが空かどうかを判定します。
IsCommandEmptyDispStringBuffer77     bool                IsCommandEmpty()
78     {
79         return 0 == commandBufferSize;
80     }
81 
82     //! 描画コマンドを生成する文字数を取得します。
GetDrawCharCountDispStringBuffer83     u16                 GetDrawCharCount() const    { return drawCharCount; }
84 
85     //! 描画コマンドを生成する文字数を設定します。
SetDrawCharCountDispStringBuffer86     void                SetDrawCharCount(u16 count)
87     {
88         drawCharCount = count;
89     }
90 
91     //! 描画コマンドを生成する文字数をリセットします。
ResetDrawCharCountDispStringBuffer92     void                ResetDrawCharCount()
93     {
94         SetDrawCharCount(0xFFFF);
95     }
96 };
97 
98 }   // namespace CTR
99 }   // namespace font
100 }   // namespace nn
101 
102 #endif //  NN_FONT_CTR_FONT_DISP_STRING_BUFFER_H_
103