mirror of
https://gitee.com/houstudio/Cdroid.git
synced 2024-12-04 21:27:41 +08:00
make image drawing faster
This commit is contained in:
parent
5158f0561d
commit
acefc45bd3
@ -369,7 +369,7 @@ void BitmapDrawable::draw(Canvas&canvas){
|
||||
const float fx = dw / sw , fy = dh / sh;
|
||||
const float alpha = mBitmapState->mBaseAlpha*mBitmapState->mAlpha/255.f;
|
||||
const int angle_degrees = getRotateAngle(canvas);
|
||||
const Cairo::SurfacePattern::Filter filterMode = (angle_degrees%90==0)&&(getOpacity()==PixelFormat::OPAQUE)?SurfacePattern::Filter::FAST:SurfacePattern::Filter::GOOD;
|
||||
const Cairo::SurfacePattern::Filter filterMode = (angle_degrees%90==0)&&(getOpacity()==PixelFormat::OPAQUE)?SurfacePattern::Filter::NEAREST:SurfacePattern::Filter::BILINEAR;
|
||||
|
||||
canvas.rectangle(mBounds.left,mBounds.top,mBounds.width,mBounds.height);
|
||||
canvas.clip();
|
||||
|
@ -30,9 +30,18 @@ NinePatch::NinePatch(Context*ctx,const std::string&resid){
|
||||
NinePatch::~NinePatch() {
|
||||
}
|
||||
|
||||
static int getRotateAngle(Canvas&canvas){
|
||||
double xx, yx, xy, yy, x0, y0;
|
||||
Cairo::Matrix ctx=canvas.get_matrix();
|
||||
double radians = atan2(ctx.yy, ctx.xy);
|
||||
return int(radians*180.f/M_PI);
|
||||
}
|
||||
|
||||
void NinePatch::draw(Canvas& painter, int x, int y) {
|
||||
const int angle_degrees = getRotateAngle(painter);
|
||||
painter.save();
|
||||
painter.translate(x,y);
|
||||
const Cairo::SurfacePattern::Filter filterMode = (angle_degrees%90==0)&&(getOpacity()==PixelFormat::OPAQUE)?SurfacePattern::Filter::NEAREST:SurfacePattern::Filter::BILINEAR;
|
||||
painter.set_source(mCachedImage,0,0);
|
||||
painter.rectangle(0,0,mCachedImage->get_width(),mCachedImage->get_height());
|
||||
painter.clip();
|
||||
|
Loading…
Reference in New Issue
Block a user