Bug 606990 - Remove CAIRO_HAS_DDRAW_SURFACE/CAIRO_DDRAW_USE_GL dead code. r=vlad,jmuizelaar a=bsmedberg

This commit is contained in:
Emmanuel Gil Peyrot 2010-11-24 11:11:45 +01:00
Родитель a1854766cd
Коммит fc651b0ef4
16 изменённых файлов: 1 добавлений и 4816 удалений

Просмотреть файл

@ -167,7 +167,6 @@ CPPSRCS += cairo-d2d-surface.cpp
endif
CSRCS += cairo-win32-font.c
else
CSRCS += cairo-ddraw-surface.c
EXPORTS_cairo += cairo-ddraw.h
endif

Просмотреть файл

@ -1,159 +0,0 @@
/* cairo - a vector graphics library with display and print output
*
* Copyright © 2005 Red Hat, Inc
*
* This library is free software; you can redistribute it and/or
* modify it either under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation
* (the "LGPL") or, at your option, under the terms of the Mozilla
* Public License Version 1.1 (the "MPL"). If you do not alter this
* notice, a recipient may use your version of this file under either
* the MPL or the LGPL.
*
* You should have received a copy of the LGPL along with this library
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* You should have received a copy of the MPL along with this library
* in the file COPYING-MPL-1.1
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
* the specific language governing rights and limitations.
*
* The Original Code is the cairo graphics library.
*
* The Initial Developer of the Original Code is NVIDIA Corporation.
*
* Contributor(s):
*/
#ifndef CAIRO_DDRAW_PRIVATE_H
#define CAIRO_DDRAW_PRIVATE_H
#include "cairo-ddraw.h"
#include "cairoint.h"
#include "cairo-region-private.h"
#ifdef CAIRO_DDRAW_USE_GL
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#endif
#define CAIRO_DDRAW_FILL_ACCELERATION
#undef CAIRO_DDRAW_CREATE_SIMILAR
#undef CAIRO_DDRAW_CLONE_SIMILAR
#ifdef CAIRO_DDRAW_USE_GL
/* these paths need GL */
#define CAIRO_DDRAW_FONT_ACCELERATION
#define CAIRO_DDRAW_COMPOSITE_ACCELERATION
#endif /* CAIRO_DDRAW_USE_GL */
#ifdef CAIRO_DDRAW_USE_GL
#define CAIRO_DDRAW_FILL_THRESHOLD 32
#else
#define CAIRO_DDRAW_FILL_THRESHOLD 1024
#endif
typedef struct _cairo_ddraw_surface cairo_ddraw_surface_t;
struct _cairo_ddraw_surface {
/*
* fields that apply to all surfaces (roots and aliases)
*/
/* base surface object */
cairo_surface_t base;
/* cairo format */
cairo_format_t format;
/* pointer to root surface (in root points to itself) */
cairo_ddraw_surface_t *root;
/* origin of surface relative to root */
cairo_point_int_t origin;
/* image surface alias (may be NULL until created) */
cairo_surface_t *image;
/* data offset of image relative to root (0 in root) */
uint32_t data_offset;
/* valid image extents. in aliases, may be clipped by root */
cairo_rectangle_int_t extents;
/* current clip region, translated by extents */
cairo_region_t clip_region;
/* direct-draw clipper object for surface */
LPDIRECTDRAWCLIPPER lpddc;
/*
* fields that are copied to aliases (not addref'ed)
*/
/* pointer to direct draw */
LPDIRECTDRAW lpdd;
/* pointer to root surface */
LPDIRECTDRAWSURFACE lpdds;
/*
* fields that apply only to the root
*/
/* currently-installed clipper object (not addref'ed) */
LPDIRECTDRAWCLIPPER installed_clipper;
#ifdef CAIRO_DDRAW_USE_GL
/* gl id for texture, renderbuffer and fbo */
GLuint gl_id;
#endif /* CAIRO_DDRAW_USE_GL */
/*
* bitfield flags that apply only to the root
*/
/* surface is a ddraw surface, and locked */
cairo_bool_t locked : 1;
#ifdef CAIRO_DDRAW_USE_GL
/* has been rendered to by GL, needs a glFinish() */
cairo_bool_t dirty : 1;
#endif /* CAIRO_DDRAW_USE_GL */
/*
* bitfield flags that apply to all surfaces
*/
/* we have a non-NULL clip region (in clip_region) */
cairo_bool_t has_clip_region : 1;
/* clip region has been set to image surface */
cairo_bool_t has_image_clip : 1;
/* image clip doesn't match region */
cairo_bool_t image_clip_invalid : 1;
/* clip list doesn't match region */
cairo_bool_t clip_list_invalid : 1;
};
#endif /* CAIRO_DDRAW_PRIVATE_H */

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -38,37 +38,4 @@
#include "cairo.h"
#if CAIRO_HAS_DDRAW_SURFACE
#include <windows.h>
#include <ddraw.h>
CAIRO_BEGIN_DECLS
cairo_public cairo_surface_t *
cairo_ddraw_surface_create (LPDIRECTDRAW lpdd,
cairo_format_t format,
int width,
int height);
cairo_public cairo_surface_t *
cairo_ddraw_surface_create_alias (cairo_surface_t *surface,
int x,
int y,
int width,
int height);
cairo_public LPDIRECTDRAWSURFACE
cairo_ddraw_surface_get_ddraw_surface (cairo_surface_t *surface);
cairo_public cairo_surface_t *
cairo_ddraw_surface_get_image (cairo_surface_t *surface);
CAIRO_END_DECLS
#else /* CAIRO_HAS_DDRAW_SURFACE */
# error Cairo was not compiled with support for the direct draw backend
#endif /* CAIRO_HAS_DDRAW_SURFACE */
#endif /* _CAIRO_DDRAW_H_ */

