* 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:
Stephan Aßmus 2008-07-21 12:33:06 +00:00
parent c5ac899aac
commit 328699e5f6
2 changed files with 79 additions and 94 deletions

View File

@ -1,55 +1,49 @@
//------------------------------------------------------------------------------
// Copyright (c) 2005, Haiku, Inc.
//
// 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.cpp
// Author: Michael Lotz <mmlr@mlotz.ch>
// Description: A RenderingBuffer implementation that accesses graphics
// memory directly.
//
//------------------------------------------------------------------------------
/*
* Copyright 2005 Michael Lotz <mmlr@mlotz.ch>
* All rights reserved. Distributed under the terms of the MIT license.
*/
//! A RenderingBuffer implementation that accesses graphics memory directly.
#include "AccelerantBuffer.h"
// constructors
AccelerantBuffer::AccelerantBuffer()
: fDisplayModeSet(false),
fFrameBufferConfigSet(false)
: fDisplayModeSet(false),
fFrameBufferConfigSet(false),
fIsOffscreenBuffer(false)
{
}
AccelerantBuffer::AccelerantBuffer( const display_mode &mode,
const frame_buffer_config &config)
: fDisplayModeSet(false),
fFrameBufferConfigSet(false)
AccelerantBuffer::AccelerantBuffer(const display_mode& mode,
const frame_buffer_config& config)
: fDisplayModeSet(false),
fFrameBufferConfigSet(false),
fIsOffscreenBuffer(false)
{
SetDisplayMode(mode);
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()
{
}
// InitCheck
status_t
AccelerantBuffer::InitCheck() const
{
@ -59,7 +53,7 @@ AccelerantBuffer::InitCheck() const
return B_NO_INIT;
}
// ColorSpace
color_space
AccelerantBuffer::ColorSpace() const
{
@ -69,21 +63,22 @@ AccelerantBuffer::ColorSpace() const
return B_NO_COLOR_SPACE;
}
// Bits
void *
void*
AccelerantBuffer::Bits() const
{
if (InitCheck() != B_OK)
return NULL;
// TODO: Enable this if we can ensure that frame_buffer_dma is valid
/*if (fFrameBufferConfig.frame_buffer_dma)
return fFrameBufferConfig.frame_buffer_dma;*/
return fFrameBufferConfig.frame_buffer;
uint8* bits = (uint8*)fFrameBufferConfig.frame_buffer;
if (fIsOffscreenBuffer)
bits += fDisplayMode.virtual_height * fFrameBufferConfig.bytes_per_row;
return bits;
}
// BytesPerRow
uint32
AccelerantBuffer::BytesPerRow() const
{
@ -93,7 +88,7 @@ AccelerantBuffer::BytesPerRow() const
return 0;
}
// Width
uint32
AccelerantBuffer::Width() const
{
@ -103,7 +98,7 @@ AccelerantBuffer::Width() const
return 0;
}
// Height
uint32
AccelerantBuffer::Height() const
{
@ -113,16 +108,25 @@ AccelerantBuffer::Height() const
return 0;
}
void
AccelerantBuffer::SetDisplayMode(const display_mode &mode)
AccelerantBuffer::SetDisplayMode(const display_mode& mode)
{
fDisplayMode = mode;
fDisplayModeSet = true;
}
void
AccelerantBuffer::SetFrameBufferConfig(const frame_buffer_config &config)
AccelerantBuffer::SetFrameBufferConfig(const frame_buffer_config& config)
{
fFrameBufferConfig = config;
fFrameBufferConfigSet = true;
}
void
AccelerantBuffer::SetOffscreenBuffer(bool offscreenBuffer)
{
fIsOffscreenBuffer = offscreenBuffer;
}

View File

@ -1,31 +1,7 @@
//------------------------------------------------------------------------------
// Copyright (c) 2005, Haiku, Inc.
//
// 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 <mmlr@mlotz.ch>
// Description: A RenderingBuffer implementation that accesses graphics
// memory directly.
//
//------------------------------------------------------------------------------
/*
* Copyright 2005 Michael Lotz <mmlr@mlotz.ch>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#ifndef ACCELERANT_BUFFER_H
#define ACCELERANT_BUFFER_H
@ -35,27 +11,32 @@
class AccelerantBuffer : public RenderingBuffer {
public:
AccelerantBuffer();
AccelerantBuffer(const display_mode &mode,
const frame_buffer_config &config);
virtual ~AccelerantBuffer();
AccelerantBuffer(const display_mode& mode,
const frame_buffer_config& config);
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 void *Bits() const;
virtual uint32 BytesPerRow() const;
virtual uint32 Width() const;
virtual uint32 Height() const;
virtual color_space ColorSpace() const;
virtual void* Bits() const;
virtual uint32 BytesPerRow() const;
virtual uint32 Width() const;
virtual uint32 Height() const;
void SetDisplayMode(const display_mode &mode);
void SetFrameBufferConfig(const frame_buffer_config &config);
void SetDisplayMode(const display_mode& mode);
void SetFrameBufferConfig(
const frame_buffer_config& config);
void SetOffscreenBuffer(bool offscreenBuffer);
private:
display_mode fDisplayMode;
frame_buffer_config fFrameBufferConfig;
bool fDisplayModeSet;
bool fFrameBufferConfigSet;
display_mode fDisplayMode;
frame_buffer_config fFrameBufferConfig;
bool fDisplayModeSet : 1;
bool fFrameBufferConfigSet : 1;
bool fIsOffscreenBuffer : 1;
};
#endif // ACCELERANT_BUFFER_H