Path: blob/main_old/util/windows/win32/Win32Pixmap.cpp
1693 views
//1// Copyright 2015 The ANGLE Project Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4//56// Win32Pixmap.cpp: Implementation of OSPixmap for Win32 (Windows)78#include "util/windows/win32/Win32Pixmap.h"910Win32Pixmap::Win32Pixmap() : mBitmap(nullptr) {}1112Win32Pixmap::~Win32Pixmap()13{14if (mBitmap)15{16DeleteObject(mBitmap);17}18}1920bool Win32Pixmap::initialize(EGLNativeDisplayType display, size_t width, size_t height, int depth)21{22BITMAPINFO bitmapInfo;23memset(&bitmapInfo, 0, sizeof(bitmapInfo));2425if (depth != 24 && depth != 32)26{27return false;28}2930bitmapInfo.bmiHeader.biSize = sizeof(bitmapInfo);31bitmapInfo.bmiHeader.biWidth = static_cast<LONG>(width);32bitmapInfo.bmiHeader.biHeight = static_cast<LONG>(height);33bitmapInfo.bmiHeader.biPlanes = 1;34bitmapInfo.bmiHeader.biBitCount = static_cast<WORD>(depth);35bitmapInfo.bmiHeader.biCompression = BI_RGB;36bitmapInfo.bmiHeader.biSizeImage = 0;37bitmapInfo.bmiHeader.biXPelsPerMeter = 1;38bitmapInfo.bmiHeader.biYPelsPerMeter = 1;39bitmapInfo.bmiHeader.biClrUsed = 0;40bitmapInfo.bmiHeader.biClrImportant = 0;4142void *bitmapPtr = nullptr;43mBitmap = CreateDIBSection(display, &bitmapInfo, DIB_RGB_COLORS, &bitmapPtr, nullptr, 0);4445return mBitmap != nullptr;46}4748EGLNativePixmapType Win32Pixmap::getNativePixmap() const49{50return mBitmap;51}5253OSPixmap *CreateOSPixmap()54{55return new Win32Pixmap();56}575859