fix thebes gfxPattern refcounting; add coord space transforms for Rects; fix packed-color conversion.. notpartofthebuild

This commit is contained in:
vladimir%pobox.com 2005-07-02 01:05:26 +00:00
Родитель feeb5a5609
Коммит 380e5a443f
8 изменённых файлов: 86 добавлений и 16 удалений

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

@ -27,7 +27,7 @@ EXPORTS += gfxWindowsSurface.h
endif
ifeq ($(MOZ_GFX_TOOLKIT),gtk2)
EXPORTS += gfxXlibSurface.h
EXPORTS += gfxXlibSurface.h
endif
include $(topsrcdir)/config/rules.mk

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

@ -50,11 +50,14 @@ public:
cairo_surface_t* CairoSurface() { return mSurface; }
protected:
void Init(cairo_surface_t *surface) {
cairo_surface_t* mSurface;
void Init(cairo_surface_t* surface) {
mDestroyed = PR_FALSE;
mSurface = surface;
}
PRBool mDestroyed;
void Destroy() {
if (mDestroyed) {
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()?)");
}
}
protected:
cairo_surface_t *mSurface;
PRBool mDestroyed;
};
#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(gfxFloat _r, gfxFloat _g, gfxFloat _b, gfxFloat _a=1.0) : r(_r), g(_g), b(_b), a(_a) {}
gfxRGBA(PRUint32 c) {
a = (c & 0xff) / 255.0;
r = ((c >> 8) & 0xff) / 255.0;
g = ((c >> 16) & 0xff) / 255.0;
b = ((c >> 24) & 0xff) / 255.0;
r = ((c >> 0) & 0xff) / 255.0;
g = ((c >> 8) & 0xff) / 255.0;
b = ((c >> 16) & 0xff) / 255.0;
a = ((c >> 24) & 0xff) / 255.0;
}
gfxRGBA(const char* str) {
a = 1.0;

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

@ -127,8 +127,10 @@ public:
gfxPoint DeviceToUser(gfxPoint point) const;
gfxSize DeviceToUser(gfxSize size) const;
gfxRect DeviceToUser(gfxRect rect) const;
gfxPoint UserToDevice(gfxPoint point) const;
gfxSize UserToDevice(gfxSize size) const;
gfxRect UserToDevice(gfxRect rect) const;
/**
** Painting sources
@ -139,7 +141,7 @@ public:
void SetSource(gfxASurface *surface) {
SetSource(surface, gfxPoint(0, 0));
}
void SetSource(gfxASurface* surface, gfxPoint origin);
void SetSource(gfxASurface* surface, gfxPoint offset);
/**
** Painting

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

@ -136,11 +136,11 @@ public:
cairo_matrix_transform_point(&mat, x, y);
}
gfxSize GetScale() const {
gfxSize GetScaling() const {
return gfxSize(mat.xx, mat.yy);
}
gfxPoint GetTranslate() const {
gfxPoint GetTranslation() const {
return gfxPoint(mat.x0, mat.y0);
}

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

@ -60,6 +60,9 @@ struct gfxSize {
gfxSize operator+(const gfxSize& s) const {
return gfxSize(width + s.width, height + s.height);
}
gfxSize operator-() const {
return gfxSize(- width, - height);
}
};
struct gfxPoint {
@ -89,6 +92,16 @@ struct gfxPoint {
gfxPoint operator-(const gfxSize& s) const {
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() {
x = ::floor(x + 0.5);
y = ::floor(y + 0.5);

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

@ -267,6 +267,14 @@ gfxSize gfxContext::DeviceToUser(gfxSize size) const
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 ret = point;
@ -281,6 +289,14 @@ gfxSize gfxContext::UserToDevice(gfxSize size) const
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)
{
// XXX implement me
@ -376,7 +392,7 @@ void gfxContext::Clip(const gfxRegion& region)
void gfxContext::Clip()
{
cairo_clip(mCairo);
cairo_clip_preserve(mCairo);
}
void gfxContext::ResetClip()
@ -397,9 +413,9 @@ void gfxContext::SetPattern(gfxPattern *pattern)
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?

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

@ -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)