summaryrefslogtreecommitdiffstats
path: root/opengl
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2009-10-29 01:26:48 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2009-10-29 01:26:48 -0700
commit893cb4da1034870a8814394a1c3bdac10ca6cadf (patch)
treef4ba2333222c80a64c263cc58ad574433bc77952 /opengl
parentb07d14c26ef33b8aa94a815273d6cb2caac180f5 (diff)
parent73e17015d3cd67c93ccad5d63d31c439ff6fa694 (diff)
downloadframeworks_base-893cb4da1034870a8814394a1c3bdac10ca6cadf.zip
frameworks_base-893cb4da1034870a8814394a1c3bdac10ca6cadf.tar.gz
frameworks_base-893cb4da1034870a8814394a1c3bdac10ca6cadf.tar.bz2
am 73e17015: Merge change I8d2de438 into eclair
Merge commit '73e17015d3cd67c93ccad5d63d31c439ff6fa694' into eclair-mr2 * commit '73e17015d3cd67c93ccad5d63d31c439ff6fa694': fix [2143798] Need to figure out how to do video
Diffstat (limited to 'opengl')
-rw-r--r--opengl/libagl/Android.mk15
-rw-r--r--opengl/libagl/copybit.cpp100
2 files changed, 91 insertions, 24 deletions
diff --git a/opengl/libagl/Android.mk b/opengl/libagl/Android.mk
index 2522656..9837845 100644
--- a/opengl/libagl/Android.mk
+++ b/opengl/libagl/Android.mk
@@ -25,6 +25,13 @@ LOCAL_SRC_FILES:= \
primitives.cpp.arm \
vertex.cpp.arm
+LOCAL_CFLAGS += -DLOG_TAG=\"libagl\"
+LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
+LOCAL_CFLAGS += -fvisibility=hidden
+
+LOCAL_SHARED_LIBRARIES := libcutils libhardware libutils libpixelflinger
+LOCAL_LDLIBS := -lpthread -ldl
+
ifeq ($(TARGET_ARCH),arm)
LOCAL_SRC_FILES += fixed_asm.S iterators.S
LOCAL_CFLAGS += -fstrict-aliasing
@@ -38,15 +45,9 @@ endif
ifeq ($(LIBAGL_USE_GRALLOC_COPYBITS),1)
LOCAL_CFLAGS += -DLIBAGL_USE_GRALLOC_COPYBITS
LOCAL_SRC_FILES += copybit.cpp
+ LOCAL_SHARED_LIBRARIES += libui
endif
-LOCAL_CFLAGS += -DLOG_TAG=\"libagl\"
-LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
-
-LOCAL_SHARED_LIBRARIES := libcutils libhardware libutils libpixelflinger
-LOCAL_CFLAGS += -fvisibility=hidden
-
-LOCAL_LDLIBS := -lpthread -ldl
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/egl
LOCAL_MODULE:= libGLES_android
diff --git a/opengl/libagl/copybit.cpp b/opengl/libagl/copybit.cpp
index 73b2355..0c3d0ee 100644
--- a/opengl/libagl/copybit.cpp
+++ b/opengl/libagl/copybit.cpp
@@ -33,6 +33,10 @@
#include <hardware/copybit.h>
#include <private/ui/android_natives_priv.h>
+#include <ui/GraphicBuffer.h>
+#include <ui/Region.h>
+#include <ui/Rect.h>
+
#define DEBUG_COPYBIT true
@@ -175,16 +179,6 @@ static bool copybit(GLint x, GLint y,
dtdy /= screen_h;
}
dtdy = -dtdy; // see equation of dtdy above
- if (dsdx < c->copybits.minScale || dsdx > c->copybits.maxScale
- || dtdy < c->copybits.minScale || dtdy > c->copybits.maxScale) {
- // The requested scale is out of the range the hardware
- // can support.
- LOGD_IF(DEBUG_COPYBIT,
- "scale out of range dsdx=%08x (Wcr=%d / w=%d), "
- "dtdy=%08x (Hcr=%d / h=%d), Ucr=%d, Vcr=%d",
- dsdx, Wcr, w, dtdy, Hcr, h, Ucr, Vcr);
- return false;
- }
// copybit doesn't say anything about filtering, so we can't
// discriminate. On msm7k, copybit will always filter.
@@ -278,21 +272,93 @@ static bool copybit(GLint x, GLint y,
return false;
}
+ copybit_device_t* copybit = c->copybits.blitEngine;
+ copybit_image_t src;
+ buffer_handle_t source_hnd = textureObject->buffer->handle;
+ textureToCopyBitImage(&textureObject->surface, opFormat, source_hnd, &src);
+ copybit_rect_t srect = { Ucr, Vcr + Hcr, Ucr + Wcr, Vcr };
+
+ /*
+ * Below we perform extra passes needed to emulate things the h/w
+ * cannot do.
+ */
- // LOGW("calling copybits");
+ const GLfixed minScaleInv = gglDivQ(0x10000, c->copybits.minScale, 16);
+ const GLfixed maxScaleInv = gglDivQ(0x10000, c->copybits.maxScale, 16);
- copybit_device_t* copybit = c->copybits.blitEngine;
+ sp<GraphicBuffer> tempBitmap;
+
+ if (dsdx < maxScaleInv || dsdx > minScaleInv ||
+ dtdy < maxScaleInv || dtdy > minScaleInv)
+ {
+ // The requested scale is out of the range the hardware
+ // can support.
+ LOGD_IF(DEBUG_COPYBIT,
+ "scale out of range dsdx=%08x (Wcr=%d / w=%d), "
+ "dtdy=%08x (Hcr=%d / h=%d), Ucr=%d, Vcr=%d",
+ dsdx, Wcr, w, dtdy, Hcr, h, Ucr, Vcr);
+
+ int32_t xscale=0x10000, yscale=0x10000;
+ if (dsdx > minScaleInv) xscale = c->copybits.minScale;
+ else if (dsdx < maxScaleInv) xscale = c->copybits.maxScale;
+ if (dtdy > minScaleInv) yscale = c->copybits.minScale;
+ else if (dtdy < maxScaleInv) yscale = c->copybits.maxScale;
+ dsdx = gglMulx(dsdx, xscale);
+ dtdy = gglMulx(dtdy, yscale);
+
+ /* we handle only one step of resizing below. Handling an arbitrary
+ * number is relatively easy (replace "if" above by "while"), but requires
+ * two intermediate buffers and so far we never had the need.
+ */
+
+ if (dsdx < maxScaleInv || dsdx > minScaleInv ||
+ dtdy < maxScaleInv || dtdy > minScaleInv) {
+ LOGD_IF(DEBUG_COPYBIT,
+ "scale out of range dsdx=%08x (Wcr=%d / w=%d), "
+ "dtdy=%08x (Hcr=%d / h=%d), Ucr=%d, Vcr=%d",
+ dsdx, Wcr, w, dtdy, Hcr, h, Ucr, Vcr);
+ return false;
+ }
+
+ const int tmp_w = gglMulx(srect.r - srect.l, xscale, 16);
+ const int tmp_h = gglMulx(srect.b - srect.t, yscale, 16);
+
+ LOGD_IF(DEBUG_COPYBIT,
+ "xscale=%08x, yscale=%08x, dsdx=%08x, dtdy=%08x, tmp_w=%d, tmp_h=%d",
+ xscale, yscale, dsdx, dtdy, tmp_w, tmp_h);
+
+ tempBitmap = new GraphicBuffer(
+ tmp_w, tmp_h, src.format,
+ GraphicBuffer::USAGE_HW_2D);
+
+ status_t err = tempBitmap->initCheck();
+ if (err == NO_ERROR) {
+ copybit_image_t tmp_dst;
+ copybit_rect_t tmp_rect;
+ tmp_dst.w = tmp_w;
+ tmp_dst.h = tmp_h;
+ tmp_dst.format = src.format;
+ tmp_dst.handle = (native_handle_t*)tempBitmap->getNativeBuffer()->handle;
+ tmp_rect.l = 0;
+ tmp_rect.t = 0;
+ tmp_rect.r = tmp_dst.w;
+ tmp_rect.b = tmp_dst.h;
+ region_iterator tmp_it(Region(Rect(tmp_rect.r, tmp_rect.b)));
+ copybit->set_parameter(copybit, COPYBIT_TRANSFORM, 0);
+ copybit->set_parameter(copybit, COPYBIT_PLANE_ALPHA, 0xFF);
+ copybit->set_parameter(copybit, COPYBIT_DITHER, COPYBIT_DISABLE);
+ err = copybit->stretch(copybit,
+ &tmp_dst, &src, &tmp_rect, &srect, &tmp_it);
+ src = tmp_dst;
+ srect = tmp_rect;
+ }
+ }
copybit_image_t dst;
buffer_handle_t target_hnd = c->copybits.drawSurfaceBuffer;
textureToCopyBitImage(&cbSurface, cbSurface.format, target_hnd, &dst);
copybit_rect_t drect = {x, y, x+w, y+h};
- copybit_image_t src;
- buffer_handle_t source_hnd = textureObject->buffer->handle;
- textureToCopyBitImage(&textureObject->surface, opFormat, source_hnd, &src);
- copybit_rect_t srect = { Ucr, Vcr + Hcr, Ucr + Wcr, Vcr };
-
copybit->set_parameter(copybit, COPYBIT_TRANSFORM, transform);
copybit->set_parameter(copybit, COPYBIT_PLANE_ALPHA, planeAlpha);
copybit->set_parameter(copybit, COPYBIT_DITHER,