* Coding style cleanup
* Added a flag "fIsOffscreenBuffer", which is used to shift the frame buffer pointer to the position after the visible frame buffer. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26543 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,55 +1,49 @@
|
|||||||
//------------------------------------------------------------------------------
|
/*
|
||||||
// Copyright (c) 2005, Haiku, Inc.
|
* Copyright 2005 Michael Lotz <[email protected]>
|
||||||
//
|
* All rights reserved. Distributed under the terms of the MIT license.
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
*/
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
|
||||||
// to deal in the Software without restriction, including without limitation
|
//! A RenderingBuffer implementation that accesses graphics memory directly.
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
// Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in
|
|
||||||
// all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
//
|
|
||||||
// File Name: AccelerantBuffer.cpp
|
|
||||||
// Author: Michael Lotz <[email protected]>
|
|
||||||
// Description: A RenderingBuffer implementation that accesses graphics
|
|
||||||
// memory directly.
|
|
||||||
//
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include "AccelerantBuffer.h"
|
#include "AccelerantBuffer.h"
|
||||||
|
|
||||||
// constructors
|
|
||||||
AccelerantBuffer::AccelerantBuffer()
|
AccelerantBuffer::AccelerantBuffer()
|
||||||
: fDisplayModeSet(false),
|
: fDisplayModeSet(false),
|
||||||
fFrameBufferConfigSet(false)
|
fFrameBufferConfigSet(false),
|
||||||
|
fIsOffscreenBuffer(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
AccelerantBuffer::AccelerantBuffer( const display_mode &mode,
|
|
||||||
const frame_buffer_config &config)
|
AccelerantBuffer::AccelerantBuffer(const display_mode& mode,
|
||||||
: fDisplayModeSet(false),
|
const frame_buffer_config& config)
|
||||||
fFrameBufferConfigSet(false)
|
: fDisplayModeSet(false),
|
||||||
|
fFrameBufferConfigSet(false),
|
||||||
|
fIsOffscreenBuffer(false)
|
||||||
{
|
{
|
||||||
SetDisplayMode(mode);
|
SetDisplayMode(mode);
|
||||||
SetFrameBufferConfig(config);
|
SetFrameBufferConfig(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
// destructor
|
|
||||||
|
AccelerantBuffer::AccelerantBuffer(const AccelerantBuffer& other,
|
||||||
|
bool offscreenBuffer)
|
||||||
|
: fDisplayMode(other.fDisplayMode),
|
||||||
|
fFrameBufferConfig(other.fFrameBufferConfig),
|
||||||
|
fDisplayModeSet(other.fDisplayModeSet),
|
||||||
|
fFrameBufferConfigSet(other.fFrameBufferConfigSet),
|
||||||
|
fIsOffscreenBuffer(other.fIsOffscreenBuffer || offscreenBuffer)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
AccelerantBuffer::~AccelerantBuffer()
|
AccelerantBuffer::~AccelerantBuffer()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// InitCheck
|
|
||||||
status_t
|
status_t
|
||||||
AccelerantBuffer::InitCheck() const
|
AccelerantBuffer::InitCheck() const
|
||||||
{
|
{
|
||||||
@@ -59,7 +53,7 @@ AccelerantBuffer::InitCheck() const
|
|||||||
return B_NO_INIT;
|
return B_NO_INIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ColorSpace
|
|
||||||
color_space
|
color_space
|
||||||
AccelerantBuffer::ColorSpace() const
|
AccelerantBuffer::ColorSpace() const
|
||||||
{
|
{
|
||||||
@@ -69,21 +63,22 @@ AccelerantBuffer::ColorSpace() const
|
|||||||
return B_NO_COLOR_SPACE;
|
return B_NO_COLOR_SPACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bits
|
|
||||||
void *
|
void*
|
||||||
AccelerantBuffer::Bits() const
|
AccelerantBuffer::Bits() const
|
||||||
{
|
{
|
||||||
if (InitCheck() != B_OK)
|
if (InitCheck() != B_OK)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// TODO: Enable this if we can ensure that frame_buffer_dma is valid
|
uint8* bits = (uint8*)fFrameBufferConfig.frame_buffer;
|
||||||
/*if (fFrameBufferConfig.frame_buffer_dma)
|
|
||||||
return fFrameBufferConfig.frame_buffer_dma;*/
|
|
||||||
|
|
||||||
return fFrameBufferConfig.frame_buffer;
|
if (fIsOffscreenBuffer)
|
||||||
|
bits += fDisplayMode.virtual_height * fFrameBufferConfig.bytes_per_row;
|
||||||
|
|
||||||
|
return bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
// BytesPerRow
|
|
||||||
uint32
|
uint32
|
||||||
AccelerantBuffer::BytesPerRow() const
|
AccelerantBuffer::BytesPerRow() const
|
||||||
{
|
{
|
||||||
@@ -93,7 +88,7 @@ AccelerantBuffer::BytesPerRow() const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Width
|
|
||||||
uint32
|
uint32
|
||||||
AccelerantBuffer::Width() const
|
AccelerantBuffer::Width() const
|
||||||
{
|
{
|
||||||
@@ -103,7 +98,7 @@ AccelerantBuffer::Width() const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Height
|
|
||||||
uint32
|
uint32
|
||||||
AccelerantBuffer::Height() const
|
AccelerantBuffer::Height() const
|
||||||
{
|
{
|
||||||
@@ -113,16 +108,25 @@ AccelerantBuffer::Height() const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AccelerantBuffer::SetDisplayMode(const display_mode &mode)
|
AccelerantBuffer::SetDisplayMode(const display_mode& mode)
|
||||||
{
|
{
|
||||||
fDisplayMode = mode;
|
fDisplayMode = mode;
|
||||||
fDisplayModeSet = true;
|
fDisplayModeSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AccelerantBuffer::SetFrameBufferConfig(const frame_buffer_config &config)
|
AccelerantBuffer::SetFrameBufferConfig(const frame_buffer_config& config)
|
||||||
{
|
{
|
||||||
fFrameBufferConfig = config;
|
fFrameBufferConfig = config;
|
||||||
fFrameBufferConfigSet = true;
|
fFrameBufferConfigSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AccelerantBuffer::SetOffscreenBuffer(bool offscreenBuffer)
|
||||||
|
{
|
||||||
|
fIsOffscreenBuffer = offscreenBuffer;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,31 +1,7 @@
|
|||||||
//------------------------------------------------------------------------------
|
/*
|
||||||
// Copyright (c) 2005, Haiku, Inc.
|
* Copyright 2005 Michael Lotz <[email protected]>
|
||||||
//
|
* All rights reserved. Distributed under the terms of the MIT license.
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
*/
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
|
||||||
// to deal in the Software without restriction, including without limitation
|
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
// Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in
|
|
||||||
// all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
//
|
|
||||||
// File Name: AccelerantBuffer.h
|
|
||||||
// Author: Michael Lotz <[email protected]>
|
|
||||||
// Description: A RenderingBuffer implementation that accesses graphics
|
|
||||||
// memory directly.
|
|
||||||
//
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef ACCELERANT_BUFFER_H
|
#ifndef ACCELERANT_BUFFER_H
|
||||||
#define ACCELERANT_BUFFER_H
|
#define ACCELERANT_BUFFER_H
|
||||||
|
|
||||||
@@ -35,27 +11,32 @@
|
|||||||
class AccelerantBuffer : public RenderingBuffer {
|
class AccelerantBuffer : public RenderingBuffer {
|
||||||
public:
|
public:
|
||||||
AccelerantBuffer();
|
AccelerantBuffer();
|
||||||
AccelerantBuffer(const display_mode &mode,
|
AccelerantBuffer(const display_mode& mode,
|
||||||
const frame_buffer_config &config);
|
const frame_buffer_config& config);
|
||||||
virtual ~AccelerantBuffer();
|
AccelerantBuffer(const AccelerantBuffer& other,
|
||||||
|
bool offscreenBuffer = false);
|
||||||
|
virtual ~AccelerantBuffer();
|
||||||
|
|
||||||
virtual status_t InitCheck() const;
|
virtual status_t InitCheck() const;
|
||||||
|
|
||||||
virtual color_space ColorSpace() const;
|
virtual color_space ColorSpace() const;
|
||||||
virtual void *Bits() const;
|
virtual void* Bits() const;
|
||||||
virtual uint32 BytesPerRow() const;
|
virtual uint32 BytesPerRow() const;
|
||||||
virtual uint32 Width() const;
|
virtual uint32 Width() const;
|
||||||
virtual uint32 Height() const;
|
virtual uint32 Height() const;
|
||||||
|
|
||||||
void SetDisplayMode(const display_mode &mode);
|
void SetDisplayMode(const display_mode& mode);
|
||||||
void SetFrameBufferConfig(const frame_buffer_config &config);
|
void SetFrameBufferConfig(
|
||||||
|
const frame_buffer_config& config);
|
||||||
|
void SetOffscreenBuffer(bool offscreenBuffer);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
display_mode fDisplayMode;
|
display_mode fDisplayMode;
|
||||||
frame_buffer_config fFrameBufferConfig;
|
frame_buffer_config fFrameBufferConfig;
|
||||||
|
|
||||||
bool fDisplayModeSet;
|
bool fDisplayModeSet : 1;
|
||||||
bool fFrameBufferConfigSet;
|
bool fFrameBufferConfigSet : 1;
|
||||||
|
bool fIsOffscreenBuffer : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ACCELERANT_BUFFER_H
|
#endif // ACCELERANT_BUFFER_H
|
||||||
|
|||||||
Reference in New Issue
Block a user