X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fsynfig%2Fsurface.cpp;h=f783d9ced706d51e81255aa48322c524fa3b9bd1;hb=c3ad95144d148602f672e95ddda1f18fc35502f8;hp=fb905b79ee24d4631f3de6d033038cd242508c0e;hpb=e3acc0b267b14fda5db3c7bbb2f218b993ef84b3;p=synfig.git diff --git a/synfig-core/trunk/src/synfig/surface.cpp b/synfig-core/trunk/src/synfig/surface.cpp index fb905b7..f783d9c 100644 --- a/synfig-core/trunk/src/synfig/surface.cpp +++ b/synfig-core/trunk/src/synfig/surface.cpp @@ -1,18 +1,22 @@ -/* ======================================================================== -** Sinfg -** Template File -** $Id: surface.cpp,v 1.1.1.1 2005/01/04 01:23:14 darco Exp $ +/* === S Y N F I G ========================================================= */ +/*! \file surface.cpp +** \brief Template File ** -** Copyright (c) 2002 Robert B. Quattlebaum Jr. +** $Id$ ** -** This software and associated documentation -** are CONFIDENTIAL and PROPRIETARY property of -** the above-mentioned copyright holder. +** \legal +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley ** -** You may not copy, print, publish, or in any -** other way distribute this software without -** a prior written agreement with -** the copyright holder. +** This package is free software; you can redistribute it and/or +** modify it under the terms of the GNU General Public License as +** published by the Free Software Foundation; either version 2 of +** the License, or (at your option) any later version. +** +** This package is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** General Public License for more details. +** \endlegal ** ** === N O T E S =========================================================== ** @@ -20,7 +24,7 @@ /* === H E A D E R S ======================================================= */ -#define SINFG_NO_ANGLE +#define SYNFIG_NO_ANGLE #ifdef USING_PCH # include "pch.h" @@ -40,7 +44,7 @@ #endif -using namespace sinfg; +using namespace synfig; using namespace std; using namespace etl; @@ -48,7 +52,7 @@ using namespace etl; /* === G L O B A L S ======================================================= */ -class target2surface : public sinfg::Target_Scanline +class target2surface : public synfig::Target_Scanline { public: Surface *surface; @@ -57,10 +61,10 @@ public: target2surface(Surface *surface); virtual ~target2surface(); - virtual bool set_rend_desc(sinfg::RendDesc *newdesc); - - virtual bool start_frame(sinfg::ProgressCallback *cb); - + virtual bool set_rend_desc(synfig::RendDesc *newdesc); + + virtual bool start_frame(synfig::ProgressCallback *cb); + virtual void end_frame(); virtual Color * start_scanline(int scanline); @@ -77,30 +81,30 @@ target2surface::~target2surface() } bool -target2surface::set_rend_desc(sinfg::RendDesc *newdesc) +target2surface::set_rend_desc(synfig::RendDesc *newdesc) { assert(newdesc); assert(surface); desc=*newdesc; - return sinfg::Target_Scanline::set_rend_desc(newdesc); + return synfig::Target_Scanline::set_rend_desc(newdesc); } - + bool -target2surface::start_frame(sinfg::ProgressCallback *cb) -{ +target2surface::start_frame(synfig::ProgressCallback */*cb*/) +{ if(surface->get_w() != desc.get_w() || surface->get_h() != desc.get_h()) { surface->set_wh(desc.get_w(),desc.get_h()); } - return true; + return true; } - + void target2surface::end_frame() { return; } - + Color * target2surface::start_scanline(int scanline) { @@ -118,13 +122,13 @@ target2surface::end_scanline() /* === M E T H O D S ======================================================= */ Target_Scanline::Handle -sinfg::surface_target(Surface *surface) +synfig::surface_target(Surface *surface) { return Target_Scanline::Handle(new target2surface(surface)); } void -sinfg::Surface::clear() +synfig::Surface::clear() { #ifdef HAS_VIMAGE fill(Color(0.5,0.5,0.5,0.0000001)); @@ -134,7 +138,7 @@ sinfg::Surface::clear() } void -sinfg::Surface::blit_to(alpha_pen& pen, int x, int y, int w, int h) +synfig::Surface::blit_to(alpha_pen& pen, int x, int y, int w, int h) { static const float epsilon(0.00001); const float alpha(pen.get_alpha()); @@ -147,26 +151,26 @@ sinfg::Surface::blit_to(alpha_pen& pen, int x, int y, int w, int h) if(x<0) { w+=x; //decrease - x=0; + x=0; } - + if(y<0) { h+=y; //decrease - y=0; + y=0; } - + //clip width against dest width - w = min(w,pen.end_x()-pen.x()); - h = min(h,pen.end_y()-pen.y()); - + w = min((long)w,(long)(pen.end_x()-pen.x())); + h = min((long)h,(long)(pen.end_y()-pen.y())); + //clip width against src width - w = min(w,get_w()-x); - h = min(h,get_h()-y); + w = min(w,get_w()-x); + h = min(h,get_h()-y); if(w<=0 || h<=0) return; - + for(int i=0;i(static_cast(operator[](y)+x))+i*get_w()*sizeof(Color)); @@ -175,8 +179,8 @@ sinfg::Surface::blit_to(alpha_pen& pen, int x, int y, int w, int h) } return; } - -#ifdef HAS_VIMAGE + +#ifdef HAS_VIMAGE if( pen.get_blend_method()==Color::BLEND_COMPOSITE && fabs(alpha-1.0f)=get_w() || y>=get_w()) @@ -187,23 +191,23 @@ sinfg::Surface::blit_to(alpha_pen& pen, int x, int y, int w, int h) { //u-=x; //increase w+=x; //decrease - x=0; + x=0; } - + if(y<0) { //v-=y; //increase h+=y; //decrease - y=0; + y=0; } - + //clip width against dest width w = min(w,pen.end_x()-pen.x()); h = min(h,pen.end_y()-pen.y()); - + //clip width against src width - w = min(w,get_w()-x); - h = min(h,get_h()-y); + w = min(w,get_w()-x); + h = min(h,get_h()-y); if(w<=0 || h<=0) return; @@ -212,7 +216,7 @@ sinfg::Surface::blit_to(alpha_pen& pen, int x, int y, int w, int h) vImage_Buffer top,bottom; vImage_Buffer& dest(bottom); - + top.data=static_cast(operator[](y)+x); top.height=h; top.width=w; @@ -224,12 +228,12 @@ sinfg::Surface::blit_to(alpha_pen& pen, int x, int y, int w, int h) bottom.width=w; //bottom.rowBytes=pen.get_width()*sizeof(Color); //! \fixme this should get the pitch!! bottom.rowBytes=pen.get_pitch(); //! \fixme this should get the pitch!! - + vImage_Error ret; ret=vImageAlphaBlend_ARGBFFFF(&top,&bottom,&dest,kvImageNoFlags); - + assert(ret!=kvImageNoError); - + return; } #endif