📄 memoryblock.h
字号:
//// Copyright (c) 2005 by Istv醤 V醨adi//// This file is part of dxr3Player, a DVD player written specifically // for the DXR3 (aka Hollywood+) decoder card, but now handles other// hardware as well. These files contain a (mostly) user-space driver // for the Unichrome board found on Via's EPIA motherboards.//// The information for implementing this driver has been gathered// from the following sources://// - The DirectFB Unichrome driver// Copyright (c) 2003 Andreas Robinson, All rights reserved.//// - Andreas Robinson's MPEG-2 decoder for the Unichrome board.// Copyright (c) 2003 Andreas Robinson, All rights reserved.//// - Via's Unichrome Framebuffer driver// Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.// Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.//// You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA#ifndef UNICHROME_MEMORYBLOCK_H#define UNICHROME_MEMORYBLOCK_H//------------------------------------------------------------------------------#include "Unichrome.h"#include <inttypes.h>//------------------------------------------------------------------------------namespace unichrome {//------------------------------------------------------------------------------/** * This class represents a memory block allocated from the video * board's own memory. Blocks represented by instances of this class * are different from the graphics, video and SPU frame buffers, which * are handled elsewhere, automatically by the driver. Such memory is * allocated from the beginning of the on-board memory, while the * memory blocks belonging to instances of this class start to get * allocated from the end. * * These memory blocks are supposed to hold such things as fonts, * patterns, bitmaps, etc. They are linked to ensure that they are * freed in the reverse order of their allocation. This must be * ensured by the programmer, this class only checks if the * deallocation order is correct. */class MemoryBlock{private: /** * The previous memory block. */ MemoryBlock* previous; /** * The Unichrome board this memory block is allocated on. */ Unichrome& unichrome; /** * The offset of this memory block within the frame buffer. */ size_t offset; /** * The size of this memory block. */ size_t size; /** * Construct the memory block. */ MemoryBlock(MemoryBlock* previous, Unichrome& unichrome, size_t offset, size_t size);public: /** * Destroy the memory block. It can be destroyed only, if this is * the last one. */ ~MemoryBlock(); /** * Get the size of this memory block. */ size_t getSize() const; /** * Set this memory block as the source for an operation. */ void setSource(size_t pitch = 0) const; /** * Set an offset within this memory block as the source for an operation. */ void setOffsetSource(size_t o, size_t pitch = 0) const; /** * Get the frame buffer pointer of this memory block. */ volatile void* getBuffer() const; /** * Get the frame buffer pointer as a pointer to 8-bit characters * of this memory block. */ volatile uint8_t* getBuffer8() const; /** * Get the frame buffer pointer as a pointer to 32-bit characters * of this memory block. */ volatile uint32_t* getBuffer32() const;private: /** * Get the previous memory block. */ MemoryBlock* getPrevious() const; /** * Get the unichrome boards this memory block belongs to. */ Unichrome& getUnichrome() const; /** * Get the offset of this memory block. */ size_t getOffset() const; friend class Unichrome; friend class PhysicalWindow;};//------------------------------------------------------------------------------// Inline definitions//------------------------------------------------------------------------------inline MemoryBlock::MemoryBlock(MemoryBlock* previous, Unichrome& unichrome, size_t offset, size_t size) : previous(previous), unichrome(unichrome), offset(offset), size(size){}//------------------------------------------------------------------------------inline MemoryBlock::~MemoryBlock(){ unichrome.deallocateMemoryBlock(this);}//------------------------------------------------------------------------------inline size_t MemoryBlock::getSize() const{ return size;}//------------------------------------------------------------------------------inline void MemoryBlock::setOffsetSource(size_t o, size_t pitch) const{ unichrome.setSourceBase(offset + o); if (pitch!=0) { unichrome.setSourcePitch(pitch); }}//------------------------------------------------------------------------------inline void MemoryBlock::setSource(size_t pitch) const{ setOffsetSource(0, pitch);}//------------------------------------------------------------------------------inline volatile void* MemoryBlock::getBuffer() const{ return unichrome.getFrameBuffer() + offset;}//------------------------------------------------------------------------------inline volatile uint8_t* MemoryBlock::getBuffer8() const{ return reinterpret_cast<volatile uint8_t*>(getBuffer());}//------------------------------------------------------------------------------inline volatile uint32_t* MemoryBlock::getBuffer32() const{ return reinterpret_cast<volatile uint32_t*>(getBuffer());}//------------------------------------------------------------------------------inline MemoryBlock* MemoryBlock::getPrevious() const{ return previous;}//------------------------------------------------------------------------------inline Unichrome& MemoryBlock::getUnichrome() const{ return unichrome;}//------------------------------------------------------------------------------inline size_t MemoryBlock::getOffset() const{ return offset;}//------------------------------------------------------------------------------} /* namespace unichrome *///------------------------------------------------------------------------------#endif // UNICHROME_MEMORYBLOCK_H// Local variables:// mode: c++// End:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -