ScummVM API documentation
atari-surface.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef BACKENDS_GRAPHICS_ATARI_SURFACE_H
23#define BACKENDS_GRAPHICS_ATARI_SURFACE_H
24
25#include "graphics/managed_surface.h"
26
27#include "backends/graphics/atari/atari-supervidel.h"
28
30constexpr Graphics::PixelFormat PIXELFORMAT_RGB332 = Graphics::PixelFormat(1, 3, 3, 2, 0, 5, 2, 0, 0);
31constexpr Graphics::PixelFormat PIXELFORMAT_RGB121 = Graphics::PixelFormat(1, 1, 2, 1, 0, 3, 1, 0, 0);
32
34public:
35 AtariSurface() = default;
36 AtariSurface(int16 width, int16 height, const Graphics::PixelFormat &pixelFormat);
37 ~AtariSurface() override;
38
40 void create(int16 width, int16 height, const Graphics::PixelFormat &pixelFormat) final override;
41 void free() final override;
42
43 void addDirtyRect(const Common::Rect &r) final override {};
44
45 // no override as ManagedSurface::copyRectToSurface is not a virtual function!
46 virtual void copyRectToSurface(const void *buffer, int srcPitch, int destX, int destY, int width, int height);
47 virtual void copyRectToSurface(const Graphics::Surface &srcSurface, int destX, int destY, const Common::Rect &subRect) {
48 assert(subRect.left % 16 == 0);
49 assert(srcSurface.format == format);
50
51 copyRectToSurface(
52 srcSurface.getBasePtr(subRect.left, subRect.top), srcSurface.pitch,
53 destX, destY,
54 subRect.width(), subRect.height());
55 }
56
57 virtual void drawMaskedSprite(const Graphics::Surface &srcSurface, const Graphics::Surface &srcMask,
58 const Graphics::Surface &boundingSurface,
59 int destX, int destY,
60 const Common::Rect &subRect);
61
62 int getBitsPerPixel() const {
63 return format == PIXELFORMAT_RGB121 ? 4 : 8;
64 }
65
66 static Common::Rect alignRect(int x1, int y1, int x2, int y2) {
67 // make non-virtual for performance reasons
68 return g_hasSuperVidel
69 ? Common::Rect(x1, y1, x2, y2)
70 : Common::Rect(x1 & (-16), y1, (x2 + 15) & (-16), y2);
71 }
72 static Common::Rect alignRect(const Common::Rect &rect) {
73 // make non-virtual for performance reasons
74 return g_hasSuperVidel
75 ? rect
76 : Common::Rect(rect.left & (-16), rect.top, (rect.right + 15) & (-16), rect.bottom);
77 }
78};
79
80#ifdef USE_SUPERVIDEL
81class SuperVidelSurface final : public AtariSurface {
82public:
83 SuperVidelSurface() = default;
84 SuperVidelSurface(int16 width, int16 height, const Graphics::PixelFormat &pixelFormat)
85 : AtariSurface(width, height, pixelFormat) {
86 }
87
88 //using Graphics::ManagedSurface::copyRectToSurface;
89 void copyRectToSurface(const void *buffer, int srcPitch, int destX, int destY, int width, int height) override {
90 Graphics::ManagedSurface::copyRectToSurface(buffer, srcPitch, destX, destY, width, height);
91 }
92 void copyRectToSurface(const Graphics::Surface &srcSurface, int destX, int destY, const Common::Rect &subRect) override {
93 Graphics::ManagedSurface::copyRectToSurface(srcSurface, destX, destY, subRect);
94 }
95
96 void drawMaskedSprite(const Graphics::Surface &srcSurface, const Graphics::Surface &srcMask,
97 const Graphics::Surface &boundingSurface,
98 int destX, int destY,
99 const Common::Rect &subRect) override {
100#ifdef USE_SV_BLITTER
101 g_blitMask = (const byte *)srcMask.getBasePtr(subRect.left, subRect.top);
102#endif
103 copyRectToSurfaceWithKey(srcSurface, destX, destY, subRect, 0);
104#ifdef USE_SV_BLITTER
105 g_blitMask = nullptr;
106#endif
107 }
108};
109#endif
110
111void AtariSurfaceInit();
112void AtariSurfaceDeinit();
113
114#endif // BACKENDS_GRAPHICS_ATARI_SURFACE_H
Definition: atari-surface.h:33
void create(int16 width, int16 height, const Graphics::PixelFormat &pixelFormat) final override
void free() final override
void addDirtyRect(const Common::Rect &r) final override
Definition: atari-surface.h:43
Definition: managed_surface.h:51
virtual void create(int16 width, int16 height)
void copyRectToSurface(const void *buffer, int srcPitch, int destX, int destY, int width, int height)
Definition: managed_surface.h:815
PixelFormat & format
Definition: managed_surface.h:137
void copyRectToSurfaceWithKey(const void *buffer, int srcPitch, int destX, int destY, int width, int height, uint32 key)
Definition: managed_surface.h:835
Definition: algorithm.h:29
T height() const
Definition: rect.h:218
T left
Definition: rect.h:170
T width() const
Definition: rect.h:217
Definition: rect.h:536
Definition: pixelformat.h:138
static constexpr PixelFormat createFormatCLUT8()
Definition: pixelformat.h:184
Definition: surface.h:67
const void * getBasePtr(int x, int y) const
Definition: surface.h:140
int32 pitch
Definition: surface.h:83
PixelFormat format
Definition: surface.h:95