aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Hillenbrand <codeworkx@cyanogenmod.org>2013-06-14 23:16:18 +0200
committerDaniel Hillenbrand <codeworkx@cyanogenmod.org>2013-06-14 23:19:47 +0200
commit4adc54b9973e7d2d2f22b83e32abbbeb545b8b4e (patch)
treefb715a263a642c5cb5f75a0f19645d29c6b01a7e
parent647876b665f2cf011e75adc6ff2238d467c47635 (diff)
downloadexternal_skia-4adc54b9973e7d2d2f22b83e32abbbeb545b8b4e.zip
external_skia-4adc54b9973e7d2d2f22b83e32abbbeb545b8b4e.tar.gz
external_skia-4adc54b9973e7d2d2f22b83e32abbbeb545b8b4e.tar.bz2
skia: exynos4: add support for fimg2d3x
Change-Id: Ie0509e7d537fe2a73b23c30f5128d80ee48c1d7d
-rw-r--r--Android.mk10
-rw-r--r--include/core/SkFimgApi3x.h267
-rw-r--r--src/core/SkBlitter_ARGB32.cpp6
-rw-r--r--src/core/SkDraw.cpp17
-rw-r--r--src/core/SkFimgApi3x.cpp345
5 files changed, 642 insertions, 3 deletions
diff --git a/Android.mk b/Android.mk
index 021cb0d..2bb3bb5 100644
--- a/Android.mk
+++ b/Android.mk
@@ -365,8 +365,16 @@ LOCAL_LDLIBS += -lpthread
ifeq ($(BOARD_USES_FIMGAPI),true)
ifeq ($(BOARD_USES_SKIA_FIMGAPI),true)
LOCAL_CFLAGS += -DFIMG2D_ENABLED
-LOCAL_C_INCLUDES += $(TOP)/hardware/samsung/exynos4/hal/include
+ifeq ($(TARGET_SOC),exynos4210)
+LOCAL_SRC_FILES += src/core/SkFimgApi3x.cpp
+LOCAL_C_INCLUDES += $(TOP)/hardware/samsung/exynos4/hal/libfimg3x
+LOCAL_CFLAGS += -DFIMG2D3X
+endif
+ifeq ($(TARGET_SOC),exynos4x12)
LOCAL_SRC_FILES += src/core/SkFimgApi4x.cpp
+LOCAL_C_INCLUDES += $(TOP)/hardware/samsung/exynos4/hal/include
+LOCAL_CFLAGS += -DFIMG2D4X
+endif
LOCAL_SHARED_LIBRARIES += libfimg
endif
endif
diff --git a/include/core/SkFimgApi3x.h b/include/core/SkFimgApi3x.h
new file mode 100644
index 0000000..d8285d2
--- /dev/null
+++ b/include/core/SkFimgApi3x.h
@@ -0,0 +1,267 @@
+/*
+**
+** Copyright 2009 Samsung Electronics Co, Ltd.
+**
+** Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+**
+*/
+#ifndef SkFimgApi_DEFINED
+#define SkFimgApi_DEFINED
+
+#if defined(FIMG2D_ENABLED)
+
+#include "SkColorPriv.h"
+#include "SkBitmap.h"
+#include "SkMallocPixelRef.h"
+#include "SkFlattenable.h"
+#include "SkUtils.h"
+#include "SkXfermode.h"
+#include "SkMatrix.h"
+
+#include "FimgApi.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+#include <signal.h>
+#include <sys/mman.h>
+#include <sys/time.h>
+#include <sys/ioctl.h>
+#include <sys/poll.h>
+#include <sys/stat.h>
+
+#include <linux/android_pmem.h>
+
+//---------------------------------------------------------------------------//
+
+#define FIMGAPI_G2D_BLOCKING TRUE
+#define FIMGAPI_FILTERMODE_USE_SW TRUE
+#define FIMGAPI_DITHERMODE_USE_SW TRUE
+#define FIMGAPI_COMPROMISE_USE TRUE
+#define FIMGAPI_HYBRID_USE FALSE
+
+#if defined(SWP1_CUSTOMSIMD_ENABLE)
+#define FIMGAPI_DMC_SIMD_OPT_USE TRUE
+#else
+#define FIMGAPI_DMC_SIMD_OPT_USE FALSE
+#endif
+
+#define FIMGAPI_FINISHED (0x1<<0)
+#define FIMGAPI_HYBRID (0x1<<1)
+
+// G2D Compromise values
+#define COMP_VALUE_FILTER_SCALE 48*80
+
+#define COPT_NANS 0
+#define COPT_ANS 1
+#define COPT_NAS 2
+#define COPT_AS 3
+
+struct Fimg {
+ int srcX;
+ int srcY;
+ unsigned int srcW;
+ unsigned int srcH;
+ unsigned int srcFWStride; // this is not w, just stride (w * bpp)
+ unsigned int srcFH;
+ unsigned int srcBPP;
+ int srcColorFormat;
+ unsigned char *srcAddr;
+
+ int dstX;
+ int dstY;
+ unsigned int dstW;
+ unsigned int dstH;
+ unsigned int dstFWStride; // this is not w, just stride (w * bpp)
+ unsigned int dstFH;
+ unsigned int dstBPP;
+ int dstColorFormat;
+ unsigned char *dstAddr;
+
+ int clipT;
+ int clipB;
+ int clipL;
+ int clipR;
+
+ int rotate;
+ int alpha;
+ int xfermode;
+ int isDither;
+ int isFilter;
+ int colorFilter;
+ int canusehybrid;
+ int matrixType;
+ int matrixSx;
+ int matrixSy;
+ Fimg() {
+ }
+};
+
+int FimgApiCheckPossibleHybrid(Fimg *fimg);
+bool FimgApiCheckPossible(Fimg *fimg);
+bool FimgApiCompromise(Fimg *fimg);
+int FimgApiStretch(Fimg *fimg, const char *func_name);
+int FimgApiSync(const char *func_name);
+#endif //defined(FIMG2D_ENABLED)
+
+#ifdef CHECK_TIME_FOR_FIMGAPI
+
+extern "C" {
+ #include <stdio.h>
+ #include <sys/time.h>
+ #include <time.h>
+ #include <unistd.h>
+}
+
+class MyAutoTimeManager
+{
+private:
+ const char *mInfo;
+
+ int mSrcColorFormat;
+ int mSrcWidth;
+ int mSrcHeight;
+
+ int mDstColorFormat;
+ int mDstWidth;
+ int mDstHeight;
+ int mAlpha;
+
+ char *nameA;
+ long long timeA;
+ char *nameB;
+ long long timeB;
+
+public:
+ MyAutoTimeManager(const char *info,
+ int srcColorFormat,
+ int srcWidth,
+ int srcHeight,
+ int dstColorFormat,
+ int dstWidth,
+ int dstHeight,
+ int alpha)
+ : mInfo(info),
+ mSrcColorFormat(srcColorFormat),
+ mSrcWidth (srcWidth),
+ mSrcHeight(srcHeight),
+ mDstColorFormat(dstColorFormat),
+ mDstWidth (dstWidth),
+ mDstHeight(dstHeight),
+ mAlpha(alpha)
+ {
+ nameA = NULL;
+ timeA = 0;
+ nameB = NULL;
+ timeB = 0;
+ }
+
+ ~MyAutoTimeManager()
+ {
+ if (nameA && nameB
+ && FimgApiCheckPossible(mSrcColorFormat, mSrcWidth, mSrcHeight,
+ mDstColorFormat, mDstWidth, mDstHeight) == true) {
+ long long gapTime;
+ float gapRate;
+ long long fasterTime;
+ long long slowerTime;
+ char *fasterName;
+ char *slowerName;
+
+ if (timeA <= timeB) {
+ fasterName = nameA;
+ fasterTime = timeA;
+ slowerName = nameB;
+ slowerTime = timeB;
+ } else {
+ fasterName = nameB;
+ fasterTime = timeB;
+ slowerName = nameA;
+ slowerTime = timeA;
+ }
+
+ gapTime = slowerTime - fasterTime;
+ gapRate = ((float)slowerTime / (float)fasterTime) * 100.f - 100.0f;
+
+ SkDebugf("%s::%s (%5lld) faster than %s (%5lld) (%5lld) microsec / (%6.1f ) %% : [%3d %3d (%2d)] -> [%3d %3d (%2d)] \[sizeConv : %c] [colorConv : %c] [alpha : %3d] \n",
+ mInfo,
+ fasterName,
+ fasterTime,
+ slowerName,
+ slowerTime,
+ gapTime,
+ gapRate,
+ mSrcWidth,
+ mSrcHeight,
+ mSrcColorFormat,
+ mDstWidth,
+ mDstHeight,
+ mDstColorFormat,
+ (mSrcWidth != mDstWidth || mSrcHeight != mDstHeight) ? 'O' : 'X',
+ (mSrcColorFormat != mDstColorFormat) ? 'O' : 'X',
+ mAlpha);
+ }
+ }
+
+ void SetGap(char *name, long long gap)
+ {
+ if (nameA == NULL) {
+ nameA = name;
+ timeA = gap;
+ } else {
+ nameB = name;
+ timeB = gap;
+ }
+ }
+};
+
+//---------------------------------------------------------------------------//
+
+class MyAutoTime
+{
+private:
+ struct timeval mStartWhen;
+ const char *mMyName;
+ MyAutoTimeManager *mAutoTimeManager;
+
+public:
+ MyAutoTime(const char *myName,
+ MyAutoTimeManager *autoTimeManager)
+ : mMyName(myName),
+ mAutoTimeManager(autoTimeManager)
+ {
+ gettimeofday(&mStartWhen, NULL);
+ }
+
+ ~MyAutoTime()
+ {
+ struct timeval endWhen;
+ long long timeGap;
+
+ gettimeofday(&endWhen, NULL);
+
+ long long start = ((long long) mStartWhen.tv_sec) * 1000000LL + ((long long) mStartWhen.tv_usec);
+ long long stop = ((long long) endWhen.tv_sec) * 1000000LL + ((long long) endWhen.tv_usec);
+
+ timeGap = stop - start;
+ mAutoTimeManager->SetGap((char*)mMyName, timeGap);
+ }
+};
+
+#endif
+
+#endif //SkFimgApi_DEFINED
diff --git a/src/core/SkBlitter_ARGB32.cpp b/src/core/SkBlitter_ARGB32.cpp
index 44d0d8c..eb1e622 100644
--- a/src/core/SkBlitter_ARGB32.cpp
+++ b/src/core/SkBlitter_ARGB32.cpp
@@ -18,7 +18,11 @@
#if defined(FIMG2D_ENABLED)
#include "SkBitmap.h"
#include "SkBitmapProcShader.h"
+#if defined(FIMG2D3X)
+#include "SkFimgApi3x.h"
+#elif defined(FIMG2D4X)
#include "SkFimgApi4x.h"
+#endif
extern Fimg fimg;
extern SkMutex gG2DMutex;
#endif
@@ -224,7 +228,7 @@ void SkARGB32_Blitter::blitRect(int x, int y, int width, int height) {
uint32_t color = fPMColor;
size_t rowBytes = fDevice.rowBytes();
-#if defined(FIMG2D_ENABLED)
+#if defined(FIMG2D_ENABLED) && defined (FIMG2D4X)
gG2DMutex.acquire();
int retFimg = FimgARGB32_Rect(fimg, fDevice.getAddr32(0, 0),
x, y, width, height, rowBytes, color);
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index 4460eb8..e3ee31c 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -34,7 +34,11 @@
#include <cutils/log.h>
#if defined(FIMG2D_ENABLED)
+#if defined(FIMG2D3X)
+#include "SkFimgApi3x.h"
+#elif defined(FIMG2D4X)
#include "SkFimgApi4x.h"
+#endif
Fimg fimg;
SkMutex gG2DMutex;
#endif
@@ -1261,7 +1265,10 @@ void SkDraw::drawBitmap(const SkBitmap& bitmap, const SkMatrix& prematrix,
fimg.clipL = cr.fLeft;
fimg.clipR = cr.fRight;
+#if defined(FIMG2D4X)
fimg.mskAddr = NULL;
+#endif
+
fimg.rotate = 0;
SkXfermode::Mode mode;
@@ -1272,8 +1279,13 @@ void SkDraw::drawBitmap(const SkBitmap& bitmap, const SkMatrix& prematrix,
fimg.colorFilter = (int)paint.getColorFilter();
fimg.alpha = paint.getAlpha();
- if (bitmap.isOpaque() && (255 == fimg.alpha))
+ if (bitmap.isOpaque() && (255 == fimg.alpha)) {
+#if defined(FIMG2D3X)
+ fimg.alpha = 256;
+#elif defined(FIMG2D4X)
fimg.alpha = 255;
+#endif
+ }
if (fimg.srcAddr != NULL) {
int retFimg = FimgApiStretch(&fimg, __func__);
@@ -1343,7 +1355,10 @@ void SkDraw::drawBitmap(const SkBitmap& bitmap, const SkMatrix& prematrix,
fimg.dstColorFormat = fBitmap->config();
fimg.dstAddr = (unsigned char *)fBitmap->getAddr(0,0);
+#if defined(FIMG2D4X)
fimg.mskAddr = NULL;
+#endif
+
fimg.rotate = 0;
fimg.alpha = paint.getAlpha();
diff --git a/src/core/SkFimgApi3x.cpp b/src/core/SkFimgApi3x.cpp
new file mode 100644
index 0000000..5795371
--- /dev/null
+++ b/src/core/SkFimgApi3x.cpp
@@ -0,0 +1,345 @@
+/*
+**
+** Copyright 2009 Samsung Electronics Co, Ltd.
+**
+** Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+**
+*/
+
+#if defined(FIMG2D_ENABLED)
+
+#include "SkFimgApi3x.h"
+
+#define G2D_BLOCKING_USE 0
+
+// 0 kRGB_565_Config
+// 1 kARGB_4444_Config
+// 2 kARGB_8888_Config
+// [dst][src][option]
+
+#if FIMGAPI_DMC_SIMD_OPT_USE
+#if FIMGAPI_HYBRID_USE
+int comp_value[3][3][4] = {
+ {{360*600, 78*130, 168*280, 66*110}, {78*130, 54*90, 80*140, 66*110}, {168*280, 162*270, 102*170, 72*120}},
+ {{54*90, 42*70, 54*90, 42*70}, {54*90, 48*80, 54*90, 48*80}, {66*110, 54*90, 66*110, 54*90}},
+ {{84*140, 54*90, 84*130, 54*90}, {102*170, 78*130, 96*160, 78*130}, {120*200, 66*110, 96*160, 72*120}}
+};
+#else
+int comp_value[3][3][4] = {
+ {{480*800, 78*130, 168*280, 66*110}, {78*130, 54*90, 80*140, 66*110}, {204*340, 216*360, 102*170, 72*120}},
+ {{54*90, 42*70, 54*90, 42*70}, {54*90, 48*80, 54*90, 48*80}, {66*110, 54*90, 66*110, 54*90}},
+ {{84*140, 54*90, 84*130, 54*90}, {102*170, 78*130, 96*160, 78*130}, {180*300, 66*110, 96*160, 72*120}}
+};
+#endif
+#else
+#if FIMGAPI_HYBRID_USE
+int comp_value[3][3][4] = {
+ {{360*600, 78*130, 168*280, 66*110}, {78*130, 54*90, 80*140, 66*110}, {168*280, 162*270, 102*170, 72*120}},
+ {{54*90, 42*70, 54*90, 42*70}, {54*90, 48*80, 54*90, 48*80}, {66*110, 54*90, 66*110, 54*90}},
+ {{84*140, 54*90, 84*130, 54*90}, {102*170, 78*130, 96*160, 78*130}, {120*200, 66*110, 96*160, 72*120}}
+};
+#else
+int comp_value[3][3][4] = {
+ {{480*800, 78*130, 168*280, 66*110}, {78*130, 54*90, 80*140, 66*110}, {204*340, 216*360, 102*170, 72*120}},
+ {{54*90, 42*70, 54*90, 42*70}, {54*90, 48*80, 54*90, 48*80}, {66*110, 54*90, 66*110, 54*90}},
+ {{84*140, 54*90, 84*130, 54*90}, {102*170, 78*130, 96*160, 78*130}, {180*300, 66*110, 96*160, 72*120}}
+};
+#endif
+#endif
+
+int FimgApiCheckPossibleHybrid(Fimg *fimg)
+{
+ if (!((fimg->srcW == fimg->dstW) && (fimg->srcH == fimg->dstH)))
+ return 0;
+ if (!((fimg->clipB - fimg->clipT) >= 40))
+ return 0;
+
+ if (fimg->canusehybrid == 0)
+ return 0;
+
+ if (fimg->srcColorFormat == SkBitmap::kARGB_8888_Config) {
+ if (fimg->dstColorFormat == SkBitmap::kARGB_8888_Config) {
+ if (fimg->alpha < G2D_ALPHA_VALUE_MAX)
+ return 9;
+ else
+ return 7;
+ } else if (fimg->dstColorFormat == SkBitmap::kRGB_565_Config) {
+ if (fimg->alpha < G2D_ALPHA_VALUE_MAX)
+ return 7;
+ else
+ return 7;
+ }
+ } else if (fimg->srcColorFormat == SkBitmap::kRGB_565_Config) {
+ if (fimg->dstColorFormat == SkBitmap::kRGB_565_Config) {
+ if (fimg->alpha < G2D_ALPHA_VALUE_MAX)
+ return 9;
+ else
+ return 5;
+ }
+ }
+ return 0;
+}
+
+bool FimgApiCheckPossible(Fimg *fimg)
+{
+ switch (fimg->srcColorFormat) {
+ case SkBitmap::kRGB_565_Config:
+ case SkBitmap::kARGB_8888_Config:
+ case SkBitmap::kARGB_4444_Config:
+ break;
+ default:
+ return false;
+ break;
+ }
+
+ switch (fimg->dstColorFormat) {
+ case SkBitmap::kRGB_565_Config:
+#if FIMGAPI_DITHERMODE_USE_SW
+ if ((fimg->srcColorFormat == SkBitmap::kARGB_8888_Config) &&
+ (fimg->isDither == true))
+ return false;
+ else
+ break;
+#endif
+ case SkBitmap::kARGB_8888_Config:
+ break;
+ case SkBitmap::kARGB_4444_Config:
+#if FIMGAPI_DITHERMODE_USE_SW
+ if ((fimg->srcColorFormat == SkBitmap::kARGB_8888_Config) &&
+ (fimg->isDither == true))
+ return false;
+#endif
+ break;
+ default:
+ return false;
+ }
+
+ switch (fimg->xfermode) {
+ case SkXfermode::kSrcOver_Mode:
+ break;
+ case SkXfermode::kClear_Mode:
+ break;
+ case SkXfermode::kSrc_Mode:
+ if (fimg->alpha < G2D_ALPHA_VALUE_MAX)
+ return false;
+ break;
+ default:
+ return false;
+ }
+
+#if FIMGAPI_FILTERMODE_USE_SW
+ if ((fimg->srcW != fimg->dstW) || (fimg->srcH != fimg->dstH))
+ if (fimg->isFilter == true)
+ return false;
+#endif
+
+ if (fimg->colorFilter != NULL)
+ return false;
+
+ if ((fimg->srcAddr == NULL) || (fimg->dstAddr == NULL))
+ return false;
+
+ if (fimg->matrixType & SkMatrix::kAffine_Mask)
+ return false;
+
+ if ((fimg->matrixSx < 0) || (fimg->matrixSy < 0))
+ return false;
+
+ if ((fimg->srcX + fimg->srcW) > 8000 || (fimg->srcY + fimg->srcH) > 8000)
+ return false;
+
+ if ((fimg->dstX + fimg->dstW) > 8000 || (fimg->dstY + fimg->dstH) > 8000)
+ return false;
+
+ if ((fimg->clipT < 0) || (fimg->clipB < 0) || (fimg->clipL < 0) || (fimg->clipR < 0)) {
+ SkDebugf("Invalid clip value: TBLR = (%d, %d, %d, %d)",fimg->clipT, fimg->clipB, fimg->clipL, fimg->clipR);
+ return false;
+ }
+
+ if ((fimg->clipT >= fimg->clipB) || (fimg->clipL >= fimg->clipR)) {
+ SkDebugf("Invalid clip value: TBLR = (%d, %d, %d, %d)",fimg->clipT, fimg->clipB, fimg->clipL, fimg->clipR);
+ return false;
+ }
+
+ return true;
+}
+
+bool FimgApiCheckPossible_Clipping(Fimg *fimg)
+{
+ if (((fimg->clipR - fimg->clipL) <= 0) || ((fimg->clipB - fimg->clipT) <= 0))
+ return false;
+ return true;
+}
+
+bool FimgApiCompromise(Fimg *fimg)
+{
+ int comp_opt = 0;
+ if ((fimg->srcW != fimg->dstW) || (fimg->srcH != fimg->dstH)) {
+ if ((fimg->alpha != 256) && (fimg->alpha != 255))
+ comp_opt = COPT_AS;
+ else
+ comp_opt = COPT_NAS;
+ } else {
+ if ((fimg->alpha != 256) && (fimg->alpha != 255))
+ comp_opt = COPT_ANS;
+ else
+ comp_opt = COPT_NANS;
+ }
+
+ if ((fimg->isFilter == true) && ((comp_opt == COPT_AS) || (comp_opt == COPT_NAS)))
+ if (((fimg->clipR - fimg->clipL) * (fimg->clipB - fimg->clipT)) >= COMP_VALUE_FILTER_SCALE)
+ return true;
+
+ if ((((fimg->clipR - fimg->clipL)*1.2) * ((fimg->clipB - fimg->clipT)*0.8)) < comp_value[fimg->dstColorFormat -4][fimg->srcColorFormat - 4][comp_opt])
+ return false;
+
+ return true;
+}
+
+int FimgApiStretch(Fimg *fimg, const char *func_name)
+{
+ int ret;
+
+ if (FimgApiCheckPossible(fimg) == false)
+ return false;
+
+ if (fimg->clipL < fimg->dstX)
+ fimg->clipL = fimg->dstX;
+ if (fimg->clipT < fimg->dstY)
+ fimg->clipT = fimg->dstY;
+ if (fimg->clipR > (fimg->dstX + fimg->dstW))
+ fimg->clipR = fimg->dstX + fimg->dstW;
+ if (fimg->clipB > (fimg->dstY + fimg->dstH))
+ fimg->clipB = fimg->dstY + fimg->dstH;
+
+#if FIMGAPI_COMPROMISE_USE
+ if (FimgApiCompromise(fimg) == false)
+ return false;
+#endif
+
+ int srcColorFormat = FimgApi::COLOR_FORMAT_BASE;
+ int dstColorFormat = FimgApi::COLOR_FORMAT_BASE;
+ int rotate = FimgApi::ROTATE_0;
+ int alpha = fimg->alpha;
+
+ switch (fimg->srcColorFormat) {
+ case SkBitmap::kRGB_565_Config:
+ srcColorFormat = FimgApi::COLOR_FORMAT_RGB_565;
+ break;
+ case SkBitmap::kARGB_4444_Config:
+ srcColorFormat = FimgApi::COLOR_FORMAT_RGBA_4444;
+ break;
+ case SkBitmap::kARGB_8888_Config:
+ srcColorFormat = FimgApi::COLOR_FORMAT_ABGR_8888;
+ break;
+ default:
+ return false;
+ }
+
+ switch (fimg->dstColorFormat) {
+ case SkBitmap::kRGB_565_Config:
+ dstColorFormat = FimgApi::COLOR_FORMAT_RGB_565;
+ break;
+ case SkBitmap::kARGB_4444_Config:
+ dstColorFormat = FimgApi::COLOR_FORMAT_RGBA_4444;
+ break;
+ case SkBitmap::kARGB_8888_Config:
+ dstColorFormat = FimgApi::COLOR_FORMAT_ABGR_8888;
+ break;
+ default:
+ return false;
+ }
+
+ switch (fimg->rotate) {
+ case 0:
+ rotate = FimgApi::ROTATE_0;
+ break;
+ case 90:
+ rotate = FimgApi::ROTATE_90;
+ break;
+ case 180:
+ rotate = FimgApi::ROTATE_180;
+ break;
+ case 270:
+ rotate = FimgApi::ROTATE_270;
+ break;
+ default:
+ #ifdef DEBUG_ON_FIMGAPISTRETCH_LEVEL
+ SkDebugf("%s::unsuppoted angle(%d) fail \n", func_name, fimg->rotate);
+ #endif
+ return false;
+ }
+
+ FimgRect fimgSrcRect = {fimg->srcX, fimg->srcY,
+ fimg->srcW, fimg->srcH,
+ (fimg->srcFWStride / fimg->srcBPP), fimg->srcFH,
+ srcColorFormat,
+ fimg->srcBPP,
+ fimg->srcAddr};
+
+ FimgRect fimgDstRect = {fimg->dstX, fimg->dstY,
+ fimg->dstW, fimg->dstH,
+ (fimg->dstFWStride / fimg->dstBPP), fimg->dstFH,
+ dstColorFormat,
+ fimg->dstBPP,
+ fimg->dstAddr};
+
+#if FIMGAPI_HYBRID_USE
+ int ratio = FimgApiCheckPossibleHybrid(fimg);
+ if (ratio == 0)
+ ret = FIMGAPI_FINISHED;
+ else {
+ int temp_clipT = fimg->clipT;
+ fimg->clipT = fimg->clipT + ((fimg->clipB - fimg->clipT) / 10) * (10 - ratio);
+
+ if ((temp_clipT >= fimg->clipT) || (fimg->clipB <= fimg->clipT)) {
+ SkDebugf("Invalid clip value: TBLR = (%d, %d, %d, %d), mT = %d",
+ temp_clipT, fimg->clipB, fimg->clipL, fimg->clipR, fimg->clipT);
+ return false;
+ }
+
+ ret = FIMGAPI_HYBRID;
+ }
+#else
+ ret = FIMGAPI_FINISHED;
+#endif
+
+#if (FIMGAPI_COMPROMISE_USE == FALSE)
+ if (FimgApiCheckPossible_Clipping(fimg) == false)
+ return false;
+#endif
+
+ FimgClip fimgClip = {fimg->clipT, fimg->clipB, fimg->clipL, fimg->clipR};
+ FimgFlag fimgFlag;
+
+ if (ret == FIMGAPI_HYBRID)
+ fimgFlag = {rotate, alpha, 0, 0, 0, 0, 0, 0, 0,
+ G2D_CACHE_OP | G2D_INTERRUPT | G2D_HYBRID_MODE, fimg->xfermode, G2D_MEMORY_USER};
+ else
+ fimgFlag = {rotate, alpha, 0, 0, 0, 0, 0, 0, 0,
+ G2D_CACHE_OP | G2D_INTERRUPT, fimg->xfermode, G2D_MEMORY_USER};
+
+ if (stretchFimgApi(&fimgSrcRect, &fimgDstRect, &fimgClip, &fimgFlag) < 0)
+ return false;
+
+ return ret;
+}
+
+int FimgApiSync(const char *func_name)
+{
+ if (SyncFimgApi() < 0)
+ return false;
+
+ return true;
+}
+#endif