blob: 0879424d242c06080411d48a917ef8dfe15616db (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#include <stdafx.h>
#include <vd2/Kasumi/blitter.h>
VDPixmapCachedBlitter::VDPixmapCachedBlitter()
: mSrcWidth(0)
, mSrcHeight(0)
, mSrcFormat(0)
, mDstWidth(0)
, mDstHeight(0)
, mDstFormat(0)
, mpCachedBlitter(NULL)
{
}
VDPixmapCachedBlitter::~VDPixmapCachedBlitter() {
Invalidate();
}
void VDPixmapCachedBlitter::Blit(const VDPixmap& dst, const VDPixmap& src) {
VDASSERT(src.w == dst.w && src.h == dst.h);
if (!mpCachedBlitter ||
dst.w != mDstWidth ||
dst.h != mDstHeight ||
dst.format != mDstFormat ||
src.w != mSrcWidth ||
src.h != mSrcHeight ||
src.format != mSrcFormat)
{
if (mpCachedBlitter)
delete mpCachedBlitter;
mpCachedBlitter = VDPixmapCreateBlitter(dst, src);
if (!mpCachedBlitter)
return;
mDstWidth = dst.w;
mDstHeight = dst.h;
mDstFormat = dst.format;
mSrcWidth = src.w;
mSrcHeight = src.h;
mSrcFormat = src.format;
}
mpCachedBlitter->Blit(dst, src);
}
void VDPixmapCachedBlitter::Invalidate() {
if (mpCachedBlitter) {
delete mpCachedBlitter;
mpCachedBlitter = NULL;
}
}
|