25#include <com/sun/star/rendering/ColorComponentTag.hpp>
50 DXColorBuffer(
const sal::systools::COMReference<surface_type>& rSurface,
51 const ::basegfx::B2ISize& rSize )
62 virtual void unlock()
const override;
63 virtual sal_uInt32 getWidth()
const override;
64 virtual sal_uInt32 getHeight()
const override;
65 virtual sal_uInt32 getStride()
const override;
66 virtual Format getFormat()
const override;
72 sal::systools::COMReference<surface_type>
mpSurface;
82 void DXColorBuffer::unlock()
const
87 sal_uInt32 DXColorBuffer::getWidth()
const
92 sal_uInt32 DXColorBuffer::getHeight()
const
97 sal_uInt32 DXColorBuffer::getStride()
const
116 const ::basegfx::B2ISize& rSize )
127 virtual void unlock()
const override;
128 virtual sal_uInt32 getWidth()
const override;
129 virtual sal_uInt32 getHeight()
const override;
130 virtual sal_uInt32 getStride()
const override;
131 virtual Format getFormat()
const override;
145 aBmpData.PixelFormat = PixelFormat32bppARGB;
149 Gdiplus::ImageLockModeRead,
150 PixelFormat32bppARGB,
159 void GDIColorBuffer::unlock()
const
164 sal_uInt32 GDIColorBuffer::getWidth()
const
169 sal_uInt32 GDIColorBuffer::getHeight()
const
174 sal_uInt32 GDIColorBuffer::getStride()
const
190 const std::shared_ptr<canvas::ISurfaceProxyManager>& rMgr,
195 mpRenderModule(rRenderModule),
196 mpSurfaceManager(rMgr),
202 mbIsSurfaceDirty(true),
276 Gdiplus::Color transColor(255,0,0,0);
277 pGraphics->SetCompositingMode( Gdiplus::CompositingModeSourceCopy );
278 pGraphics->Clear( transColor );
319 D3DLOCKED_RECT aLockedRect;
320 if(SUCCEEDED(
mpSurface->LockRect(&aLockedRect,
nullptr,D3DLOCK_NOSYSLOCK|D3DLOCK_READONLY)))
324 Gdiplus::PixelFormat nFormat =
hasAlpha() ? PixelFormat32bppARGB : PixelFormat32bppRGB;
330 static_cast<BYTE *
>(aLockedRect.pBits) );
343 const ::basegfx::B2DPoint& rPos,
344 const ::basegfx::B2DPolyPolygon& rClipPoly,
345 const ::basegfx::B2DHomMatrix& rTransform )
353 return mpSurfaceProxy->draw( fAlpha, rPos, rClipPoly, rTransform );
361 const ::basegfx::B2DPoint& rPos,
362 const ::basegfx::B2DRange& rArea,
363 const ::basegfx::B2DHomMatrix& rTransform )
379 const ::basegfx::B2DPoint& rPos,
380 const ::basegfx::B2DHomMatrix& rTransform )
403 const double fAlpha(1.0);
404 const ::basegfx::B2DHomMatrix aTransform;
405 const ::basegfx::B2DRange aIEEEArea( rArea );
417 const geometry::IntegerRectangle2D& rect )
421 uno::Sequence< sal_Int8 > aRes( (rect.X2-rect.X1)*(rect.Y2-rect.Y1)*4 );
429 aBmpData.PixelFormat = PixelFormat32bppARGB;
436 Gdiplus::ImageLockModeRead | Gdiplus::ImageLockModeUserInputBuf,
437 PixelFormat32bppARGB,
444 return uno::Sequence< sal_Int8 >();
453 sal_uInt32 nWidth = rect.X2-rect.X1;
454 sal_uInt32 nHeight = rect.Y2-rect.Y1;
456 uno::Sequence< sal_Int8 > aRes(nWidth*nHeight*4);
458 D3DLOCKED_RECT aLockedRect;
459 if(FAILED(
mpSurface->LockRect(&aLockedRect,
nullptr,D3DLOCK_NOSYSLOCK|D3DLOCK_READONLY)))
460 return uno::Sequence< sal_Int8 >();
461 D3DSURFACE_DESC aDesc;
463 return uno::Sequence< sal_Int8 >();
465 assert(aDesc.Format == D3DFMT_A8R8G8B8 || aDesc.Format == D3DFMT_X8R8G8B8);
467 sal_uInt8 *pSrc = (
static_cast<BYTE *
>(aLockedRect.pBits)+(rect.Y1*aLockedRect.Pitch))+rect.X1;
469 sal_uInt32 nSegmentSizeInBytes = nWidth*4;
470 for(sal_uInt32
y=0;
y<nHeight; ++
y)
472 memcpy(pDst,pSrc,nSegmentSizeInBytes);
473 pDst += nSegmentSizeInBytes;
474 pSrc += aLockedRect.Pitch;
477 if(rBitmapLayout.ColorSpace->getComponentTags().getArray()[0] == rendering::ColorComponentTag::RGB_RED &&
478 rBitmapLayout.ColorSpace->getComponentTags().getArray()[2] == rendering::ColorComponentTag::RGB_BLUE)
480 pDst =
reinterpret_cast<sal_uInt8 *
>(aRes.getArray());
481 for(sal_uInt32
y=0;
y<nHeight; ++
y)
484 for(sal_uInt32
n = 0;
n<nWidth;
n++)
487 pPixel[0] = pPixel[2];
491 pDst += nSegmentSizeInBytes;
505 const rendering::IntegerBitmapLayout& ,
506 const geometry::IntegerRectangle2D& rect )
516 aBmpData.PixelFormat = PixelFormat32bppARGB;
522 Gdiplus::ImageLockModeWrite | Gdiplus::ImageLockModeUserInputBuf,
523 PixelFormat32bppARGB,
529 throw uno::RuntimeException(
"GDIPlus method call was unsuccessful, problem with locking bitmap aRect object");
537 sal_uInt32 nWidth = rect.X2-rect.X1;
538 sal_uInt32 nHeight = rect.Y2-rect.Y1;
541 D3DLOCKED_RECT aLockedRect;
542 if(FAILED(
mpSurface->LockRect(&aLockedRect,
nullptr,D3DLOCK_NOSYSLOCK|D3DLOCK_READONLY)))
543 throw uno::RuntimeException(
"failed to lock directx surface to surface memory");
546 sal_uInt8 *pDst = (
static_cast<BYTE *
>(aLockedRect.pBits)+(rect.Y1*aLockedRect.Pitch))+rect.X1;
547 sal_uInt32 nSegmentSizeInBytes = nWidth<<4;
548 for(sal_uInt32
y=0;
y<nHeight; ++
y)
550 memcpy(pDst,pSrc,nSegmentSizeInBytes);
551 pSrc += nSegmentSizeInBytes;
552 pDst += aLockedRect.Pitch;
566 const rendering::IntegerBitmapLayout& ,
567 const geometry::IntegerPoint2D& pos )
574 "CanvasHelper::setPixel: X coordinate out of bounds" );
576 "CanvasHelper::setPixel: Y coordinate out of bounds" );
578 "CanvasHelper::setPixel: not enough color components" );
583 throw uno::RuntimeException(
"Problem with setting the color of bitmap object");
589 "CanvasHelper::setPixel: X coordinate out of bounds" );
591 "CanvasHelper::setPixel: Y coordinate out of bounds" );
593 "CanvasHelper::setPixel: not enough color components" );
598 D3DLOCKED_RECT aLockedRect;
599 if(FAILED(
mpSurface->LockRect(&aLockedRect,
nullptr,D3DLOCK_NOSYSLOCK|D3DLOCK_READONLY)))
600 throw uno::RuntimeException(
"cannot lock the directx surface to surface memory");
602 sal_uInt32 *pDst =
reinterpret_cast<sal_uInt32 *
>((
static_cast<BYTE *
>(aLockedRect.pBits)+(
pos.Y*aLockedRect.Pitch))+
pos.X);
603 *pDst = aColor.GetValue();
615 const geometry::IntegerPoint2D& pos )
622 "CanvasHelper::getPixel: X coordinate out of bounds" );
624 "CanvasHelper::getPixel: Y coordinate out of bounds" );
626 Gdiplus::Color aColor;
629 return uno::Sequence< sal_Int8 >();
636 "CanvasHelper::getPixel: X coordinate out of bounds" );
638 "CanvasHelper::getPixel: Y coordinate out of bounds" );
641 D3DLOCKED_RECT aLockedRect;
642 if(FAILED(
mpSurface->LockRect(&aLockedRect,
nullptr,D3DLOCK_NOSYSLOCK|D3DLOCK_READONLY)))
643 throw uno::RuntimeException(
"failed to lock directX surface to surface memory");
645 sal_uInt32 *pDst =
reinterpret_cast<sal_uInt32 *
>((
static_cast<BYTE *
>(aLockedRect.pBits)+(
pos.Y*aLockedRect.Pitch))+
pos.X);
646 Gdiplus::Color aColor(*pDst);
HRESULT createInstance(REFIID iid, Ifc **ppIfc)
virtual bool hasAlpha() const override
GraphicsSharedPtr mpGraphics
virtual ::basegfx::B2ISize getSize() const override
std::shared_ptr< canvas::ISurfaceProxyManager > mpSurfaceManager
std::shared_ptr< canvas::ISurfaceProxy > mpSurfaceProxy
IDXRenderModuleSharedPtr mpRenderModule
virtual void setPixel(const css::uno::Sequence< sal_Int8 > &color, const css::rendering::IntegerBitmapLayout &bitmapLayout, const css::geometry::IntegerPoint2D &pos) override
::basegfx::B2ISize maSize
bool resize(const ::basegfx::B2ISize &rSize)
sal::systools::COMReference< surface_type > mpSurface
bool draw(double fAlpha, const ::basegfx::B2DPoint &rPos, const ::basegfx::B2DHomMatrix &rTransform)
virtual css::uno::Sequence< sal_Int8 > getPixel(css::rendering::IntegerBitmapLayout &bitmapLayout, const css::geometry::IntegerPoint2D &pos) override
virtual GraphicsSharedPtr getGraphics() override
virtual void setData(const css::uno::Sequence< sal_Int8 > &data, const css::rendering::IntegerBitmapLayout &bitmapLayout, const css::geometry::IntegerRectangle2D &rect) override
virtual BitmapSharedPtr getBitmap() const override
DXSurfaceBitmap(const ::basegfx::B2ISize &rSize, const std::shared_ptr< canvas::ISurfaceProxyManager > &rMgr, const IDXRenderModuleSharedPtr &rRenderModule, bool bWithAlpha)
virtual css::uno::Sequence< sal_Int8 > getData(css::rendering::IntegerBitmapLayout &bitmapLayout, const css::geometry::IntegerRectangle2D &rect) override
std::shared_ptr< canvas::IColorBuffer > mpColorBuffer
BitmapSharedPtr mpGDIPlusBitmap
#define ENSURE_ARG_OR_THROW(c, m)
GraphicsSharedPtr mpGraphics
BitmapSharedPtr mpGDIPlusBitmap
Gdiplus::BitmapData aBmpData
sal::systools::COMReference< surface_type > mpSurface
D3DLOCKED_RECT maLockedRect
::basegfx::B2ISize maSize
std::shared_ptr< osl::Mutex > const & lock()
std::shared_ptr< ::cppcanvas::Bitmap > BitmapSharedPtr
std::shared_ptr< Gdiplus::Graphics > GraphicsSharedPtr
GraphicsSharedPtr createSurfaceGraphics(const sal::systools::COMReference< surface_type > &rSurface)
Container providing a Gdiplus::Graphics for a Surface.
std::shared_ptr< IDXRenderModule > IDXRenderModuleSharedPtr
std::shared_ptr< Gdiplus::Bitmap > BitmapSharedPtr
Interface for a raw memory pixel container.
Format
The underlying pixel format for this buffer.