-** This software and associated documentation
-** are CONFIDENTIAL and PROPRIETARY property of
-** the above-mentioned 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.
-** 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 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.
void crop(int x, int y, int w, int h)
{
origin_=origin+y*stride_+x;
w_=w;
h_=h;
}
void crop(int x, int y, int w, int h)
{
origin_=origin+y*stride_+x;
w_=w;
h_=h;
}
SurfaceNew::create(int w, int h, ColorSystem sys=COLORSYS_RGB)
{
Handle ret(new SurfaceNew);
SurfaceNew::create(int w, int h, ColorSystem sys=COLORSYS_RGB)
{
Handle ret(new SurfaceNew);
ret.color_system_=orig.color_system_;
ret.premult_flag_=orig.premult_flag_;
ret.channel_map_=orig.channel_map_;
ret.color_system_=orig.color_system_;
ret.premult_flag_=orig.premult_flag_;
ret.channel_map_=orig.channel_map_;
SurfaceNew::crop(HandleConst, int x, int y, int w, int h)
{
Lock lock(orig);
SurfaceNew::crop(HandleConst, int x, int y, int w, int h)
{
Lock lock(orig);
std::map<Channel,ChannelData>::iterator iter;
for(iter=ret.channel_map_.begin();iter!=ret.channel_map_.end();++iter)
iter->crop(x,y,w,h);
std::map<Channel,ChannelData>::iterator iter;
for(iter=ret.channel_map_.begin();iter!=ret.channel_map_.end();++iter)
iter->crop(x,y,w,h);
{
// This operation is rather expensive, as it should be.
// I want to discurage people from using it all over the place.
{
// This operation is rather expensive, as it should be.
// I want to discurage people from using it all over the place.
Color ret(
lock_channel_const(CHAN_R).get_value(x,y),
lock_channel_const(CHAN_G).get_value(x,y),
lock_channel_const(CHAN_B).get_value(x,y),
lock_channel_const(CHAN_A).get_value(x,y)
);
Color ret(
lock_channel_const(CHAN_R).get_value(x,y),
lock_channel_const(CHAN_G).get_value(x,y),
lock_channel_const(CHAN_B).get_value(x,y),
lock_channel_const(CHAN_A).get_value(x,y)
);
channel_lock.surface_=this;
channel_lock.channel_=chan;
channel_map_[chan].rw_lock.writer_lock();
channel_lock.surface_=this;
channel_lock.channel_=chan;
channel_map_[chan].rw_lock.writer_lock();
channel_map_[chan].set_wh(get_w(),get_h());
ChannelLockConst channel_lock;
channel_map_[chan].set_wh(get_w(),get_h());
ChannelLockConst channel_lock;
channel_lock.surface_=this;
channel_lock.channel_=chan;
channel_map_[chan].rw_lock.reader_lock();
channel_lock.surface_=this;
channel_lock.channel_=chan;
channel_map_[chan].rw_lock.reader_lock();
// If this channel isn't defined, then
// skip it and move on to the next one
if(!is_channel_defined(chan))
continue;
// If this channel isn't defined, then
// skip it and move on to the next one
if(!is_channel_defined(chan))
continue;
ChannelLock color_channel(lock_channel(chan));
ChannelLockConst alpha_channel(lock_channel_alpha_const(chan));
const int w(get_w());
const int h(get_h());
ChannelLock color_channel(lock_channel(chan));
ChannelLockConst alpha_channel(lock_channel_alpha_const(chan));
const int w(get_w());
const int h(get_h());
float* color_ptr(color_channel.get_data_ptr());
const float* alpha_ptr(alpha_channel.get_data_ptr());
float* color_ptr(color_channel.get_data_ptr());
const float* alpha_ptr(alpha_channel.get_data_ptr());
const int color_pitch(color_channel.get_data_ptr_stride()-w);
const int alpha_pitch(alpha_channel.get_data_ptr_stride()-w);
const int color_pitch(color_channel.get_data_ptr_stride()-w);
const int alpha_pitch(alpha_channel.get_data_ptr_stride()-w);
dest=crop(dest,x_dest,y_dest,w,h);
if(bm==Color::BLEND_STRAIGHT)
dest=crop(dest,x_dest,y_dest,w,h);
if(bm==Color::BLEND_STRAIGHT)
if(surface_ && ref_count_.is_unique())
return surface->channel_map_[channel_].rw_lock.reader_unlock();
surface=0;
if(surface_ && ref_count_.is_unique())
return surface->channel_map_[channel_].rw_lock.reader_unlock();
surface=0;
const int w(dest.get_w());
const int h(dest.get_h());
const int pitch(dest.get_data_pitch()-w);
const int w(dest.get_w());
const int h(dest.get_h());
const int pitch(dest.get_data_pitch()-w);
const int h(dest.get_h());
const int d_pitch(dest.get_data_stride()-w);
const int s_pitch(x.get_data_stride()-w);
const int h(dest.get_h());
const int d_pitch(dest.get_data_stride()-w);
const int s_pitch(x.get_data_stride()-w);
int(y=0;y<h;y++,d_ptr+=d_pitch,s_ptr+=s_pitch)
int(x=0;x<w;x++,d_ptr++,s_ptr++)
*d_ptr *= *s_ptr;
int(y=0;y<h;y++,d_ptr+=d_pitch,s_ptr+=s_pitch)
int(x=0;x<w;x++,d_ptr++,s_ptr++)
*d_ptr *= *s_ptr;
const int w(dest.get_w());
const int h(dest.get_h());
const int pitch(dest.get_data_pitch()-w);
const int w(dest.get_w());
const int h(dest.get_h());
const int pitch(dest.get_data_pitch()-w);
const int h(dest.get_h());
const int d_pitch(dest.get_data_stride()-w);
const int s_pitch(x.get_data_stride()-w);
const int h(dest.get_h());
const int d_pitch(dest.get_data_stride()-w);
const int s_pitch(x.get_data_stride()-w);
int(y=0;y<h;y++,d_ptr+=d_pitch,s_ptr+=s_pitch)
int(x=0;x<w;x++,d_ptr++,s_ptr++)
*d_ptr /= *s_ptr;
int(y=0;y<h;y++,d_ptr+=d_pitch,s_ptr+=s_pitch)
int(x=0;x<w;x++,d_ptr++,s_ptr++)
*d_ptr /= *s_ptr;
const int w(dest.get_w());
const int h(dest.get_h());
const int pitch(dest.get_data_pitch()-w);
const int w(dest.get_w());
const int h(dest.get_h());
const int pitch(dest.get_data_pitch()-w);
const int h(dest.get_h());
const int d_pitch(dest.get_data_stride()-w);
const int s_pitch(x.get_data_stride()-w);
const int h(dest.get_h());
const int d_pitch(dest.get_data_stride()-w);
const int s_pitch(x.get_data_stride()-w);
int(y=0;y<h;y++,d_ptr+=d_pitch,s_ptr+=s_pitch)
int(x=0;x<w;x++,d_ptr++,s_ptr++)
*d_ptr += *s_ptr;
int(y=0;y<h;y++,d_ptr+=d_pitch,s_ptr+=s_pitch)
int(x=0;x<w;x++,d_ptr++,s_ptr++)
*d_ptr += *s_ptr;
const int w(dest.get_w());
const int h(dest.get_h());
const int pitch(dest.get_data_pitch()-w);
const int w(dest.get_w());
const int h(dest.get_h());
const int pitch(dest.get_data_pitch()-w);
const int h(dest.get_h());
const int d_pitch(dest.get_data_stride()-w);
const int s_pitch(x.get_data_stride()-w);
const int h(dest.get_h());
const int d_pitch(dest.get_data_stride()-w);
const int s_pitch(x.get_data_stride()-w);
int(y=0;y<h;y++,d_ptr+=d_pitch,s_ptr+=s_pitch)
int(x=0;x<w;x++,d_ptr++,s_ptr++)
*d_ptr -= *s_ptr;
int(y=0;y<h;y++,d_ptr+=d_pitch,s_ptr+=s_pitch)
int(x=0;x<w;x++,d_ptr++,s_ptr++)
*d_ptr -= *s_ptr;