/*---------------------------------------------------------------------------* Project: NintendoWare File: dev_Screenshot.h Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. $Revision: 21180 $ *---------------------------------------------------------------------------*/ #ifndef NW_DEV_SCREENSHOT_H_ #define NW_DEV_SCREENSHOT_H_ #include #include #include #include #include #if defined(NW_DEV_ENABLED) && defined(NW_PLATFORM_CTR) #include #endif namespace nw { namespace os { class IAllocator; } namespace dev { #if defined(NW_DEV_ENABLED) && defined(NW_PLATFORM_CTR) //! @brief ディスプレイバッファの内容を表す構造体です。 struct DisplayDescription { //! @brief コンストラクタです。 DisplayDescription() : format(0), width(0), height(0), offsetX(0), offsetY(0), display(0) {} GLint format; //!< カラーフォーマットです。 GLint width; //!< バッファの横幅です。 GLint height; //!< バッファの縦幅です。 int offsetX; //!< ディスプレイに表示するオフセットです。 int offsetY; //!< ディスプレイに表示するオフセットです。 GLenum display; //!< ディスプレイを表す定義です。 }; //! @brief スクリーンショットを表すクラスです。 class Screenshot { public: //! @brief ハッシュコードを取得します。 u32* GetHash() { return this->m_Hash; } //! @brief ハッシュコードを取得します。 const u32* GetHash() const { return this->m_Hash; } //! @brief スクリーンショットとハッシュコードの比較を行います。 bool Equal(const Screenshot* source) const { return (this->m_Hash[0] == source->GetHash()[0] && this->m_Hash[1] == source->GetHash()[1] && this->m_Hash[2] == source->GetHash()[2] && this->m_Hash[3] == source->GetHash()[3]); } //! @brief ハッシュコードの比較を行います。 bool Equal(const u32* hash) const { return (this->m_Hash[0] == hash[0] && this->m_Hash[1] == hash[1] && this->m_Hash[2] == hash[2] && this->m_Hash[3] == hash[3]); } //! @brief スクリーンショットが書き込まれたかどうかを調べます。 bool IsWrited() const { return m_Writed; } //! @brief ハッシュを文字列で出力します。 void DumpHash() const; //! @brief スクリーンショットを生成します。 //! //! @param[in] allocator アロケータです。 //! @param[in] maxLength バッファ領域の大きさです。 //! //! @return 生成したスクリーンショットです。 //! static Screenshot* Create( nw::os::IAllocator* allocator, size_t maxLength); //! @brief ディスプレイバッファからスクリーンショットを設定します。 //! //! @param[in] displayDescription ディスプレイバッファの内容です。 //! @param[in] srcScreen コピー元のディスプレイバッファの領域です。 //! @param[in] length バッファ領域の大きさです。 //! @param[in] width スクリーンショットの横幅です。 //! @param[in] height スクリーンショットの縦幅です。 //! void Set(const DisplayDescription& displayDescription, void* srcScreen, int length, int width, int height); //! @brief バッファのサイズを取得します。 int GetBufferLength() const { return m_Length; } //! @brief バッファを取得します。 const void* GetBuffer() const { return m_CopyScreen; } //! @brief スクリーンショットの横幅を取得します。 int GetWidth() const { return m_Width; } //! @brief スクリーンショットの縦幅を取得します。 int GetHeight() const { return m_Height; } //! @brief デストラクタです。 ~Screenshot(); private: //! @brief コンストラクタです。 Screenshot( nw::os::IAllocator* allocator, void* copyScreen, size_t maxLength, u32* hash) : m_Allocator(allocator), m_CopyScreen(copyScreen), m_SrcScreen(NULL), m_Length(0), m_MaxLength(maxLength), m_Hash(hash), m_Writed(false), m_Width(0), m_Height(0) {} DisplayDescription m_DisplayDescription; nw::os::IAllocator* m_Allocator; void* m_CopyScreen; void* m_SrcScreen; size_t m_Length; size_t m_MaxLength; u32* m_Hash; bool m_Writed; int m_Width; int m_Height; }; //! @brief テスト用にスクリーンショットを作成する機能を提供します。 class ScreenshotManager { public: //! @brief スクリーンショットの管理クラスを生成します。 static ScreenshotManager* Create( nw::os::IAllocator* allocator, int maxScreenshot, int memorySize ); //! @brief スクリーンショットを撮影してメモリを確保して保存します。 //! //! @return 撮影したスクリーンショットのインデックス番号を返します。 int Take( GLenum display, int offsetX = 0, int offsetY = 0); //---------------------------------------- //! @name 取得/設定 //@{ //! @brief 保存したスクリーンショットを削除します。 void ClearScreenshots(); //! @brief スクリーンショットのリストを表します。 typedef ut::MoveArray ScreenshotArray; //! @brief スクリーンショットのリストの範囲を表す型の定義です。 typedef std::pair< ScreenshotArray::iterator, ScreenshotArray::iterator> ScreenshotRange; //! @brief スクリーンショットのリストの先頭と末尾を取得します。 ScreenshotRange GetScreenshots() { return std::make_pair( m_Screenshots.begin(), m_Screenshots.end()); } //! @brief スクリーンショットの数を取得します。 int GetScreenshotCount() const { return m_Screenshots.size(); } //! @brief 指定したインデックス番号のスクリーンショットを取得します。 Screenshot* GetScreenshot(int index) { return m_Screenshots[index]; } //! @brief 指定したインデックス番号のスクリーンショットを取得します。 const Screenshot* GetScreenshot(int index) const { return m_Screenshots[index]; } //@} void Destroy(os::IAllocator* allocator); private: //! @brief コンストラクタです。 ScreenshotManager( nw::os::IAllocator* allocator, ScreenshotArray screenshots ); //! @brief デストラクタです。 ~ScreenshotManager(); nw::os::IAllocator* m_Allocator; ScreenshotArray m_Screenshots; int m_NextWrited; }; #else struct DisplayDescription { DisplayDescription() : format(0), width(0), height(0), offsetX(0), offsetY(0), display(0) {} GLint format; GLint width; GLint height; int offsetX; int offsetY; GLenum display; }; class Screenshot { public: u32* GetHash() { return NULL; } const u32* GetHash() const { return NULL; } void DumpHash() const {} static Screenshot* Create(DisplayDescription, nw::os::IAllocator*, void*, void*, size_t) { return NULL; } bool Equal(const Screenshot*) const { return false; } bool Equal(const u32*) const { return false; } bool IsWrited() const { return false; } void Set(const DisplayDescription&, void*, int) {}; private: }; class ScreenshotManager { public: static ScreenshotManager* Create(nw::os::IAllocator*, int, int) { return NULL; } bool Take(GLenum, int = 0, int = 0) { return false; } void ClearScreenshots() {} typedef ut::MoveArray ScreenshotArray; typedef std::pair< ScreenshotArray::iterator, ScreenshotArray::iterator> ScreenshotRange; ScreenshotRange GetScreenshots() { return ScreenshotRange(); } int GetScreenshotCount() const { return 0; } Screenshot* GetScreenshot(int) { return NULL; } const Screenshot* GetScreenshot(int) const { return NULL; } void Destroy(os::IAllocator*) {} private: }; #endif // NW_DEV_ENABLED } // namespace nw::dev } // namespace nw #endif // NW_DEV_SCREENSHOT_H_