}
- if(pass)
+ if (pass)
{
return E_SUCCESS;
}
}
result
-_Canvas::DrawBitmap(const Rectangle& destRect, const _Bitmap& srcBitmap, const Rectangle& srcRect)
+_Canvas::DrawBitmap(const _Util::Rectangle<double>& destRectD, const _Bitmap& srcBitmap, const _Util::Rectangle<double>& srcRectD)
{
SysTryReturnResult(NID_GRP, &srcBitmap && srcBitmap.IsValid(), E_INVALID_ARG, "The source bitmap is invalid.\n");
- if (srcRect.width == 0 || srcRect.height == 0)
+ if (srcRectD.w == 0 || srcRectD.h == 0)
{
return E_SUCCESS;
}
- if (destRect.width == 0 || destRect.height == 0)
+ if (destRectD.w == 0 || destRectD.h == 0)
{
return E_SUCCESS;
}
this->__GetClipBounds(clipRect);
- if (alphaConstant >= 255)
+ _Util::Rectangle<int> destRect =
+ {
+ _DoubleToIntForPos(destRectD.x),
+ _DoubleToIntForPos(destRectD.y),
+ _DoubleToIntForSize(destRectD.w),
+ _DoubleToIntForSize(destRectD.h)
+ };
+
+ _Util::Rectangle<int> srcRect =
+ {
+ _DoubleToIntForPos(srcRectD.x),
+ _DoubleToIntForPos(srcRectD.y),
+ _DoubleToIntForSize(srcRectD.w),
+ _DoubleToIntForSize(srcRectD.h)
+ };
+
{
bool pass = false;
{
if (!this->__useStableRenderer && srcBufferInfo.bitsPerPixel == 32)
{
- _Util::Rectangle<int> outRect = { 0, 0, -1, -1 };
- _Util::Rectangle<int> dstRect = { destRect.x, destRect.y, destRect.width, destRect.height };
- _Util::Rectangle<int> tgtRect = { clipRect.x, clipRect.y, clipRect.width, clipRect.height };
-
- _Util::IntersectRect(outRect, tgtRect, dstRect);
-
- // assert(destRect.width > 0 && destRect.height > 0);
-
- _Util::Bounds<int> outBounds = { outRect.x, outRect.y, outRect.x + outRect.w, outRect.y + outRect.h };
- _Util::Bounds<int> dstBounds = { dstRect.x, dstRect.y, dstRect.x + dstRect.w, dstRect.y + dstRect.h };
- _Util::Bounds<int> srcBounds =
+ _Util::Rectangle<int> srcBounds =
{
- srcRect.x + (outBounds.x1 - dstBounds.x1) * srcRect.width / (dstBounds.x2 - dstBounds.x1),
- srcRect.y + (outBounds.y1 - dstBounds.y1) * srcRect.height / (dstBounds.y2 - dstBounds.y1),
- (srcRect.x + srcRect.width) + (outBounds.x2 - dstBounds.x2) * srcRect.width / (dstBounds.x2 - dstBounds.x1),
- (srcRect.y + srcRect.height) + (outBounds.y2 - dstBounds.y2) * srcRect.height / (dstBounds.y2 - dstBounds.y1),
+ int(Math::Floor(srcRect.x)),
+ int(Math::Floor(srcRect.y)),
+ int(Math::Ceiling(srcRect.x + srcRect.w) - Math::Floor(srcRect.x)),
+ int(Math::Ceiling(srcRect.y + srcRect.h) - Math::Floor(srcRect.y))
};
- srcBounds.x1 = (srcBounds.x1 >= srcRect.x) ? srcBounds.x1 : srcRect.x;
- srcBounds.y1 = (srcBounds.y1 >= srcRect.y) ? srcBounds.y1 : srcRect.y;
- srcBounds.x2 = (srcBounds.x2 <= (srcRect.x + srcRect.width)) ? srcBounds.x2 : (srcRect.x + srcRect.width);
- srcBounds.y2 = (srcBounds.y2 <= (srcRect.y + srcRect.height)) ? srcBounds.y2 : (srcRect.y + srcRect.height);
-
_Util::Pixmap srcImageUnclipped(srcBufferInfo.width, srcBufferInfo.height, srcBufferInfo.bitsPerPixel, srcBufferInfo.pPixels, srcBufferInfo.pitch);
- _Util::Pixmap srcImage = srcImageUnclipped.GetSubBitmap(srcBounds.x1, srcBounds.y1, srcBounds.x2 - srcBounds.x1, srcBounds.y2 - srcBounds.y1);
+ _Util::Pixmap srcImage = srcImageUnclipped.GetSubBitmap(srcBounds.x, srcBounds.y, srcBounds.w, srcBounds.h);
_ApplySrcBitmapAttrib(srcImage, srcBitmap, srcBitmap.__isOpaqueAllOver);
_Util::Pixmap dstImageUnclipped(dstBufferInfo.width, dstBufferInfo.height, dstBufferInfo.bitsPerPixel, dstBufferInfo.pPixels, dstBufferInfo.pitch);
- _Util::Pixmap dstImage = dstImageUnclipped.GetSubBitmap(outRect.x, outRect.y, outRect.w, outRect.h);
+ _Util::Pixmap dstImage = dstImageUnclipped.GetSubBitmap(clipRect.x, clipRect.y, clipRect.width, clipRect.height);
- pass = _Pixman::ScalePixmap(dstImage, srcImage, GetDrawingQuality(), GetCompositeMode());
+ if (alphaConstant < 255)
+ {
+ std::unique_ptr<_Util::Pixmap> modifiedSrcImage(srcImage.GetAlphaAttenuatedPixmap(alphaConstant));
+
+ if (modifiedSrcImage != null)
+ {
+ pass = _Pixman::ScalePixmap(dstImage, *modifiedSrcImage.get(), GetDrawingQuality(), GetCompositeMode(), destRectD.x - clipRect.x, destRectD.y - clipRect.y, destRectD.w, destRectD.h);
+ }
+ }
+
+ if (!pass)
+ {
+ pass = _Pixman::ScalePixmap(dstImage, srcImage, GetDrawingQuality(), GetCompositeMode(), destRectD.x - clipRect.x, destRectD.y - clipRect.y, destRectD.w, destRectD.h);
+ }
}
if (!pass)
{
unsigned char* pPixels = (unsigned char*) srcBufferInfo.pPixels + srcRect.y * srcBufferInfo.pitch + srcRect.x * (srcBufferInfo.bitsPerPixel / 8);
- _Util::Pixmap srcImage(srcRect.width, srcRect.height, srcBufferInfo.bitsPerPixel, (void*) pPixels, srcBufferInfo.pitch);
+ _Util::Pixmap srcImage(srcRect.w, srcRect.h, srcBufferInfo.bitsPerPixel, (void*) pPixels, srcBufferInfo.pitch);
_ApplySrcBitmapAttrib(srcImage, srcBitmap, srcBitmap.__isOpaqueAllOver);
_Util::Pixmap dstImageUnclipped(dstBufferInfo.width, dstBufferInfo.height, dstBufferInfo.bitsPerPixel, dstBufferInfo.pPixels, dstBufferInfo.pitch);
_Util::Pixmap dstImage = dstImageUnclipped.GetSubBitmap(clipRect.x, clipRect.y, clipRect.width, clipRect.height);
- pass = Tizen::Graphics::_Effect::ScaleImage(dstImage, destRect.x - clipRect.x, destRect.y - clipRect.y, destRect.width, destRect.height, srcImage, _ConvertParam<_Effect::Rop>(this->__blendOption));
+ pass = Tizen::Graphics::_Effect::ScaleImage(dstImage, destRect.x - clipRect.x, destRect.y - clipRect.y, destRect.w, destRect.h, srcImage, _ConvertParam<_Effect::Rop>(this->__blendOption));
}
}
- SysTryReturnResult(NID_GRP, pass, E_INVALID_ARG, "The source bitmap is invalid.\n");
-
- return E_SUCCESS;
+ if(pass)
+ {
+ return E_SUCCESS;
+ }
}
- else
+
{
- _Util::Pixmap tmpImage(destRect.width, destRect.height, srcBitmap.GetBitsPerPixel());
+ _Util::Pixmap tmpImage(destRect.w, destRect.h, srcBitmap.GetBitsPerPixel());
// copies the source bitmap to the scaled bitmap
{
{
unsigned char* pPixels = (unsigned char*) srcBufferInfo.pPixels + srcRect.y * srcBufferInfo.pitch + srcRect.x * (srcBufferInfo.bitsPerPixel / 8);
- _Util::Pixmap srcImage(srcRect.width, srcRect.height, srcBufferInfo.bitsPerPixel, (void*) pPixels, srcBufferInfo.pitch);
+ _Util::Pixmap srcImage(srcRect.w, srcRect.h, srcBufferInfo.bitsPerPixel, (void*) pPixels, srcBufferInfo.pitch);
_ApplySrcBitmapAttrib(srcImage, srcBitmap, srcBitmap.__isOpaqueAllOver);
- pass = Tizen::Graphics::_Effect::ScaleImage(tmpImage, 0, 0, destRect.width, destRect.height, srcImage, Tizen::Graphics::_Effect::ROP_COPY);
+ pass = Tizen::Graphics::_Effect::ScaleImage(tmpImage, 0, 0, destRect.w, destRect.h, srcImage, Tizen::Graphics::_Effect::ROP_COPY);
}
}
this->__GetClipBounds(clipRect);
- if (alphaConstant >= 255)
- {
- bool pass = false;
+ bool pass = false;
+ {
_Util::LockManager srcLock(srcBitmap);
_Util::LockManager dstLock(*this);
}
else
{
- pass = _Pixman::ScalePixmap(dstImage, srcImage, GetDrawingQuality(), GetCompositeMode());
+ if (alphaConstant < 255)
+ {
+ std::unique_ptr<_Util::Pixmap> modifiedSrcImage(srcImage.GetAlphaAttenuatedPixmap(alphaConstant));
+
+ if (modifiedSrcImage != null)
+ {
+ pass = _Pixman::ScalePixmap(dstImage, *modifiedSrcImage.get(), GetDrawingQuality(), GetCompositeMode());
+ }
+ }
+
+ if (!pass)
+ {
+ pass = _Pixman::ScalePixmap(dstImage, srcImage, GetDrawingQuality(), GetCompositeMode());
+ }
}
}
}
- SysTryReturnResult(NID_GRP, pass, E_INVALID_ARG, "The source bitmap is invalid.\n");
-
- return E_SUCCESS;
}
- else
+
+ if (!pass)
{
_Util::Pixmap tmpImage(destRect.width, destRect.height, srcBitmap.GetBitsPerPixel());
}
}
- bool pass = false;
+ bool scaled = false;
{
_Util::LockManager srcLock(srcBitmap);
_Util::Pixmap srcImage(srcRect.width, srcRect.height, srcBufferInfo.bitsPerPixel, (void*) pPixels, srcBufferInfo.pitch);
_ApplySrcBitmapAttrib(srcImage, srcBitmap, srcBitmap.__isOpaqueAllOver);
- pass = Tizen::Graphics::_Effect::ScaleImage(tmpImage, 0, 0, destRect.width, destRect.height, srcImage, Tizen::Graphics::_Effect::ROP_COPY);
+ scaled = Tizen::Graphics::_Effect::ScaleImage(tmpImage, 0, 0, destRect.width, destRect.height, srcImage, Tizen::Graphics::_Effect::ROP_COPY);
}
}
- SysTryReturnResult(NID_GRP, pass, E_INVALID_ARG, "The source bitmap is invalid.\n");
+ SysTryReturnResult(NID_GRP, scaled, E_INVALID_ARG, "The source bitmap is invalid.\n");
}
{
- bool pass = false;
-
- {
- _Util::LockManager dstLock(*this);
- SysTryReturnResult(NID_GRP, dstLock.IsValid(), E_OPERATION_FAILED, "The canvas cannot be locked.\n");
+ _Util::LockManager dstLock(*this);
+ SysTryReturnResult(NID_GRP, dstLock.IsValid(), E_OPERATION_FAILED, "The canvas cannot be locked.\n");
- const BufferInfo& dstBufferInfo = dstLock.GetBufferInfo();
+ const BufferInfo& dstBufferInfo = dstLock.GetBufferInfo();
- {
- _Util::Pixmap dstImageUnclipped(dstBufferInfo.width, dstBufferInfo.height, dstBufferInfo.bitsPerPixel, dstBufferInfo.pPixels, dstBufferInfo.pitch);
- _Util::Pixmap dstImage = dstImageUnclipped.GetSubBitmap(clipRect.x, clipRect.y, clipRect.width, clipRect.height);
+ {
+ _Util::Pixmap dstImageUnclipped(dstBufferInfo.width, dstBufferInfo.height, dstBufferInfo.bitsPerPixel, dstBufferInfo.pPixels, dstBufferInfo.pitch);
+ _Util::Pixmap dstImage = dstImageUnclipped.GetSubBitmap(clipRect.x, clipRect.y, clipRect.width, clipRect.height);
- pass = Tizen::Graphics::_Effect::DrawImageWithAlpha(dstImage, destRect.x - clipRect.x, destRect.y - clipRect.y, tmpImage, alphaConstant);
- }
+ pass = Tizen::Graphics::_Effect::DrawImageWithAlpha(dstImage, destRect.x - clipRect.x, destRect.y - clipRect.y, tmpImage, alphaConstant);
}
-
- SysTryReturnResult(NID_GRP, pass, E_INVALID_ARG, "The source bitmap is invalid.\n");
}
-
- return E_SUCCESS;
}
+
+ SysTryReturnResult(NID_GRP, pass, E_INVALID_ARG, "The source bitmap is invalid.\n");
+
+ return E_SUCCESS;
}
result
// not <- PADDING * 2>
Tizen::Graphics::Rectangle srcRect(PADDING, PADDING, expandedBitmap.GetWidth() - PADDING, expandedBitmap.GetHeight() - PADDING);
- return this->DrawBitmap(rect, expandedBitmap, srcRect);
+ return this->DrawBitmap(_Util::Convert<Rectangle, _Util::Rectangle<double> >(rect), expandedBitmap, _Util::Convert<Rectangle, _Util::Rectangle<double> >(srcRect));
}
#else // old spec.
{
SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
- SysTryReturnResult(NID_GRP, BITMAP_IS_VALID(srcBitmap), E_INVALID_ARG, "The source bitmap is invalid.");
-
- SysTryReturnResult(NID_GRP, (&vcSrcRect) && (&vcDestRect), E_INVALID_ARG, "The given rectangle is invalid.");
-
- SysTryReturnResult(NID_GRP, (vcSrcRect.width >= 0) && (vcSrcRect.height >= 0), E_OUT_OF_RANGE, "The given source rectangle(width:%d,height:%d) is out of range.", vcSrcRect.width, vcSrcRect.height);
- SysTryReturnResult(NID_GRP, (vcDestRect.width >= 0) && (vcDestRect.height >= 0), E_OUT_OF_RANGE, "The given destination rectangle(width:%d,height:%d) is out of range.", vcDestRect.width, vcDestRect.height);
-
- if (vcSrcRect.width == 0 || vcSrcRect.height == 0)
- {
- return E_SUCCESS;
- }
-
- if (vcDestRect.width == 0 || vcDestRect.height == 0)
- {
- return E_SUCCESS;
- }
-
- if ((vcSrcRect.x < 0) || (vcSrcRect.y < 0) || (vcSrcRect.x + vcSrcRect.width > srcBitmap.GetWidth()) || (vcSrcRect.y + vcSrcRect.height > srcBitmap.GetHeight()))
- {
- SysTryReturnResult(NID_GRP, 0, E_OUT_OF_RANGE, "The specified region of source bitmap is out of range.");
- }
-
- // check if srcRect is in bitmap's area.
- result r = _Util::Validate(vcSrcRect, Rectangle(0, 0, srcBitmap.GetWidth(), srcBitmap.GetHeight()));
-
- SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
-
- // check if destRect is in this canvas.
- Rectangle rtCanvas = _GetBoundsRel(*this);
-
- if (rtCanvas.IsEmpty())
- {
- return E_SUCCESS;
- }
-
- r = _Util::Validate(vcDestRect, rtCanvas);
-
- SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
-
- EXTRACT_BITMAPEX(pBitmapEx, srcBitmap);
-
- if (_ResUtil::NeedToConvertCoord())
- {
- Tizen::Graphics::Dimension virSize;
- Tizen::Graphics::Dimension phySize;
- bool lazyScaling = Tizen::Graphics::_IsLazyScalingBitmap(srcBitmap, virSize, phySize);
-
- Rectangle pcDestRect = _ResUtil::ConvertToPhyCoord(vcDestRect);
-
- if (lazyScaling)
- {
- return this->_pNativeCanvas->DrawBitmap(pcDestRect, *pBitmapEx, vcSrcRect);
- }
- else
- {
- Rectangle pcSrcRect = _ResUtil::ConvertToPhyCoord(vcSrcRect);
-
- return this->_pNativeCanvas->DrawBitmap(pcDestRect, *pBitmapEx, pcSrcRect);
- }
- }
- else
- {
- return this->_pNativeCanvas->DrawBitmap(vcDestRect, *pBitmapEx, vcSrcRect);
- }
+ return this->DrawBitmap(FloatRectangle(float(vcDestRect.x), float(vcDestRect.y), float(vcDestRect.width), float(vcDestRect.height)), srcBitmap, FloatRectangle(float(vcSrcRect.x), float(vcSrcRect.y), float(vcSrcRect.width), float(vcSrcRect.height)));
}
result
FloatRectangle pcDestRectF = _ResUtil::ConvertToPhyCoord(vcDestRectF);
- Rectangle pcDestRect(_FloatToIntForPos(pcDestRectF.x), _FloatToIntForPos(pcDestRectF.y), _FloatToIntForSize(pcDestRectF.width), _FloatToIntForSize(pcDestRectF.height));
+ _Util::Rectangle<double> pcDestRectD = _Util::Convert<FloatRectangle, _Util::Rectangle<double> >(pcDestRectF);
if (lazyScaling)
{
- Rectangle vcSrcRect(_FloatToIntForPos(vcSrcRectF.x), _FloatToIntForPos(vcSrcRectF.y), _FloatToIntForSize(vcSrcRectF.width), _FloatToIntForSize(vcSrcRectF.height));
+ _Util::Rectangle<double> vcSrcRectD = _Util::Convert<FloatRectangle, _Util::Rectangle<double> >(vcSrcRectF);
- return this->_pNativeCanvas->DrawBitmap(pcDestRect, *pBitmapEx, vcSrcRect);
+ return this->_pNativeCanvas->DrawBitmap(pcDestRectD, *pBitmapEx, vcSrcRectD);
}
else
{
FloatRectangle pcSrcRectF = _ResUtil::ConvertToPhyCoord(vcSrcRectF);
- Rectangle pcSrcRect(_FloatToIntForPos(pcSrcRectF.x), _FloatToIntForPos(pcSrcRectF.y), _FloatToIntForSize(pcSrcRectF.width), _FloatToIntForSize(pcSrcRectF.height));
+ _Util::Rectangle<double> pcSrcRectD = _Util::Convert<FloatRectangle, _Util::Rectangle<double> >(pcSrcRectF);
- return this->_pNativeCanvas->DrawBitmap(pcDestRect, *pBitmapEx, pcSrcRect);
+ return this->_pNativeCanvas->DrawBitmap(pcDestRectD, *pBitmapEx, pcSrcRectD);
}
}
else
{
- Rectangle vcSrcRect(_FloatToIntForPos(vcSrcRectF.x), _FloatToIntForPos(vcSrcRectF.y), _FloatToIntForSize(vcSrcRectF.width), _FloatToIntForSize(vcSrcRectF.height));
- Rectangle vcDestRect(_FloatToIntForPos(vcDestRectF.x), _FloatToIntForPos(vcDestRectF.y), _FloatToIntForSize(vcDestRectF.width), _FloatToIntForSize(vcDestRectF.height));
+ _Util::Rectangle<double> vcSrcRectD = _Util::Convert<FloatRectangle, _Util::Rectangle<double> >(vcSrcRectF);
+ _Util::Rectangle<double> vcDestRectD = _Util::Convert<FloatRectangle, _Util::Rectangle<double> >(vcDestRectF);
- return this->_pNativeCanvas->DrawBitmap(vcDestRect, *pBitmapEx, vcSrcRect);
+ return this->_pNativeCanvas->DrawBitmap(vcDestRectD, *pBitmapEx, vcSrcRectD);
}
}