Просмотреть файл

@ -1962,7 +1962,6 @@ cairo_surface_status (cairo_surface_t *surface);
* @CAIRO_SURFACE_TYPE_TEE: The surface is of type 'tee' (a multiplexing surface), since 1.10
* @CAIRO_SURFACE_TYPE_XML: The surface is of type XML (for debugging), since 1.10
* @CAIRO_SURFACE_TYPE_SKIA: The surface is of type Skia, since 1.10
* @CAIRO_SURFACE_TYPE_DDRAW: The surface is of type ddraw
*
* #cairo_surface_type_t is used to describe the type of a given
* surface. The surface types are also known as "backends" or "surface
@ -2011,7 +2010,6 @@ typedef enum _cairo_surface_type {
CAIRO_SURFACE_TYPE_TEE,
CAIRO_SURFACE_TYPE_XML,
CAIRO_SURFACE_TYPE_SKIA,
CAIRO_SURFACE_TYPE_DDRAW,
CAIRO_SURFACE_TYPE_D2D
} cairo_surface_type_t;

Просмотреть файл

@ -153,7 +153,6 @@ ifdef WINCE
EXPORTS += \
gfxFT2Fonts.h \
gfxFT2FontBase.h \
gfxDDrawSurface.h \
$(NULL)
else
EXPORTS += \
@ -246,7 +245,6 @@ ifdef WINCE
CPPSRCS += gfxFT2Fonts.cpp \
gfxFT2FontBase.cpp \
gfxFT2Utils.cpp \
gfxDDrawSurface.cpp \
gfxFT2FontList.cpp \
$(NULL)

Просмотреть файл

@ -69,10 +69,6 @@
#include "gfxQPainterSurface.h"
#endif
#ifdef CAIRO_HAS_DDRAW_SURFACE
#include "gfxDDrawSurface.h"
#endif
#include <stdio.h>
#include <limits.h>
@ -195,11 +191,6 @@ gfxASurface::Wrap (cairo_surface_t *csurf)
else if (stype == CAIRO_SURFACE_TYPE_QT) {
result = new gfxQPainterSurface(csurf);
}
#endif
#ifdef CAIRO_HAS_DDRAW_SURFACE
else if (stype == CAIRO_SURFACE_TYPE_DDRAW) {
result = new gfxDDrawSurface(csurf);
}
#endif
else {
result = new gfxUnknownSurface(csurf);
@ -481,7 +472,6 @@ static const char *sSurfaceNamesForSurfaceType[] = {
"gfx/surface/tee",
"gfx/surface/xml",
"gfx/surface/skia",
"gfx/surface/ddraw",
"gfx/surface/d2d"
};

Просмотреть файл

@ -96,7 +96,6 @@ public:
SurfaceTypeTee,
SurfaceTypeXML,
SurfaceTypeSkia,
SurfaceTypeDDraw,
SurfaceTypeD2D,
SurfaceTypeMax
} gfxSurfaceType;

