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-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;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
class THEBES_API gfxWindowsSurface : public gfxASurface {
|
|
|
|
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
|
|
|
|
|
|
|
// Create a DIB surface
|
|
|
|
gfxWindowsSurface(const gfxIntSize& size,
|
|
|
|
gfxImageFormat imageFormat = ImageFormatRGB24);
|
|
|
|
|
|
|
|
// Create a DDB surface; dc may be NULL to use the screen DC
|
|
|
|
gfxWindowsSurface(HDC dc,
|
|
|
|
const gfxIntSize& size,
|
|
|
|
gfxImageFormat imageFormat = ImageFormatRGB24);
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
HDC GetDC() { return mDC; }
|
|
|
|
|
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.
|
|
|
|
virtual gfxASurface::MemoryLocation GetMemoryLocation() const;
|
|
|
|
|
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 */
|