michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef GFX_WINDOWSSURFACE_H michael@0: #define GFX_WINDOWSSURFACE_H michael@0: michael@0: #include "gfxASurface.h" michael@0: #include "gfxImageSurface.h" michael@0: michael@0: /* include windows.h for the HWND and HDC definitions that we need. */ michael@0: #include michael@0: michael@0: struct IDirect3DSurface9; michael@0: michael@0: /* undefine LoadImage because our code uses that name */ michael@0: #undef LoadImage michael@0: michael@0: class gfxContext; michael@0: michael@0: class gfxWindowsSurface : public gfxASurface { michael@0: public: michael@0: enum { michael@0: FLAG_TAKE_DC = (1 << 0), michael@0: FLAG_FOR_PRINTING = (1 << 1), michael@0: FLAG_IS_TRANSPARENT = (1 << 2) michael@0: }; michael@0: michael@0: gfxWindowsSurface(HWND wnd, uint32_t flags = 0); michael@0: gfxWindowsSurface(HDC dc, uint32_t flags = 0); michael@0: michael@0: // Create from a shared d3d9surface michael@0: gfxWindowsSurface(IDirect3DSurface9 *surface, uint32_t flags = 0); michael@0: michael@0: // Create a DIB surface michael@0: gfxWindowsSurface(const gfxIntSize& size, michael@0: gfxImageFormat imageFormat = gfxImageFormat::RGB24); michael@0: michael@0: // Create a DDB surface; dc may be nullptr to use the screen DC michael@0: gfxWindowsSurface(HDC dc, michael@0: const gfxIntSize& size, michael@0: gfxImageFormat imageFormat = gfxImageFormat::RGB24); michael@0: michael@0: gfxWindowsSurface(cairo_surface_t *csurf); michael@0: michael@0: virtual already_AddRefed CreateSimilarSurface(gfxContentType aType, michael@0: const gfxIntSize& aSize); michael@0: michael@0: void InitWithDC(uint32_t flags); michael@0: michael@0: virtual ~gfxWindowsSurface(); michael@0: michael@0: HDC GetDC(); michael@0: michael@0: HDC GetDCWithClip(gfxContext *); michael@0: michael@0: already_AddRefed GetAsImageSurface(); michael@0: michael@0: nsresult BeginPrinting(const nsAString& aTitle, const nsAString& aPrintToFileName); michael@0: nsresult EndPrinting(); michael@0: nsresult AbortPrinting(); michael@0: nsresult BeginPage(); michael@0: nsresult EndPage(); michael@0: michael@0: virtual int32_t GetDefaultContextFlags() const; michael@0: michael@0: const gfxIntSize GetSize() const; michael@0: michael@0: void MovePixels(const nsIntRect& aSourceRect, michael@0: const nsIntPoint& aDestTopLeft) michael@0: { michael@0: FastMovePixels(aSourceRect, aDestTopLeft); michael@0: } michael@0: michael@0: // The memory used by this surface lives in this process's address space, michael@0: // but not in the heap. michael@0: virtual gfxMemoryLocation GetMemoryLocation() const; michael@0: michael@0: private: michael@0: void MakeInvalid(gfxIntSize& size); michael@0: michael@0: bool mOwnsDC; michael@0: bool mForPrinting; michael@0: michael@0: HDC mDC; michael@0: HWND mWnd; michael@0: }; michael@0: michael@0: #endif /* GFX_WINDOWSSURFACE_H */