1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/thebes/gfxWindowsSurface.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,90 @@ 1.4 +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.5 + * This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef GFX_WINDOWSSURFACE_H 1.10 +#define GFX_WINDOWSSURFACE_H 1.11 + 1.12 +#include "gfxASurface.h" 1.13 +#include "gfxImageSurface.h" 1.14 + 1.15 +/* include windows.h for the HWND and HDC definitions that we need. */ 1.16 +#include <windows.h> 1.17 + 1.18 +struct IDirect3DSurface9; 1.19 + 1.20 +/* undefine LoadImage because our code uses that name */ 1.21 +#undef LoadImage 1.22 + 1.23 +class gfxContext; 1.24 + 1.25 +class gfxWindowsSurface : public gfxASurface { 1.26 +public: 1.27 + enum { 1.28 + FLAG_TAKE_DC = (1 << 0), 1.29 + FLAG_FOR_PRINTING = (1 << 1), 1.30 + FLAG_IS_TRANSPARENT = (1 << 2) 1.31 + }; 1.32 + 1.33 + gfxWindowsSurface(HWND wnd, uint32_t flags = 0); 1.34 + gfxWindowsSurface(HDC dc, uint32_t flags = 0); 1.35 + 1.36 + // Create from a shared d3d9surface 1.37 + gfxWindowsSurface(IDirect3DSurface9 *surface, uint32_t flags = 0); 1.38 + 1.39 + // Create a DIB surface 1.40 + gfxWindowsSurface(const gfxIntSize& size, 1.41 + gfxImageFormat imageFormat = gfxImageFormat::RGB24); 1.42 + 1.43 + // Create a DDB surface; dc may be nullptr to use the screen DC 1.44 + gfxWindowsSurface(HDC dc, 1.45 + const gfxIntSize& size, 1.46 + gfxImageFormat imageFormat = gfxImageFormat::RGB24); 1.47 + 1.48 + gfxWindowsSurface(cairo_surface_t *csurf); 1.49 + 1.50 + virtual already_AddRefed<gfxASurface> CreateSimilarSurface(gfxContentType aType, 1.51 + const gfxIntSize& aSize); 1.52 + 1.53 + void InitWithDC(uint32_t flags); 1.54 + 1.55 + virtual ~gfxWindowsSurface(); 1.56 + 1.57 + HDC GetDC(); 1.58 + 1.59 + HDC GetDCWithClip(gfxContext *); 1.60 + 1.61 + already_AddRefed<gfxImageSurface> GetAsImageSurface(); 1.62 + 1.63 + nsresult BeginPrinting(const nsAString& aTitle, const nsAString& aPrintToFileName); 1.64 + nsresult EndPrinting(); 1.65 + nsresult AbortPrinting(); 1.66 + nsresult BeginPage(); 1.67 + nsresult EndPage(); 1.68 + 1.69 + virtual int32_t GetDefaultContextFlags() const; 1.70 + 1.71 + const gfxIntSize GetSize() const; 1.72 + 1.73 + void MovePixels(const nsIntRect& aSourceRect, 1.74 + const nsIntPoint& aDestTopLeft) 1.75 + { 1.76 + FastMovePixels(aSourceRect, aDestTopLeft); 1.77 + } 1.78 + 1.79 + // The memory used by this surface lives in this process's address space, 1.80 + // but not in the heap. 1.81 + virtual gfxMemoryLocation GetMemoryLocation() const; 1.82 + 1.83 +private: 1.84 + void MakeInvalid(gfxIntSize& size); 1.85 + 1.86 + bool mOwnsDC; 1.87 + bool mForPrinting; 1.88 + 1.89 + HDC mDC; 1.90 + HWND mWnd; 1.91 +}; 1.92 + 1.93 +#endif /* GFX_WINDOWSSURFACE_H */