Просмотреть файл

@ -1,123 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Oracle Corporation code.
*
* The Initial Developer of the Original Code is Oracle Corporation.
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@pavlov.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "gfxDDrawSurface.h"
#include "gfxContext.h"
#include "gfxPlatform.h"
#include "cairo.h"
#include "cairo-ddraw.h"
#include "nsString.h"
gfxDDrawSurface::gfxDDrawSurface(LPDIRECTDRAW lpdd,
const gfxIntSize& size, gfxImageFormat imageFormat)
{
if (!CheckSurfaceSize(size))
return;
cairo_surface_t *surf = cairo_ddraw_surface_create(lpdd, (cairo_format_t)imageFormat,
size.width, size.height);
Init(surf);
}
gfxDDrawSurface::gfxDDrawSurface(gfxDDrawSurface * psurf, const RECT & rect)
{
cairo_surface_t *surf = cairo_ddraw_surface_create_alias(psurf->CairoSurface(),
rect.left, rect.top,
rect.right - rect.left,
rect.bottom - rect.top);
Init(surf);
}
gfxDDrawSurface::gfxDDrawSurface(cairo_surface_t *csurf)
{
Init(csurf, PR_TRUE);
}
gfxDDrawSurface::~gfxDDrawSurface()
{
}
LPDIRECTDRAWSURFACE gfxDDrawSurface::GetDDSurface()
{
return cairo_ddraw_surface_get_ddraw_surface(CairoSurface());
}
already_AddRefed<gfxImageSurface>
gfxDDrawSurface::GetAsImageSurface()
{
cairo_surface_t *isurf = cairo_ddraw_surface_get_image(CairoSurface());
if (!isurf)
return nsnull;
nsRefPtr<gfxASurface> asurf = gfxASurface::Wrap(isurf);
gfxImageSurface *imgsurf = (gfxImageSurface*) asurf.get();
NS_ADDREF(imgsurf);
return imgsurf;
}
nsresult gfxDDrawSurface::BeginPrinting(const nsAString& aTitle,
const nsAString& aPrintToFileName)
{
return NS_OK;
}
nsresult gfxDDrawSurface::EndPrinting()
{
return NS_OK;
}
nsresult gfxDDrawSurface::AbortPrinting()
{
return NS_OK;
}
nsresult gfxDDrawSurface::BeginPage()
{
return NS_OK;
}
nsresult gfxDDrawSurface::EndPage()
{
return NS_OK;
}
PRInt32 gfxDDrawSurface::GetDefaultContextFlags() const
{
return 0;
}

Просмотреть файл

@ -1,71 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Oracle Corporation code.
*
* The Initial Developer of the Original Code is Oracle Corporation.
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@pavlov.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef GFX_DDRAWSURFACE_H
#define GFX_DDRAWSURFACE_H
#include "gfxASurface.h"
#include "gfxImageSurface.h"
#include <windows.h>
#include <ddraw.h>
class THEBES_API gfxDDrawSurface : public gfxASurface {
public:
gfxDDrawSurface(LPDIRECTDRAW lpdd, const gfxIntSize& size,
gfxImageFormat imageFormat = ImageFormatRGB24);
gfxDDrawSurface(gfxDDrawSurface * psurf, const RECT & rect);
gfxDDrawSurface(cairo_surface_t *csurf);
LPDIRECTDRAWSURFACE GetDDSurface();
virtual ~gfxDDrawSurface();
already_AddRefed<gfxImageSurface> GetAsImageSurface();
nsresult BeginPrinting(const nsAString& aTitle, const nsAString& aPrintToFileName);
nsresult EndPrinting();
nsresult AbortPrinting();
nsresult BeginPage();
nsresult EndPage();
virtual PRInt32 GetDefaultContextFlags() const;
};
#endif /* GFX_DDRAWSURFACE_H */

