Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
michael@0 | 2 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef GFX_WINDOWSSURFACE_H |
michael@0 | 7 | #define GFX_WINDOWSSURFACE_H |
michael@0 | 8 | |
michael@0 | 9 | #include "gfxASurface.h" |
michael@0 | 10 | #include "gfxImageSurface.h" |
michael@0 | 11 | |
michael@0 | 12 | /* include windows.h for the HWND and HDC definitions that we need. */ |
michael@0 | 13 | #include <windows.h> |
michael@0 | 14 | |
michael@0 | 15 | struct IDirect3DSurface9; |
michael@0 | 16 | |
michael@0 | 17 | /* undefine LoadImage because our code uses that name */ |
michael@0 | 18 | #undef LoadImage |
michael@0 | 19 | |
michael@0 | 20 | class gfxContext; |
michael@0 | 21 | |
michael@0 | 22 | class gfxWindowsSurface : public gfxASurface { |
michael@0 | 23 | public: |
michael@0 | 24 | enum { |
michael@0 | 25 | FLAG_TAKE_DC = (1 << 0), |
michael@0 | 26 | FLAG_FOR_PRINTING = (1 << 1), |
michael@0 | 27 | FLAG_IS_TRANSPARENT = (1 << 2) |
michael@0 | 28 | }; |
michael@0 | 29 | |
michael@0 | 30 | gfxWindowsSurface(HWND wnd, uint32_t flags = 0); |
michael@0 | 31 | gfxWindowsSurface(HDC dc, uint32_t flags = 0); |
michael@0 | 32 | |
michael@0 | 33 | // Create from a shared d3d9surface |
michael@0 | 34 | gfxWindowsSurface(IDirect3DSurface9 *surface, uint32_t flags = 0); |
michael@0 | 35 | |
michael@0 | 36 | // Create a DIB surface |
michael@0 | 37 | gfxWindowsSurface(const gfxIntSize& size, |
michael@0 | 38 | gfxImageFormat imageFormat = gfxImageFormat::RGB24); |
michael@0 | 39 | |
michael@0 | 40 | // Create a DDB surface; dc may be nullptr to use the screen DC |
michael@0 | 41 | gfxWindowsSurface(HDC dc, |
michael@0 | 42 | const gfxIntSize& size, |
michael@0 | 43 | gfxImageFormat imageFormat = gfxImageFormat::RGB24); |
michael@0 | 44 | |
michael@0 | 45 | gfxWindowsSurface(cairo_surface_t *csurf); |
michael@0 | 46 | |
michael@0 | 47 | virtual already_AddRefed<gfxASurface> CreateSimilarSurface(gfxContentType aType, |
michael@0 | 48 | const gfxIntSize& aSize); |
michael@0 | 49 | |
michael@0 | 50 | void InitWithDC(uint32_t flags); |
michael@0 | 51 | |
michael@0 | 52 | virtual ~gfxWindowsSurface(); |
michael@0 | 53 | |
michael@0 | 54 | HDC GetDC(); |
michael@0 | 55 | |
michael@0 | 56 | HDC GetDCWithClip(gfxContext *); |
michael@0 | 57 | |
michael@0 | 58 | already_AddRefed<gfxImageSurface> GetAsImageSurface(); |
michael@0 | 59 | |
michael@0 | 60 | nsresult BeginPrinting(const nsAString& aTitle, const nsAString& aPrintToFileName); |
michael@0 | 61 | nsresult EndPrinting(); |
michael@0 | 62 | nsresult AbortPrinting(); |
michael@0 | 63 | nsresult BeginPage(); |
michael@0 | 64 | nsresult EndPage(); |
michael@0 | 65 | |
michael@0 | 66 | virtual int32_t GetDefaultContextFlags() const; |
michael@0 | 67 | |
michael@0 | 68 | const gfxIntSize GetSize() const; |
michael@0 | 69 | |
michael@0 | 70 | void MovePixels(const nsIntRect& aSourceRect, |
michael@0 | 71 | const nsIntPoint& aDestTopLeft) |
michael@0 | 72 | { |
michael@0 | 73 | FastMovePixels(aSourceRect, aDestTopLeft); |
michael@0 | 74 | } |
michael@0 | 75 | |
michael@0 | 76 | // The memory used by this surface lives in this process's address space, |
michael@0 | 77 | // but not in the heap. |
michael@0 | 78 | virtual gfxMemoryLocation GetMemoryLocation() const; |
michael@0 | 79 | |
michael@0 | 80 | private: |
michael@0 | 81 | void MakeInvalid(gfxIntSize& size); |
michael@0 | 82 | |
michael@0 | 83 | bool mOwnsDC; |
michael@0 | 84 | bool mForPrinting; |
michael@0 | 85 | |
michael@0 | 86 | HDC mDC; |
michael@0 | 87 | HWND mWnd; |
michael@0 | 88 | }; |
michael@0 | 89 | |
michael@0 | 90 | #endif /* GFX_WINDOWSSURFACE_H */ |