2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2012-05-21 04:12:37 -07:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef GFX_WINDOWSSURFACE_H
|
|
|
|
#define GFX_WINDOWSSURFACE_H
|
|
|
|
|
|
|
|
#include "gfxASurface.h"
|
|
|
|
#include "gfxImageSurface.h"
|
|
|
|
|
2013-03-25 14:53:54 -07:00
|
|
|
/* include windows.h for the HWND and HDC definitions that we need. */
|
2007-03-22 10:30:00 -07:00
|
|
|
#include <windows.h>
|
2013-09-04 13:53:54 -07:00
|
|
|
|
|
|
|
struct IDirect3DSurface9;
|
|
|
|
|
2013-03-25 14:53:54 -07:00
|
|
|
/* undefine LoadImage because our code uses that name */
|
|
|
|
#undef LoadImage
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-04-05 19:28:54 -07:00
|
|
|
class gfxContext;
|
|
|
|
|
2013-05-29 14:59:24 -07:00
|
|
|
class gfxWindowsSurface : public gfxASurface {
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
2007-09-24 15:50:44 -07:00
|
|
|
enum {
|
|
|
|
FLAG_TAKE_DC = (1 << 0),
|
2010-07-15 14:07:44 -07:00
|
|
|
FLAG_FOR_PRINTING = (1 << 1),
|
2010-08-20 11:19:38 -07:00
|
|
|
FLAG_IS_TRANSPARENT = (1 << 2)
|
2007-09-24 15:50:44 -07:00
|
|
|
};
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
gfxWindowsSurface(HWND wnd, uint32_t flags = 0);
|
|
|
|
gfxWindowsSurface(HDC dc, uint32_t flags = 0);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-09-04 13:53:54 -07:00
|
|
|
// Create from a shared d3d9surface
|
|
|
|
gfxWindowsSurface(IDirect3DSurface9 *surface, uint32_t flags = 0);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Create a DIB surface
|
|
|
|
gfxWindowsSurface(const gfxIntSize& size,
|
2013-09-24 13:45:13 -07:00
|
|
|
gfxImageFormat imageFormat = gfxImageFormatRGB24);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-31 08:44:31 -07:00
|
|
|
// Create a DDB surface; dc may be nullptr to use the screen DC
|
2007-03-22 10:30:00 -07:00
|
|
|
gfxWindowsSurface(HDC dc,
|
|
|
|
const gfxIntSize& size,
|
2013-09-24 13:45:13 -07:00
|
|
|
gfxImageFormat imageFormat = gfxImageFormatRGB24);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
gfxWindowsSurface(cairo_surface_t *csurf);
|
|
|
|
|
2011-01-31 19:47:47 -08:00
|
|
|
virtual already_AddRefed<gfxASurface> CreateSimilarSurface(gfxContentType aType,
|
|
|
|
const gfxIntSize& aSize);
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void InitWithDC(uint32_t flags);
|
2010-07-15 14:08:10 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual ~gfxWindowsSurface();
|
|
|
|
|
2013-09-04 13:53:54 -07:00
|
|
|
HDC GetDC();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-04-05 19:28:54 -07:00
|
|
|
HDC GetDCWithClip(gfxContext *);
|
|
|
|
|
2010-11-11 12:31:22 -08:00
|
|
|
already_AddRefed<gfxImageSurface> GetAsImageSurface();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
already_AddRefed<gfxWindowsSurface> OptimizeToDDB(HDC dc,
|
|
|
|
const gfxIntSize& size,
|
|
|
|
gfxImageFormat format);
|
|
|
|
|
|
|
|
nsresult BeginPrinting(const nsAString& aTitle, const nsAString& aPrintToFileName);
|
|
|
|
nsresult EndPrinting();
|
|
|
|
nsresult AbortPrinting();
|
|
|
|
nsresult BeginPage();
|
|
|
|
nsresult EndPage();
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual int32_t GetDefaultContextFlags() const;
|
2007-11-29 12:06:56 -08:00
|
|
|
|
2011-11-17 20:00:37 -08:00
|
|
|
const gfxIntSize GetSize() const;
|
|
|
|
|
2011-05-07 18:19:11 -07:00
|
|
|
void MovePixels(const nsIntRect& aSourceRect,
|
|
|
|
const nsIntPoint& aDestTopLeft)
|
|
|
|
{
|
|
|
|
FastMovePixels(aSourceRect, aDestTopLeft);
|
|
|
|
}
|
|
|
|
|
2011-07-18 06:20:27 -07:00
|
|
|
// The memory used by this surface lives in this process's address space,
|
|
|
|
// but not in the heap.
|
2013-09-24 13:45:13 -07:00
|
|
|
virtual gfxMemoryLocation GetMemoryLocation() const;
|
2011-07-18 06:20:27 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
private:
|
2011-09-13 07:49:01 -07:00
|
|
|
void MakeInvalid(gfxIntSize& size);
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mOwnsDC;
|
|
|
|
bool mForPrinting;
|
2007-09-24 15:50:44 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
HDC mDC;
|
|
|
|
HWND mWnd;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* GFX_WINDOWSSURFACE_H */
|