mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Direct2D: Tidy up implementation of createBitmap and remove lineStride parameter
The lineStride parameter is only required to be set when the 'data' pointer is also set.
This commit is contained in:
parent
e18b78dbb2
commit
e67e78803c
3 changed files with 9 additions and 17 deletions
|
|
@ -59,7 +59,6 @@ public:
|
|||
presentationBitmap = Direct2DBitmap::createBitmap (context,
|
||||
Image::ARGB,
|
||||
{ (uint32) swapSize.getWidth(), (uint32) swapSize.getHeight() },
|
||||
swapSize.getWidth() * 4,
|
||||
D2D1_BITMAP_OPTIONS_TARGET);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ class NativeReadOnlyDataReleaser : public Image::BitmapData::BitmapDataReleaser
|
|||
{
|
||||
public:
|
||||
NativeReadOnlyDataReleaser (Image::PixelFormat pixelFormat,
|
||||
int lineStride,
|
||||
int w,
|
||||
int h,
|
||||
ComSmartPtr<ID2D1DeviceContext1> deviceContextIn,
|
||||
|
|
@ -48,7 +47,6 @@ public:
|
|||
: bitmap (Direct2DBitmap::createBitmap (deviceContextIn,
|
||||
pixelFormat,
|
||||
{ (UINT32) w, (UINT32) h },
|
||||
lineStride,
|
||||
D2D1_BITMAP_OPTIONS_CPU_READ | D2D1_BITMAP_OPTIONS_CANNOT_DRAW))
|
||||
{
|
||||
const D2D1_POINT_2U destPoint { 0, 0 };
|
||||
|
|
@ -138,7 +136,6 @@ ComSmartPtr<ID2D1Bitmap1> Direct2DPixelData::createAdapterBitmap() const
|
|||
auto bitmap = Direct2DBitmap::createBitmap (context,
|
||||
pixelFormat,
|
||||
{ (UINT32) width, (UINT32) height },
|
||||
getLineStride(),
|
||||
D2D1_BITMAP_OPTIONS_TARGET);
|
||||
|
||||
// The bitmap may be slightly too large due
|
||||
|
|
@ -186,7 +183,6 @@ void Direct2DPixelData::initBitmapDataReadOnly (Image::BitmapData& bitmap, int x
|
|||
JUCE_TRACE_LOG_D2D_IMAGE_MAP_DATA;
|
||||
|
||||
auto releaser = std::make_unique<NativeReadOnlyDataReleaser> (pixelFormat,
|
||||
lineStride,
|
||||
width,
|
||||
height,
|
||||
context,
|
||||
|
|
|
|||
|
|
@ -150,7 +150,6 @@ public:
|
|||
static ComSmartPtr<ID2D1Bitmap1> createBitmap (ComSmartPtr<ID2D1DeviceContext1> deviceContext,
|
||||
Image::PixelFormat format,
|
||||
D2D_SIZE_U size,
|
||||
int lineStride,
|
||||
D2D1_BITMAP_OPTIONS options)
|
||||
{
|
||||
JUCE_TRACE_LOG_D2D_PAINT_CALL (etw::createDirect2DBitmap, etw::graphicsKeyword);
|
||||
|
|
@ -166,20 +165,18 @@ public:
|
|||
jassert (size.width <= maxBitmapSize && size.height <= maxBitmapSize);
|
||||
#endif
|
||||
|
||||
D2D1_BITMAP_PROPERTIES1 bitmapProperties{};
|
||||
bitmapProperties.dpiX = bitmapProperties.dpiY = USER_DEFAULT_SCREEN_DPI;
|
||||
bitmapProperties.pixelFormat.format = format == Image::SingleChannel
|
||||
? DXGI_FORMAT_A8_UNORM
|
||||
: DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
bitmapProperties.pixelFormat.alphaMode = format == Image::RGB
|
||||
? D2D1_ALPHA_MODE_IGNORE
|
||||
: D2D1_ALPHA_MODE_PREMULTIPLIED;
|
||||
bitmapProperties.bitmapOptions = options;
|
||||
const auto pixelFormat = D2D1::PixelFormat (format == Image::SingleChannel
|
||||
? DXGI_FORMAT_A8_UNORM
|
||||
: DXGI_FORMAT_B8G8R8A8_UNORM,
|
||||
format == Image::RGB
|
||||
? D2D1_ALPHA_MODE_IGNORE
|
||||
: D2D1_ALPHA_MODE_PREMULTIPLIED);
|
||||
const auto bitmapProperties = D2D1::BitmapProperties1 (options, pixelFormat);
|
||||
|
||||
ComSmartPtr<ID2D1Bitmap1> bitmap;
|
||||
deviceContext->CreateBitmap (size,
|
||||
nullptr,
|
||||
(UINT32) lineStride,
|
||||
{},
|
||||
{},
|
||||
bitmapProperties,
|
||||
bitmap.resetAndGetPointerAddress());
|
||||
return bitmap;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue