Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/angle
Path: blob/main_old/util/windows/win32/Win32Pixmap.cpp
1693 views
1
//
2
// Copyright 2015 The ANGLE Project Authors. All rights reserved.
3
// Use of this source code is governed by a BSD-style license that can be
4
// found in the LICENSE file.
5
//
6
7
// Win32Pixmap.cpp: Implementation of OSPixmap for Win32 (Windows)
8
9
#include "util/windows/win32/Win32Pixmap.h"
10
11
Win32Pixmap::Win32Pixmap() : mBitmap(nullptr) {}
12
13
Win32Pixmap::~Win32Pixmap()
14
{
15
if (mBitmap)
16
{
17
DeleteObject(mBitmap);
18
}
19
}
20
21
bool Win32Pixmap::initialize(EGLNativeDisplayType display, size_t width, size_t height, int depth)
22
{
23
BITMAPINFO bitmapInfo;
24
memset(&bitmapInfo, 0, sizeof(bitmapInfo));
25
26
if (depth != 24 && depth != 32)
27
{
28
return false;
29
}
30
31
bitmapInfo.bmiHeader.biSize = sizeof(bitmapInfo);
32
bitmapInfo.bmiHeader.biWidth = static_cast<LONG>(width);
33
bitmapInfo.bmiHeader.biHeight = static_cast<LONG>(height);
34
bitmapInfo.bmiHeader.biPlanes = 1;
35
bitmapInfo.bmiHeader.biBitCount = static_cast<WORD>(depth);
36
bitmapInfo.bmiHeader.biCompression = BI_RGB;
37
bitmapInfo.bmiHeader.biSizeImage = 0;
38
bitmapInfo.bmiHeader.biXPelsPerMeter = 1;
39
bitmapInfo.bmiHeader.biYPelsPerMeter = 1;
40
bitmapInfo.bmiHeader.biClrUsed = 0;
41
bitmapInfo.bmiHeader.biClrImportant = 0;
42
43
void *bitmapPtr = nullptr;
44
mBitmap = CreateDIBSection(display, &bitmapInfo, DIB_RGB_COLORS, &bitmapPtr, nullptr, 0);
45
46
return mBitmap != nullptr;
47
}
48
49
EGLNativePixmapType Win32Pixmap::getNativePixmap() const
50
{
51
return mBitmap;
52
}
53
54
OSPixmap *CreateOSPixmap()
55
{
56
return new Win32Pixmap();
57
}
58
59