Просмотреть файл

@ -147,10 +147,6 @@ NS_IMPL_ISUPPORTS1(D2DVRAMReporter, nsIMemoryReporter)
#ifdef WINCE
#include <shlwapi.h>
#ifdef CAIRO_HAS_DDRAW_SURFACE
#include "gfxDDrawSurface.h"
#endif
#endif
#include "gfxUserFontSet.h"
@ -448,11 +444,6 @@ gfxWindowsPlatform::CreateOffscreenSurface(const gfxIntSize& size,
{
gfxASurface *surf = nsnull;
#ifdef CAIRO_HAS_DDRAW_SURFACE
if (mRenderMode == RENDER_DDRAW || mRenderMode == RENDER_DDRAW_GL)
surf = new gfxDDrawSurface(NULL, size, gfxASurface::FormatFromContent(contentType));
#endif
#ifdef CAIRO_HAS_WIN32_SURFACE
if (mRenderMode == RENDER_GDI)
surf = new gfxWindowsSurface(size, gfxASurface::FormatFromContent(contentType));

Просмотреть файл

@ -45,7 +45,7 @@
/**
* XXX to get CAIRO_HAS_DDRAW_SURFACE, CAIRO_HAS_D2D_SURFACE and
* XXX to get CAIRO_HAS_D2D_SURFACE and
* CAIRO_HAS_DWRITE_FONT
*/
#include "cairo.h"

Просмотреть файл

@ -48,13 +48,8 @@
static PRBool gDisableOptimize = PR_FALSE;
/*XXX get CAIRO_HAS_DDRAW_SURFACE */
#include "cairo.h"
#ifdef CAIRO_HAS_DDRAW_SURFACE
#include "gfxDDrawSurface.h"
#endif
#if defined(XP_WIN) || defined(WINCE)
#include "gfxWindowsPlatform.h"
#endif

Просмотреть файл

@ -380,9 +380,6 @@ protected:
void OnSettingsChange(WPARAM wParam, LPARAM lParam);
PRBool OnPaint(HDC aDC, PRUint32 aNestingLevel);
void OnWindowPosChanged(WINDOWPOS *wp, PRBool& aResult);
#if defined(CAIRO_HAS_DDRAW_SURFACE)
PRBool OnPaintImageDDraw16();
#endif // defined(CAIRO_HAS_DDRAW_SURFACE)
PRBool OnMouseWheel(UINT msg, WPARAM wParam, LPARAM lParam,
PRBool& result, PRBool& getWheelInfo,
LRESULT *aRetValue);

Просмотреть файл

@ -115,16 +115,6 @@ static gfxIntSize sSharedSurfaceSize;
*
**************************************************************/
#ifdef CAIRO_HAS_DDRAW_SURFACE
// XXX Still need to handle clean-up!!
static LPDIRECTDRAW glpDD = NULL;
static LPDIRECTDRAWSURFACE glpDDPrimary = NULL;
static LPDIRECTDRAWCLIPPER glpDDClipper = NULL;
static LPDIRECTDRAWSURFACE glpDDSecondary = NULL;
static nsAutoPtr<gfxDDrawSurface> gpDDSurf = NULL;
static DDSURFACEDESC gDDSDSecondary;
#endif
static NS_DEFINE_CID(kRegionCID, NS_REGION_CID);
static NS_DEFINE_IID(kRenderingContextCID, NS_RENDERING_CONTEXT_CID);
@ -174,50 +164,6 @@ nsWindowGfx::ConvertHRGNToRegion(HRGN aRgn)
return rgn;
}
#ifdef CAIRO_HAS_DDRAW_SURFACE
PRBool
nsWindowGfx::InitDDraw()
{
HRESULT hr;
hr = DirectDrawCreate(NULL, &glpDD, NULL);
NS_ENSURE_SUCCESS(hr, PR_FALSE);
hr = glpDD->SetCooperativeLevel(NULL, DDSCL_NORMAL);
NS_ENSURE_SUCCESS(hr, PR_FALSE);
DDSURFACEDESC ddsd;
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
hr = glpDD->CreateSurface(&ddsd, &glpDDPrimary, NULL);
NS_ENSURE_SUCCESS(hr, PR_FALSE);
hr = glpDD->CreateClipper(0, &glpDDClipper, NULL);
NS_ENSURE_SUCCESS(hr, PR_FALSE);
hr = glpDDPrimary->SetClipper(glpDDClipper);
NS_ENSURE_SUCCESS(hr, PR_FALSE);
// We do not use the cairo ddraw surface for IMAGE_DDRAW16. Instead, we
// use an 24bpp image surface, convert that to 565, then blit using ddraw.
if (!IsRenderMode(gfxWindowsPlatform::RENDER_IMAGE_DDRAW16)) {
gfxIntSize screen_size(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
gpDDSurf = new gfxDDrawSurface(glpDD, screen_size, gfxASurface::ImageFormatRGB24);
if (!gpDDSurf) {
/*XXX*/
fprintf(stderr, "couldn't create ddsurf\n");
return PR_FALSE;
}
}
return PR_TRUE;
}
#endif
/**************************************************************
**************************************************************
**
@ -354,12 +300,6 @@ PRBool nsWindow::OnPaint(HDC aDC, PRUint32 aNestingLevel)
willPaintEvent.willSendDidPaint = PR_TRUE;
DispatchWindowEvent(&willPaintEvent);
#ifdef CAIRO_HAS_DDRAW_SURFACE
if (IsRenderMode(gfxWindowsPlatform::RENDER_IMAGE_DDRAW16)) {
return OnPaintImageDDraw16();
}
#endif
PRBool result = PR_TRUE;
PAINTSTRUCT ps;
nsEventStatus eventStatus = nsEventStatus_eIgnore;
@ -464,32 +404,6 @@ PRBool nsWindow::OnPaint(HDC aDC, PRUint32 aNestingLevel)
}
targetSurface = mD2DWindowSurface;
}
#endif
#ifdef CAIRO_HAS_DDRAW_SURFACE
nsRefPtr<gfxDDrawSurface> targetSurfaceDDraw;
if (!targetSurface &&
(IsRenderMode(gfxWindowsPlatform::RENDER_DDRAW) ||
IsRenderMode(gfxWindowsPlatform::RENDER_DDRAW_GL)))
{
if (!glpDD) {
if (!nsWindowGfx::InitDDraw()) {
NS_WARNING("DirectDraw init failed; falling back to RENDER_IMAGE_STRETCH24");
gfxWindowsPlatform::GetPlatform()->SetRenderMode(gfxWindowsPlatform::RENDER_IMAGE_STRETCH24);
goto DDRAW_FAILED;
}
}
// create a rect that maps the window in screen space
// create a new sub-surface that aliases this one
RECT winrect;
GetClientRect(mWnd, &winrect);
MapWindowPoints(mWnd, NULL, (LPPOINT)&winrect, 2);
targetSurfaceDDraw = new gfxDDrawSurface(gpDDSurf.get(), winrect);
targetSurface = targetSurfaceDDraw;
}
DDRAW_FAILED:
#endif
nsRefPtr<gfxImageSurface> targetSurfaceImage;
if (!targetSurface &&
@ -590,29 +504,6 @@ DDRAW_FAILED:
if (IsRenderMode(gfxWindowsPlatform::RENDER_DDRAW) ||
IsRenderMode(gfxWindowsPlatform::RENDER_DDRAW_GL))
{
#ifdef CAIRO_HAS_DDRAW_SURFACE
// blit with direct draw
HRESULT hr = glpDDClipper->SetHWnd(0, mWnd);
#ifdef DEBUG
if (FAILED(hr))
DDError("SetHWnd", hr);
#endif
// blt from the affected area from the window back-buffer to the
// screen-relative coordinates of the window paint area
RECT dst_rect = ps.rcPaint;
MapWindowPoints(mWnd, NULL, (LPPOINT)&dst_rect, 2);
hr = glpDDPrimary->Blt(&dst_rect,
gpDDSurf->GetDDSurface(),
&dst_rect,
DDBLT_WAITNOTBUSY,
NULL);
#ifdef DEBUG
if (FAILED(hr))
DDError("SetHWnd", hr);
#endif
#endif
} else if (IsRenderMode(gfxWindowsPlatform::RENDER_IMAGE_STRETCH24) ||
IsRenderMode(gfxWindowsPlatform::RENDER_IMAGE_STRETCH32))
{
@ -959,159 +850,3 @@ HBITMAP nsWindowGfx::DataToBitmap(PRUint8* aImageData,
return nsnull;
#endif
}
// Windows Mobile Special image/direct draw painting fun
#if defined(CAIRO_HAS_DDRAW_SURFACE)
PRBool nsWindow::OnPaintImageDDraw16()
{
PRBool result = PR_FALSE;
PAINTSTRUCT ps;
nsPaintEvent event(PR_TRUE, NS_PAINT, this);
gfxIntSize surfaceSize;
nsRefPtr<gfxImageSurface> targetSurfaceImage;
nsRefPtr<gfxContext> thebesContext;
nsEventStatus eventStatus = nsEventStatus_eIgnore;
gfxIntSize newSize;
newSize.height = GetSystemMetrics(SM_CYSCREEN);
newSize.width = GetSystemMetrics(SM_CXSCREEN);
mPainting = PR_TRUE;
HDC hDC = ::BeginPaint(mWnd, &ps);
mPaintDC = hDC;
nsIntRegion paintRgn = GetRegionToPaint(PR_FALSE, ps, hDC);
if (paintRgn.IsEmpty() || !mEventCallback) {
result = PR_TRUE;
goto cleanup;
}
InitEvent(event);
if (!glpDD) {
if (!nsWindowGfx::InitDDraw()) {
NS_WARNING("DirectDraw init failed. Giving up.");
goto cleanup;
}
}
if (!glpDDSecondary) {
memset(&gDDSDSecondary, 0, sizeof (gDDSDSecondary));
memset(&gDDSDSecondary.ddpfPixelFormat, 0, sizeof(gDDSDSecondary.ddpfPixelFormat));
gDDSDSecondary.dwSize = sizeof (gDDSDSecondary);
gDDSDSecondary.ddpfPixelFormat.dwSize = sizeof(gDDSDSecondary.ddpfPixelFormat);
gDDSDSecondary.dwFlags = DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT;
gDDSDSecondary.dwHeight = newSize.height;
gDDSDSecondary.dwWidth = newSize.width;
gDDSDSecondary.ddpfPixelFormat.dwFlags = DDPF_RGB;
gDDSDSecondary.ddpfPixelFormat.dwRGBBitCount = 16;
gDDSDSecondary.ddpfPixelFormat.dwRBitMask = 0xf800;
gDDSDSecondary.ddpfPixelFormat.dwGBitMask = 0x07e0;
gDDSDSecondary.ddpfPixelFormat.dwBBitMask = 0x001f;
HRESULT hr = glpDD->CreateSurface(&gDDSDSecondary, &glpDDSecondary, 0);
if (FAILED(hr)) {
#ifdef DEBUG
DDError("CreateSurface renderer", hr);
#endif
goto cleanup;
}
}
PRInt32 brx = paintRgn.GetBounds().x;
PRInt32 bry = paintRgn.GetBounds().y;
PRInt32 brw = paintRgn.GetBounds().width;
PRInt32 brh = paintRgn.GetBounds().height;
surfaceSize = gfxIntSize(brw, brh);
if (!EnsureSharedSurfaceSize(surfaceSize))
goto cleanup;
targetSurfaceImage = new gfxImageSurface(sSharedSurfaceData.get(),
surfaceSize,
surfaceSize.width * 4,
gfxASurface::ImageFormatRGB24);
if (!targetSurfaceImage || targetSurfaceImage->CairoStatus())
goto cleanup;
targetSurfaceImage->SetDeviceOffset(gfxPoint(-brx, -bry));
thebesContext = new gfxContext(targetSurfaceImage);
thebesContext->SetFlag(gfxContext::FLAG_SIMPLIFY_OPERATORS);
{
AutoLayerManagerSetup setupLayerManager(this, thebesContext);
event.region = paintRgn;
result = DispatchWindowEvent(&event, eventStatus);
}
if (!result && eventStatus == nsEventStatus_eConsumeNoDefault)
goto cleanup;
HRESULT hr = glpDDSecondary->Lock(0, &gDDSDSecondary, DDLOCK_WAITNOTBUSY | DDLOCK_DISCARD, 0);
if (FAILED(hr))
goto cleanup;
pixman_image_t *srcPixmanImage =
pixman_image_create_bits(PIXMAN_x8r8g8b8, surfaceSize.width,
surfaceSize.height,
(uint32_t*) sSharedSurfaceData.get(),
surfaceSize.width * 4);
pixman_image_t *dstPixmanImage =
pixman_image_create_bits(PIXMAN_r5g6b5, gDDSDSecondary.dwWidth,
gDDSDSecondary.dwHeight,
(uint32_t*) gDDSDSecondary.lpSurface,
gDDSDSecondary.dwWidth * 2);
const nsIntRect* r;
for (nsIntRegionRectIterator iter(paintRgn);
(r = iter.Next()) != nsnull;) {
pixman_image_composite(PIXMAN_OP_SRC, srcPixmanImage, NULL, dstPixmanImage,
r->x - brx, r->y - bry,
0, 0,
r->x, r->y,
r->width, r->height);
}
pixman_image_unref(dstPixmanImage);
pixman_image_unref(srcPixmanImage);
hr = glpDDSecondary->Unlock(0);
if (FAILED(hr))
goto cleanup;
hr = glpDDClipper->SetHWnd(0, mWnd);
if (FAILED(hr))
goto cleanup;
for (nsIntRegionRectIterator iter(paintRgn);
(r = iter.Next()) != nsnull;) {
RECT wr = { r->x, r->y, r->XMost(), r->YMost() };
RECT renderRect = wr;
SetLastError(0); // See http://msdn.microsoft.com/en-us/library/dd145046%28VS.85%29.aspx
MapWindowPoints(mWnd, 0, (LPPOINT)&renderRect, 2);
hr = glpDDPrimary->Blt(&renderRect, glpDDSecondary, &wr, 0, NULL);
if (FAILED(hr)) {
NS_ERROR("this blt should never fail!");
printf("#### %s blt failed: %08lx", __FUNCTION__, hr);
}
}
result = PR_TRUE;
cleanup:
NS_ASSERTION(result == PR_TRUE, "fatal drawing error");
::EndPaint(mWnd, &ps);
mPaintDC = nsnull;
mPainting = PR_FALSE;
return result;
}
#endif // defined(CAIRO_HAS_DDRAW_SURFACE)

Просмотреть файл

@ -50,10 +50,6 @@
// the DirectDraw surface or not.
#include "cairo-features.h"
#ifdef CAIRO_HAS_DDRAW_SURFACE
#include "gfxDDrawSurface.h"
#endif
class nsWindowGfx {
public:
static nsIntRect ToIntRect(const RECT& aRect)
@ -65,10 +61,6 @@ public:
static nsIntRegion ConvertHRGNToRegion(HRGN aRgn);
static void OnSettingsChangeGfx(WPARAM wParam);
#if defined(CAIRO_HAS_DDRAW_SURFACE)
static PRBool InitDDraw();
#endif // defined(CAIRO_HAS_DDRAW_SURFACE)
static nsresult CreateIcon(imgIContainer *aContainer, PRBool aIsCursor, PRUint32 aHotspotX, PRUint32 aHotspotY, HICON *aIcon);
private: