зеркало из https://github.com/mozilla/gecko-dev.git
Factor out the graphics state struct into its own header and implementation
files.
This commit is contained in:
Родитель
255cc6f2bd
Коммит
b4d5277467
|
@ -35,16 +35,18 @@ CXXFLAGS += $(TK_CFLAGS)
|
|||
INCLUDES += $(TK_CFLAGS) -I$(srcdir)/..
|
||||
|
||||
CPPSRCS = \
|
||||
nsDrawingSurfaceGTK.cpp \
|
||||
nsDeviceContextGTK.cpp \
|
||||
nsDeviceContextSpecFactoryG.cpp \
|
||||
nsDeviceContextSpecG.cpp \
|
||||
nsDrawingSurfaceGTK.cpp \
|
||||
nsFontMetricsGTK.cpp \
|
||||
nsGfxFactoryGTK.cpp \
|
||||
nsRenderingContextGTK.cpp \
|
||||
nsGraphicsStateGTK.cpp \
|
||||
nsImageGTK.cpp \
|
||||
nsRegionGTK.cpp \
|
||||
nsTimer.cpp
|
||||
nsRenderingContextGTK.cpp \
|
||||
nsTimer.cpp \
|
||||
$(NULL)
|
||||
|
||||
CSRCS = \
|
||||
nsPrintdGTK.c
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsGraphicsStateGTK.h"
|
||||
|
||||
nsGraphicsState::nsGraphicsState()
|
||||
{
|
||||
mMatrix = nsnull;
|
||||
mClipRegion = nsnull;
|
||||
mColor = NS_RGB(0, 0, 0);
|
||||
mLineStyle = nsLineStyle_kSolid;
|
||||
mFontMetrics = nsnull;
|
||||
}
|
||||
|
||||
nsGraphicsState::~nsGraphicsState()
|
||||
{
|
||||
NS_IF_RELEASE(mClipRegion);
|
||||
NS_IF_RELEASE(mFontMetrics);
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsGraphicsStateGTK_h___
|
||||
#define nsGraphicsStateGTK_h___
|
||||
|
||||
#include "nsIRenderingContext.h"
|
||||
#include "nsIFontMetrics.h"
|
||||
#include "nsTransform2D.h"
|
||||
#include "nsRegionGTK.h"
|
||||
|
||||
class nsGraphicsState
|
||||
{
|
||||
public:
|
||||
nsGraphicsState();
|
||||
virtual ~nsGraphicsState();
|
||||
|
||||
nsTransform2D *mMatrix;
|
||||
nsRegionGTK *mClipRegion;
|
||||
nscolor mColor;
|
||||
nsLineStyle mLineStyle;
|
||||
nsIFontMetrics *mFontMetrics;
|
||||
};
|
||||
|
||||
#endif /* nsGraphicsStateGTK_h___ */
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
#include "nsIRegion.h"
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
|
||||
class nsRegionGTK : public nsIRegion
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "nsFontMetricsGTK.h"
|
||||
#include "nsRenderingContextGTK.h"
|
||||
#include "nsRegionGTK.h"
|
||||
#include "nsGraphicsStateGTK.h"
|
||||
#include "nsGfxCIID.h"
|
||||
#include <math.h>
|
||||
|
||||
|
@ -36,35 +37,6 @@
|
|||
|
||||
static NS_DEFINE_IID(kRenderingContextIID, NS_IRENDERING_CONTEXT_IID);
|
||||
|
||||
class GraphicsState
|
||||
{
|
||||
public:
|
||||
GraphicsState();
|
||||
virtual ~GraphicsState();
|
||||
|
||||
nsTransform2D *mMatrix;
|
||||
nsRegionGTK *mClipRegion;
|
||||
nscolor mColor;
|
||||
nsLineStyle mLineStyle;
|
||||
nsIFontMetrics *mFontMetrics;
|
||||
};
|
||||
|
||||
GraphicsState::GraphicsState()
|
||||
{
|
||||
mMatrix = nsnull;
|
||||
mClipRegion = nsnull;
|
||||
mColor = NS_RGB(0, 0, 0);
|
||||
mLineStyle = nsLineStyle_kSolid;
|
||||
mFontMetrics = nsnull;
|
||||
}
|
||||
|
||||
GraphicsState::~GraphicsState()
|
||||
{
|
||||
NS_IF_RELEASE(mClipRegion);
|
||||
NS_IF_RELEASE(mFontMetrics);
|
||||
}
|
||||
|
||||
|
||||
nsRenderingContextGTK::nsRenderingContextGTK()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
@ -245,7 +217,7 @@ NS_IMETHODIMP nsRenderingContextGTK::GetDeviceContext(nsIDeviceContext *&aContex
|
|||
|
||||
NS_IMETHODIMP nsRenderingContextGTK::PushState(void)
|
||||
{
|
||||
GraphicsState *state = new GraphicsState();
|
||||
nsGraphicsState *state = new nsGraphicsState();
|
||||
|
||||
// Push into this state object, add to vector
|
||||
state->mMatrix = mTMatrix;
|
||||
|
@ -279,10 +251,10 @@ NS_IMETHODIMP nsRenderingContextGTK::PushState(void)
|
|||
NS_IMETHODIMP nsRenderingContextGTK::PopState(PRBool &aClipEmpty)
|
||||
{
|
||||
PRUint32 cnt = mStateCache->Count();
|
||||
GraphicsState * state;
|
||||
nsGraphicsState * state;
|
||||
|
||||
if (cnt > 0) {
|
||||
state = (GraphicsState *)mStateCache->ElementAt(cnt - 1);
|
||||
state = (nsGraphicsState *)mStateCache->ElementAt(cnt - 1);
|
||||
mStateCache->RemoveElementAt(cnt - 1);
|
||||
|
||||
// Assign all local attributes from the state object just popped
|
||||
|
|
Загрузка…
Ссылка в новой задаче