mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
fix thebes gfxPattern refcounting; add coord space transforms for Rects; fix packed-color conversion.. notpartofthebuild
This commit is contained in:
parent
feeb5a5609
commit
380e5a443f
@ -27,7 +27,7 @@ EXPORTS += gfxWindowsSurface.h
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(MOZ_GFX_TOOLKIT),gtk2)
|
ifeq ($(MOZ_GFX_TOOLKIT),gtk2)
|
||||||
EXPORTS += gfxXlibSurface.h
|
EXPORTS += gfxXlibSurface.h
|
||||||
endif
|
endif
|
||||||
|
|
||||||
include $(topsrcdir)/config/rules.mk
|
include $(topsrcdir)/config/rules.mk
|
||||||
|
@ -50,11 +50,14 @@ public:
|
|||||||
cairo_surface_t* CairoSurface() { return mSurface; }
|
cairo_surface_t* CairoSurface() { return mSurface; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void Init(cairo_surface_t *surface) {
|
cairo_surface_t* mSurface;
|
||||||
|
|
||||||
|
void Init(cairo_surface_t* surface) {
|
||||||
mDestroyed = PR_FALSE;
|
mDestroyed = PR_FALSE;
|
||||||
mSurface = surface;
|
mSurface = surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PRBool mDestroyed;
|
||||||
void Destroy() {
|
void Destroy() {
|
||||||
if (mDestroyed) {
|
if (mDestroyed) {
|
||||||
NS_WARNING("Calling Destroy on an already-destroyed surface!");
|
NS_WARNING("Calling Destroy on an already-destroyed surface!");
|
||||||
@ -70,10 +73,6 @@ protected:
|
|||||||
NS_WARNING("gfxASurface::~gfxASurface called, but cairo surface was not destroyed! (Did someone forget to call Destroy()?)");
|
NS_WARNING("gfxASurface::~gfxASurface called, but cairo surface was not destroyed! (Did someone forget to call Destroy()?)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
|
||||||
cairo_surface_t *mSurface;
|
|
||||||
PRBool mDestroyed;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* GFX_ASURFACE_H */
|
#endif /* GFX_ASURFACE_H */
|
||||||
|
@ -49,10 +49,10 @@ struct gfxRGBA {
|
|||||||
gfxRGBA(const gfxRGBA& c) : r(c.r), g(c.g), b(c.b), a(c.a) {}
|
gfxRGBA(const gfxRGBA& c) : r(c.r), g(c.g), b(c.b), a(c.a) {}
|
||||||
gfxRGBA(gfxFloat _r, gfxFloat _g, gfxFloat _b, gfxFloat _a=1.0) : r(_r), g(_g), b(_b), a(_a) {}
|
gfxRGBA(gfxFloat _r, gfxFloat _g, gfxFloat _b, gfxFloat _a=1.0) : r(_r), g(_g), b(_b), a(_a) {}
|
||||||
gfxRGBA(PRUint32 c) {
|
gfxRGBA(PRUint32 c) {
|
||||||
a = (c & 0xff) / 255.0;
|
r = ((c >> 0) & 0xff) / 255.0;
|
||||||
r = ((c >> 8) & 0xff) / 255.0;
|
g = ((c >> 8) & 0xff) / 255.0;
|
||||||
g = ((c >> 16) & 0xff) / 255.0;
|
b = ((c >> 16) & 0xff) / 255.0;
|
||||||
b = ((c >> 24) & 0xff) / 255.0;
|
a = ((c >> 24) & 0xff) / 255.0;
|
||||||
}
|
}
|
||||||
gfxRGBA(const char* str) {
|
gfxRGBA(const char* str) {
|
||||||
a = 1.0;
|
a = 1.0;
|
||||||
|
@ -127,8 +127,10 @@ public:
|
|||||||
|
|
||||||
gfxPoint DeviceToUser(gfxPoint point) const;
|
gfxPoint DeviceToUser(gfxPoint point) const;
|
||||||
gfxSize DeviceToUser(gfxSize size) const;
|
gfxSize DeviceToUser(gfxSize size) const;
|
||||||
|
gfxRect DeviceToUser(gfxRect rect) const;
|
||||||
gfxPoint UserToDevice(gfxPoint point) const;
|
gfxPoint UserToDevice(gfxPoint point) const;
|
||||||
gfxSize UserToDevice(gfxSize size) const;
|
gfxSize UserToDevice(gfxSize size) const;
|
||||||
|
gfxRect UserToDevice(gfxRect rect) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
** Painting sources
|
** Painting sources
|
||||||
@ -139,7 +141,7 @@ public:
|
|||||||
void SetSource(gfxASurface *surface) {
|
void SetSource(gfxASurface *surface) {
|
||||||
SetSource(surface, gfxPoint(0, 0));
|
SetSource(surface, gfxPoint(0, 0));
|
||||||
}
|
}
|
||||||
void SetSource(gfxASurface* surface, gfxPoint origin);
|
void SetSource(gfxASurface* surface, gfxPoint offset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
** Painting
|
** Painting
|
||||||
|
@ -136,11 +136,11 @@ public:
|
|||||||
cairo_matrix_transform_point(&mat, x, y);
|
cairo_matrix_transform_point(&mat, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfxSize GetScale() const {
|
gfxSize GetScaling() const {
|
||||||
return gfxSize(mat.xx, mat.yy);
|
return gfxSize(mat.xx, mat.yy);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfxPoint GetTranslate() const {
|
gfxPoint GetTranslation() const {
|
||||||
return gfxPoint(mat.x0, mat.y0);
|
return gfxPoint(mat.x0, mat.y0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,6 +60,9 @@ struct gfxSize {
|
|||||||
gfxSize operator+(const gfxSize& s) const {
|
gfxSize operator+(const gfxSize& s) const {
|
||||||
return gfxSize(width + s.width, height + s.height);
|
return gfxSize(width + s.width, height + s.height);
|
||||||
}
|
}
|
||||||
|
gfxSize operator-() const {
|
||||||
|
return gfxSize(- width, - height);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct gfxPoint {
|
struct gfxPoint {
|
||||||
@ -89,6 +92,16 @@ struct gfxPoint {
|
|||||||
gfxPoint operator-(const gfxSize& s) const {
|
gfxPoint operator-(const gfxSize& s) const {
|
||||||
return gfxPoint(x - s.width, y - s.height);
|
return gfxPoint(x - s.width, y - s.height);
|
||||||
}
|
}
|
||||||
|
gfxPoint operator-(const gfxPoint& p) const {
|
||||||
|
return gfxPoint(x - p.x, y - p.y);
|
||||||
|
}
|
||||||
|
gfxPoint operator-(const gfxSize& s) const {
|
||||||
|
return gfxPoint(x - s.width, y - s.height);
|
||||||
|
}
|
||||||
|
gfxPoint operator-() const {
|
||||||
|
return gfxPoint(- x, - y);
|
||||||
|
}
|
||||||
|
|
||||||
gfxPoint& round() {
|
gfxPoint& round() {
|
||||||
x = ::floor(x + 0.5);
|
x = ::floor(x + 0.5);
|
||||||
y = ::floor(y + 0.5);
|
y = ::floor(y + 0.5);
|
||||||
|
@ -267,6 +267,14 @@ gfxSize gfxContext::DeviceToUser(gfxSize size) const
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gfxRect gfxContext::DeviceToUser(gfxRect rect) const
|
||||||
|
{
|
||||||
|
gfxRect ret = rect;
|
||||||
|
cairo_device_to_user(mCairo, &ret.pos.x, &ret.pos.y);
|
||||||
|
cairo_device_to_user_distance(mCairo, &ret.size.width, &ret.size.height);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
gfxPoint gfxContext::UserToDevice(gfxPoint point) const
|
gfxPoint gfxContext::UserToDevice(gfxPoint point) const
|
||||||
{
|
{
|
||||||
gfxPoint ret = point;
|
gfxPoint ret = point;
|
||||||
@ -281,6 +289,14 @@ gfxSize gfxContext::UserToDevice(gfxSize size) const
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gfxRect gfxContext::UserToDevice(gfxRect rect) const
|
||||||
|
{
|
||||||
|
gfxRect ret = rect;
|
||||||
|
cairo_user_to_device(mCairo, &ret.pos.x, &ret.pos.y);
|
||||||
|
cairo_user_to_device_distance(mCairo, &ret.size.width, &ret.size.height);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void gfxContext::SetAntialiasMode(AntialiasMode mode)
|
void gfxContext::SetAntialiasMode(AntialiasMode mode)
|
||||||
{
|
{
|
||||||
// XXX implement me
|
// XXX implement me
|
||||||
@ -376,7 +392,7 @@ void gfxContext::Clip(const gfxRegion& region)
|
|||||||
|
|
||||||
void gfxContext::Clip()
|
void gfxContext::Clip()
|
||||||
{
|
{
|
||||||
cairo_clip(mCairo);
|
cairo_clip_preserve(mCairo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxContext::ResetClip()
|
void gfxContext::ResetClip()
|
||||||
@ -397,9 +413,9 @@ void gfxContext::SetPattern(gfxPattern *pattern)
|
|||||||
cairo_set_source(mCairo, pattern->CairoPattern());
|
cairo_set_source(mCairo, pattern->CairoPattern());
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxContext::SetSource(gfxASurface *surface, gfxPoint origin)
|
void gfxContext::SetSource(gfxASurface *surface, gfxPoint offset)
|
||||||
{
|
{
|
||||||
cairo_set_source_surface(mCairo, surface->CairoSurface(), origin.x, origin.y);
|
cairo_set_source_surface(mCairo, surface->CairoSurface(), offset.x, offset.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// fonts?
|
// fonts?
|
||||||
|
40
gfx/thebes/src/gfxPattern.cpp
Normal file
40
gfx/thebes/src/gfxPattern.cpp
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/* -*- 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 "gfxPattern.h"
|
||||||
|
|
||||||
|
THEBES_IMPL_REFCOUNTING(gfxPattern)
|
Loading…
Reference in New Issue
Block a user