Merge "Fixing the lockless fifo destory bug. Removing unused code from element. build."
diff --git a/include/surfaceflinger/ISurfaceComposer.h b/include/surfaceflinger/ISurfaceComposer.h
index dba98a3..6b31ca4 100644
--- a/include/surfaceflinger/ISurfaceComposer.h
+++ b/include/surfaceflinger/ISurfaceComposer.h
@@ -132,9 +132,10 @@
virtual status_t turnElectronBeamOff(int32_t mode) = 0;
virtual status_t turnElectronBeamOn(int32_t mode) = 0;
- /* verify that an ISurface was created by SurfaceFlinger.
+ /* verify that an ISurfaceTexture was created by SurfaceFlinger.
*/
- virtual bool authenticateSurface(const sp<ISurface>& surface) const = 0;
+ virtual bool authenticateSurfaceTexture(
+ const sp<ISurfaceTexture>& surface) const = 0;
};
// ----------------------------------------------------------------------------
diff --git a/include/ui/KeycodeLabels.h b/include/ui/KeycodeLabels.h
index 8383957..2efe8ca 100755
--- a/include/ui/KeycodeLabels.h
+++ b/include/ui/KeycodeLabels.h
@@ -278,6 +278,8 @@
{ "WHEEL", 21 },
{ "GAS", 22 },
{ "BRAKE", 23 },
+ { "DISTANCE", 24 },
+ { "TILT", 25 },
{ "GENERIC_1", 32 },
{ "GENERIC_2", 33 },
{ "GENERIC_3", 34 },
diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp
index c1156d5..030a83e 100644
--- a/libs/gui/ISurfaceComposer.cpp
+++ b/libs/gui/ISurfaceComposer.cpp
@@ -31,6 +31,8 @@
#include <ui/DisplayInfo.h>
+#include <gui/ISurfaceTexture.h>
+
#include <utils/Log.h>
// ---------------------------------------------------------------------------
@@ -166,35 +168,36 @@
return reply.readInt32();
}
- virtual bool authenticateSurface(const sp<ISurface>& surface) const
+ virtual bool authenticateSurfaceTexture(
+ const sp<ISurfaceTexture>& surfaceTexture) const
{
Parcel data, reply;
int err = NO_ERROR;
err = data.writeInterfaceToken(
ISurfaceComposer::getInterfaceDescriptor());
if (err != NO_ERROR) {
- LOGE("ISurfaceComposer::authenticateSurface: error writing "
+ LOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
"interface descriptor: %s (%d)", strerror(-err), -err);
return false;
}
- err = data.writeStrongBinder(surface->asBinder());
+ err = data.writeStrongBinder(surfaceTexture->asBinder());
if (err != NO_ERROR) {
- LOGE("ISurfaceComposer::authenticateSurface: error writing strong "
- "binder to parcel: %s (%d)", strerror(-err), -err);
+ LOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
+ "strong binder to parcel: %s (%d)", strerror(-err), -err);
return false;
}
err = remote()->transact(BnSurfaceComposer::AUTHENTICATE_SURFACE, data,
&reply);
if (err != NO_ERROR) {
- LOGE("ISurfaceComposer::authenticateSurface: error performing "
- "transaction: %s (%d)", strerror(-err), -err);
+ LOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
+ "performing transaction: %s (%d)", strerror(-err), -err);
return false;
}
int32_t result = 0;
err = reply.readInt32(&result);
if (err != NO_ERROR) {
- LOGE("ISurfaceComposer::authenticateSurface: error retrieving "
- "result: %s (%d)", strerror(-err), -err);
+ LOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
+ "retrieving result: %s (%d)", strerror(-err), -err);
return false;
}
return result != 0;
@@ -291,8 +294,9 @@
} break;
case AUTHENTICATE_SURFACE: {
CHECK_INTERFACE(ISurfaceComposer, data, reply);
- sp<ISurface> surface = interface_cast<ISurface>(data.readStrongBinder());
- int32_t result = authenticateSurface(surface) ? 1 : 0;
+ sp<ISurfaceTexture> surfaceTexture =
+ interface_cast<ISurfaceTexture>(data.readStrongBinder());
+ int32_t result = authenticateSurfaceTexture(surfaceTexture) ? 1 : 0;
reply->writeInt32(result);
} break;
default:
diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp
index 2c70251..ff45fa3 100644
--- a/libs/gui/Surface.cpp
+++ b/libs/gui/Surface.cpp
@@ -342,9 +342,6 @@
int Surface::query(int what, int* value) const {
switch (what) {
- case NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER:
- *value = 1;
- return NO_ERROR;
case NATIVE_WINDOW_CONCRETE_TYPE:
*value = NATIVE_WINDOW_SURFACE;
return NO_ERROR;
@@ -354,13 +351,13 @@
// ----------------------------------------------------------------------------
-status_t Surface::lock(SurfaceInfo* other, Region* dirtyIn) {
+status_t Surface::lock(SurfaceInfo* other, Region* inOutDirtyRegion) {
ANativeWindow_Buffer outBuffer;
ARect temp;
ARect* inOutDirtyBounds = NULL;
- if (dirtyIn) {
- temp = dirtyIn->getBounds();
+ if (inOutDirtyRegion) {
+ temp = inOutDirtyRegion->getBounds();
inOutDirtyBounds = &temp;
}
@@ -374,6 +371,11 @@
other->format = uint32_t(outBuffer.format);
other->bits = outBuffer.bits;
}
+
+ if (inOutDirtyRegion) {
+ inOutDirtyRegion->set( static_cast<Rect const&>(temp) );
+ }
+
return err;
}
diff --git a/libs/gui/SurfaceTextureClient.cpp b/libs/gui/SurfaceTextureClient.cpp
index e91be84..5a35b4d 100644
--- a/libs/gui/SurfaceTextureClient.cpp
+++ b/libs/gui/SurfaceTextureClient.cpp
@@ -18,6 +18,8 @@
//#define LOG_NDEBUG 0
#include <gui/SurfaceTextureClient.h>
+#include <surfaceflinger/ISurfaceComposer.h>
+#include <surfaceflinger/SurfaceComposerClient.h>
#include <utils/Log.h>
@@ -234,7 +236,15 @@
}
break;
case NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER:
- *value = 0;
+ {
+ sp<ISurfaceComposer> composer(
+ ComposerService::getComposerService());
+ if (composer->authenticateSurfaceTexture(mSurfaceTexture)) {
+ *value = 1;
+ } else {
+ *value = 0;
+ }
+ }
return NO_ERROR;
case NATIVE_WINDOW_CONCRETE_TYPE:
*value = NATIVE_WINDOW_SURFACE_TEXTURE_CLIENT;
diff --git a/opengl/libagl/state.cpp b/opengl/libagl/state.cpp
index 8b4136a..90e9612 100644
--- a/opengl/libagl/state.cpp
+++ b/opengl/libagl/state.cpp
@@ -191,6 +191,9 @@
// these need to fall through into the rasterizer
c->rasterizer.procs.enableDisable(c, cap, enabled);
break;
+ case GL_TEXTURE_EXTERNAL_OES:
+ c->rasterizer.procs.enableDisable(c, GL_TEXTURE_2D, enabled);
+ break;
case GL_MULTISAMPLE:
case GL_SAMPLE_ALPHA_TO_COVERAGE:
diff --git a/opengl/libagl/texture.cpp b/opengl/libagl/texture.cpp
index 8eb17c4..88e8651 100644
--- a/opengl/libagl/texture.cpp
+++ b/opengl/libagl/texture.cpp
@@ -633,7 +633,7 @@
static void texParameterx(
GLenum target, GLenum pname, GLfixed param, ogles_context_t* c)
{
- if (target != GL_TEXTURE_2D) {
+ if (target != GL_TEXTURE_2D && target != GL_TEXTURE_EXTERNAL_OES) {
ogles_error(c, GL_INVALID_ENUM);
return;
}
@@ -866,7 +866,7 @@
void glBindTexture(GLenum target, GLuint texture)
{
ogles_context_t* c = ogles_context_t::get();
- if (target != GL_TEXTURE_2D) {
+ if (target != GL_TEXTURE_2D && target != GL_TEXTURE_EXTERNAL_OES) {
ogles_error(c, GL_INVALID_ENUM);
return;
}
@@ -1012,7 +1012,7 @@
GLenum target, GLenum pname, const GLint* params)
{
ogles_context_t* c = ogles_context_t::get();
- if (target != GGL_TEXTURE_2D) {
+ if (target != GL_TEXTURE_2D && target != GL_TEXTURE_EXTERNAL_OES) {
ogles_error(c, GL_INVALID_ENUM);
return;
}
@@ -1605,7 +1605,7 @@
void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image)
{
ogles_context_t* c = ogles_context_t::get();
- if (target != GL_TEXTURE_2D) {
+ if (target != GL_TEXTURE_2D && target != GL_TEXTURE_EXTERNAL_OES) {
ogles_error(c, GL_INVALID_ENUM);
return;
}
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 0425fc3..8b2485a 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -133,6 +133,11 @@
return sur;
}
+wp<IBinder> Layer::getSurfaceTextureBinder() const
+{
+ return mSurfaceTexture->asBinder();
+}
+
status_t Layer::setBuffers( uint32_t w, uint32_t h,
PixelFormat format, uint32_t flags)
{
@@ -191,13 +196,12 @@
* 1) buffer orientation/flip/mirror
* 2) state transformation (window manager)
* 3) layer orientation (screen orientation)
- * mOrientation is already the composition of (2) and (3)
+ * mTransform is already the composition of (2) and (3)
* (NOTE: the matrices are multiplied in reverse order)
*/
const Transform bufferOrientation(mCurrentTransform);
- const Transform layerOrientation(mOrientation);
- const Transform tr(layerOrientation * bufferOrientation);
+ const Transform tr(mTransform * bufferOrientation);
// this gives us only the "orientation" component of the transform
const uint32_t finalTransform = tr.getOrientation();
@@ -240,9 +244,6 @@
}
}
-static inline uint16_t pack565(int r, int g, int b) {
- return (r<<11)|(g<<5)|b;
-}
void Layer::onDraw(const Region& clip) const
{
if (CC_UNLIKELY(mActiveBuffer == 0)) {
@@ -256,7 +257,8 @@
// figure out if there is something below us
Region under;
- const SurfaceFlinger::LayerVector& drawingLayers(mFlinger->mDrawingState.layersSortedByZ);
+ const SurfaceFlinger::LayerVector& drawingLayers(
+ mFlinger->mDrawingState.layersSortedByZ);
const size_t count = drawingLayers.size();
for (size_t i=0 ; i<count ; ++i) {
const sp<LayerBase>& layer(drawingLayers[i]);
@@ -272,7 +274,7 @@
return;
}
- GLenum target = mSurfaceTexture->getCurrentTextureTarget();
+ const GLenum target = GL_TEXTURE_EXTERNAL_OES;
glBindTexture(target, mTextureName);
if (getFiltering() || needsFiltering() || isFixedSize() || isCropped()) {
// TODO: we could be more subtle with isFixedSize()
@@ -435,9 +437,8 @@
recomputeVisibleRegions = true;
}
- const GLenum target(mSurfaceTexture->getCurrentTextureTarget());
- glTexParameterx(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameterx(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glTexParameterx(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterx(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
// update the layer size and release freeze-lock
const Layer::State& front(drawingState());
@@ -537,9 +538,9 @@
snprintf(buffer, SIZE,
" "
"format=%2d, activeBuffer=[%4ux%4u:%4u,%3X],"
- " freezeLock=%p, queued-frames=%d\n",
+ " freezeLock=%p, transform-hint=0x%02x, queued-frames=%d\n",
mFormat, w0, h0, s0,f0,
- getFreezeLock().get(), mQueuedFrames);
+ getFreezeLock().get(), getTransformHint(), mQueuedFrames);
result.append(buffer);
@@ -558,6 +559,17 @@
return usage;
}
+uint32_t Layer::getTransformHint() const {
+ uint32_t orientation = 0;
+ if (!mFlinger->mDebugDisableTransformHint) {
+ orientation = getOrientation();
+ if (orientation & Transform::ROT_INVALID) {
+ orientation = 0;
+ }
+ }
+ return orientation;
+}
+
// ---------------------------------------------------------------------------
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index d3ddab4..d06a35f 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -74,6 +74,9 @@
virtual bool isProtected() const;
virtual void onRemoved();
+ // LayerBaseClient interface
+ virtual wp<IBinder> getSurfaceTextureBinder() const;
+
// only for debugging
inline const sp<FreezeLock>& getFreezeLock() const { return mFreezeLock; }
@@ -86,6 +89,7 @@
void onFrameQueued();
virtual sp<ISurface> createSurface();
uint32_t getEffectiveUsage(uint32_t usage) const;
+ uint32_t getTransformHint() const;
bool isCropped() const;
static bool getOpacityForFormat(uint32_t format);
diff --git a/services/surfaceflinger/LayerBase.cpp b/services/surfaceflinger/LayerBase.cpp
index e04c533..4cc245a 100644
--- a/services/surfaceflinger/LayerBase.cpp
+++ b/services/surfaceflinger/LayerBase.cpp
@@ -257,6 +257,7 @@
// cache a few things...
mOrientation = tr.getOrientation();
+ mTransform = tr;
mTransformedBounds = tr.makeBounds(w, h);
mLeft = tr.tx();
mTop = tr.ty();
@@ -544,6 +545,10 @@
return mClientSurfaceBinder;
}
+wp<IBinder> LayerBaseClient::getSurfaceTextureBinder() const {
+ return 0;
+}
+
void LayerBaseClient::dump(String8& result, char* buffer, size_t SIZE) const
{
LayerBase::dump(result, buffer, SIZE);
diff --git a/services/surfaceflinger/LayerBase.h b/services/surfaceflinger/LayerBase.h
index faf71dd..2cd3a94 100644
--- a/services/surfaceflinger/LayerBase.h
+++ b/services/surfaceflinger/LayerBase.h
@@ -247,6 +247,7 @@
protected:
// cached during validateVisibility()
int32_t mOrientation;
+ Transform mTransform;
GLfloat mVertices[4][2];
Rect mTransformedBounds;
int mLeft;
@@ -288,6 +289,7 @@
sp<ISurface> getSurface();
wp<IBinder> getSurfaceBinder() const;
+ virtual wp<IBinder> getSurfaceTextureBinder() const;
virtual sp<LayerBaseClient> getLayerBaseClient() const {
return const_cast<LayerBaseClient*>(this); }
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index a68ab30..0080202 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -93,6 +93,7 @@
mDebugBackground(0),
mDebugDDMS(0),
mDebugDisableHWC(0),
+ mDebugDisableTransformHint(0),
mDebugInSwapBuffers(0),
mLastSwapBufferTime(0),
mDebugInTransaction(0),
@@ -353,9 +354,10 @@
mEventQueue.invalidate();
}
-bool SurfaceFlinger::authenticateSurface(const sp<ISurface>& surface) const {
+bool SurfaceFlinger::authenticateSurfaceTexture(
+ const sp<ISurfaceTexture>& surfaceTexture) const {
Mutex::Autolock _l(mStateLock);
- sp<IBinder> surfBinder(surface->asBinder());
+ sp<IBinder> surfaceTextureBinder(surfaceTexture->asBinder());
// Check the visible layer list for the ISurface
const LayerVector& currentLayers = mCurrentState.layersSortedByZ;
@@ -363,14 +365,17 @@
for (size_t i=0 ; i<count ; i++) {
const sp<LayerBase>& layer(currentLayers[i]);
sp<LayerBaseClient> lbc(layer->getLayerBaseClient());
- if (lbc != NULL && lbc->getSurfaceBinder() == surfBinder) {
- return true;
+ if (lbc != NULL) {
+ wp<IBinder> lbcBinder = lbc->getSurfaceTextureBinder();
+ if (lbcBinder == surfaceTextureBinder) {
+ return true;
+ }
}
}
// Check the layers in the purgatory. This check is here so that if a
- // Surface gets destroyed before all the clients are done using it, the
- // error will not be reported as "surface XYZ is not authenticated", but
+ // SurfaceTexture gets destroyed before all the clients are done using it,
+ // the error will not be reported as "surface XYZ is not authenticated", but
// will instead fail later on when the client tries to use the surface,
// which should be reported as "surface XYZ returned an -ENODEV". The
// purgatorized layers are no less authentic than the visible ones, so this
@@ -379,8 +384,11 @@
for (size_t i=0 ; i<purgatorySize ; i++) {
const sp<LayerBase>& layer(mLayerPurgatory.itemAt(i));
sp<LayerBaseClient> lbc(layer->getLayerBaseClient());
- if (lbc != NULL && lbc->getSurfaceBinder() == surfBinder) {
- return true;
+ if (lbc != NULL) {
+ wp<IBinder> lbcBinder = lbc->getSurfaceTextureBinder();
+ if (lbcBinder == surfaceTextureBinder) {
+ return true;
+ }
}
}
@@ -815,7 +823,7 @@
hwc_layer_t* const cur(hwc.getLayers());
for (size_t i=0 ; cur && i<count ; i++) {
currentLayers[i]->setGeometry(&cur[i]);
- if (mDebugDisableHWC) {
+ if (mDebugDisableHWC || mDebugRegion) {
cur[i].compositionType = HWC_FRAMEBUFFER;
cur[i].flags |= HWC_SKIP_LAYER;
}
@@ -967,6 +975,10 @@
{
const DisplayHardware& hw(graphicPlane(0).displayHardware());
const uint32_t flags = hw.getFlags();
+ const int32_t height = hw.getHeight();
+ if (mInvalidRegion.isEmpty()) {
+ return;
+ }
if (!((flags & DisplayHardware::SWAP_RECTANGLE) ||
(flags & DisplayHardware::BUFFER_PRESERVED))) {
@@ -992,26 +1004,21 @@
while (it != end) {
const Rect& r = *it++;
GLfloat vertices[][2] = {
- { r.left, r.top },
- { r.left, r.bottom },
- { r.right, r.bottom },
- { r.right, r.top }
+ { r.left, height - r.top },
+ { r.left, height - r.bottom },
+ { r.right, height - r.bottom },
+ { r.right, height - r.top }
};
glVertexPointer(2, GL_FLOAT, 0, vertices);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
}
- if (mInvalidRegion.isEmpty()) {
- mDirtyRegion.dump("mDirtyRegion");
- mInvalidRegion.dump("mInvalidRegion");
- }
hw.flip(mInvalidRegion);
if (mDebugRegion > 1)
usleep(mDebugRegion * 1000);
glEnable(GL_SCISSOR_TEST);
- //mDirtyRegion.dump("mDirtyRegion");
}
void SurfaceFlinger::drawWormhole() const
@@ -1574,7 +1581,7 @@
HWComposer& hwc(hw.getHwComposer());
snprintf(buffer, SIZE, " h/w composer %s and %s\n",
hwc.initCheck()==NO_ERROR ? "present" : "not present",
- mDebugDisableHWC ? "disabled" : "enabled");
+ (mDebugDisableHWC || mDebugRegion) ? "disabled" : "enabled");
result.append(buffer);
hwc.dump(result, buffer, SIZE);
@@ -1653,21 +1660,15 @@
case 1002: // SHOW_UPDATES
n = data.readInt32();
mDebugRegion = n ? n : (mDebugRegion ? 0 : 1);
+ invalidateHwcGeometry();
+ repaintEverything();
return NO_ERROR;
case 1003: // SHOW_BACKGROUND
n = data.readInt32();
mDebugBackground = n ? 1 : 0;
return NO_ERROR;
- case 1008: // toggle use of hw composer
- n = data.readInt32();
- mDebugDisableHWC = n ? 1 : 0;
- invalidateHwcGeometry();
- // fall-through...
case 1004:{ // repaint everything
- Mutex::Autolock _l(mStateLock);
- const DisplayHardware& hw(graphicPlane(0).displayHardware());
- mDirtyRegion.set(hw.bounds()); // careful that's not thread-safe
- signalEvent();
+ repaintEverything();
return NO_ERROR;
}
case 1005:{ // force transaction
@@ -1683,6 +1684,18 @@
mFreezeCount = data.readInt32();
mFreezeDisplayTime = 0;
return NO_ERROR;
+ case 1008: // toggle use of hw composer
+ n = data.readInt32();
+ mDebugDisableHWC = n ? 1 : 0;
+ invalidateHwcGeometry();
+ repaintEverything();
+ return NO_ERROR;
+ case 1009: // toggle use of transform hint
+ n = data.readInt32();
+ mDebugDisableTransformHint = n ? 1 : 0;
+ invalidateHwcGeometry();
+ repaintEverything();
+ return NO_ERROR;
case 1010: // interrogate.
reply->writeInt32(0);
reply->writeInt32(0);
@@ -1700,6 +1713,13 @@
return err;
}
+void SurfaceFlinger::repaintEverything() {
+ Mutex::Autolock _l(mStateLock);
+ const DisplayHardware& hw(graphicPlane(0).displayHardware());
+ mDirtyRegion.set(hw.bounds()); // careful that's not thread-safe
+ signalEvent();
+}
+
// ---------------------------------------------------------------------------
status_t SurfaceFlinger::renderScreenToTextureLocked(DisplayID dpy,
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 89df0de..5f8eb08 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -171,7 +171,7 @@
virtual status_t freezeDisplay(DisplayID dpy, uint32_t flags);
virtual status_t unfreezeDisplay(DisplayID dpy, uint32_t flags);
virtual int setOrientation(DisplayID dpy, int orientation, uint32_t flags);
- virtual bool authenticateSurface(const sp<ISurface>& surface) const;
+ virtual bool authenticateSurfaceTexture(const sp<ISurfaceTexture>& surface) const;
virtual status_t captureScreen(DisplayID dpy,
sp<IMemoryHeap>* heap,
@@ -278,6 +278,7 @@
void handleRepaint();
void postFramebuffer();
void composeSurfaces(const Region& dirty);
+ void repaintEverything();
ssize_t addClientLayer(const sp<Client>& client,
@@ -373,6 +374,7 @@
int mDebugBackground;
int mDebugDDMS;
int mDebugDisableHWC;
+ int mDebugDisableTransformHint;
volatile nsecs_t mDebugInSwapBuffers;
nsecs_t mLastSwapBufferTime;
volatile nsecs_t mDebugInTransaction;
diff --git a/services/surfaceflinger/SurfaceTextureLayer.cpp b/services/surfaceflinger/SurfaceTextureLayer.cpp
index 79cd0c3..4390ca1 100644
--- a/services/surfaceflinger/SurfaceTextureLayer.cpp
+++ b/services/surfaceflinger/SurfaceTextureLayer.cpp
@@ -57,16 +57,10 @@
status_t res = SurfaceTexture::queueBuffer(buf, timestamp,
outWidth, outHeight, outTransform);
-
sp<Layer> layer(mLayer.promote());
if (layer != NULL) {
- uint32_t orientation = layer->getOrientation();
- if (orientation & Transform::ROT_INVALID) {
- orientation = 0;
- }
- *outTransform = orientation;
+ *outTransform = layer->getTransformHint();
}
-
return res;
}
diff --git a/services/surfaceflinger/TextureManager.cpp b/services/surfaceflinger/TextureManager.cpp
deleted file mode 100644
index bb63c37..0000000
--- a/services/surfaceflinger/TextureManager.cpp
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * 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.
- */
-
-#include <stdlib.h>
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <utils/Errors.h>
-#include <utils/Log.h>
-
-#include <ui/GraphicBuffer.h>
-
-#include <GLES/gl.h>
-#include <GLES/glext.h>
-
-#include <hardware/hardware.h>
-
-#include "clz.h"
-#include "DisplayHardware/DisplayHardware.h"
-#include "GLExtensions.h"
-#include "TextureManager.h"
-
-namespace android {
-
-// ---------------------------------------------------------------------------
-
-TextureManager::TextureManager()
- : mGLExtensions(GLExtensions::getInstance())
-{
-}
-
-GLenum TextureManager::getTextureTarget(const Image* image) {
-#if defined(GL_OES_EGL_image_external)
- switch (image->target) {
- case Texture::TEXTURE_EXTERNAL:
- return GL_TEXTURE_EXTERNAL_OES;
- }
-#endif
- return GL_TEXTURE_2D;
-}
-
-status_t TextureManager::initTexture(Texture* texture)
-{
- if (texture->name != -1UL)
- return INVALID_OPERATION;
-
- GLuint textureName = -1;
- glGenTextures(1, &textureName);
- texture->name = textureName;
- texture->width = 0;
- texture->height = 0;
-
- const GLenum target = GL_TEXTURE_2D;
- glBindTexture(target, textureName);
- glTexParameterx(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameterx(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- glTexParameterx(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameterx(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-
- return NO_ERROR;
-}
-
-status_t TextureManager::initTexture(Image* pImage, int32_t format)
-{
- if (pImage->name != -1UL)
- return INVALID_OPERATION;
-
- GLuint textureName = -1;
- glGenTextures(1, &textureName);
- pImage->name = textureName;
- pImage->width = 0;
- pImage->height = 0;
-
- GLenum target = GL_TEXTURE_2D;
-#if defined(GL_OES_EGL_image_external)
- if (GLExtensions::getInstance().haveTextureExternal()) {
- if (format && isYuvFormat(format)) {
- target = GL_TEXTURE_EXTERNAL_OES;
- pImage->target = Texture::TEXTURE_EXTERNAL;
- }
- }
-#endif
-
- glBindTexture(target, textureName);
- glTexParameterx(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameterx(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- glTexParameterx(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameterx(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-
- return NO_ERROR;
-}
-
-bool TextureManager::isSupportedYuvFormat(int format)
-{
- switch (format) {
- case HAL_PIXEL_FORMAT_YV12:
- return true;
- }
- return false;
-}
-
-bool TextureManager::isYuvFormat(int format)
-{
- switch (format) {
- // supported YUV formats
- case HAL_PIXEL_FORMAT_YV12:
- // Legacy/deprecated YUV formats
- case HAL_PIXEL_FORMAT_YCbCr_422_SP:
- case HAL_PIXEL_FORMAT_YCrCb_420_SP:
- case HAL_PIXEL_FORMAT_YCbCr_422_I:
- return true;
- }
-
- // Any OEM format needs to be considered
- if (format>=0x100 && format<=0x1FF)
- return true;
-
- return false;
-}
-
-status_t TextureManager::initEglImage(Image* pImage,
- EGLDisplay dpy, const sp<GraphicBuffer>& buffer)
-{
- status_t err = NO_ERROR;
- if (!pImage->dirty) return err;
-
- // free the previous image
- if (pImage->image != EGL_NO_IMAGE_KHR) {
- eglDestroyImageKHR(dpy, pImage->image);
- pImage->image = EGL_NO_IMAGE_KHR;
- }
-
- // construct an EGL_NATIVE_BUFFER_ANDROID
- ANativeWindowBuffer* clientBuf = buffer->getNativeBuffer();
-
- // create the new EGLImageKHR
- const EGLint attrs[] = {
- EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
- EGL_NONE, EGL_NONE
- };
- pImage->image = eglCreateImageKHR(
- dpy, EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID,
- (EGLClientBuffer)clientBuf, attrs);
-
- if (pImage->image != EGL_NO_IMAGE_KHR) {
- if (pImage->name == -1UL) {
- initTexture(pImage, buffer->format);
- }
- const GLenum target = getTextureTarget(pImage);
- glBindTexture(target, pImage->name);
- glEGLImageTargetTexture2DOES(target, (GLeglImageOES)pImage->image);
- GLint error = glGetError();
- if (error != GL_NO_ERROR) {
- LOGE("glEGLImageTargetTexture2DOES(%p) failed err=0x%04x",
- pImage->image, error);
- err = INVALID_OPERATION;
- } else {
- // Everything went okay!
- pImage->dirty = false;
- pImage->width = clientBuf->width;
- pImage->height = clientBuf->height;
- }
- } else {
- LOGE("eglCreateImageKHR() failed. err=0x%4x", eglGetError());
- err = INVALID_OPERATION;
- }
- return err;
-}
-
-status_t TextureManager::loadTexture(Texture* texture,
- const Region& dirty, const GGLSurface& t)
-{
- if (texture->name == -1UL) {
- status_t err = initTexture(texture);
- LOGE_IF(err, "loadTexture failed in initTexture (%s)", strerror(err));
- if (err != NO_ERROR) return err;
- }
-
- if (texture->target != Texture::TEXTURE_2D)
- return INVALID_OPERATION;
-
- glBindTexture(GL_TEXTURE_2D, texture->name);
-
- /*
- * In OpenGL ES we can't specify a stride with glTexImage2D (however,
- * GL_UNPACK_ALIGNMENT is a limited form of stride).
- * So if the stride here isn't representable with GL_UNPACK_ALIGNMENT, we
- * need to do something reasonable (here creating a bigger texture).
- *
- * extra pixels = (((stride - width) * pixelsize) / GL_UNPACK_ALIGNMENT);
- *
- * This situation doesn't happen often, but some h/w have a limitation
- * for their framebuffer (eg: must be multiple of 8 pixels), and
- * we need to take that into account when using these buffers as
- * textures.
- *
- * This should never be a problem with POT textures
- */
-
- int unpack = __builtin_ctz(t.stride * bytesPerPixel(t.format));
- unpack = 1 << ((unpack > 3) ? 3 : unpack);
- glPixelStorei(GL_UNPACK_ALIGNMENT, unpack);
-
- /*
- * round to POT if needed
- */
- if (!mGLExtensions.haveNpot()) {
- texture->NPOTAdjust = true;
- }
-
- if (texture->NPOTAdjust) {
- // find the smallest power-of-two that will accommodate our surface
- texture->potWidth = 1 << (31 - clz(t.width));
- texture->potHeight = 1 << (31 - clz(t.height));
- if (texture->potWidth < t.width) texture->potWidth <<= 1;
- if (texture->potHeight < t.height) texture->potHeight <<= 1;
- texture->wScale = float(t.width) / texture->potWidth;
- texture->hScale = float(t.height) / texture->potHeight;
- } else {
- texture->potWidth = t.width;
- texture->potHeight = t.height;
- }
-
- Rect bounds(dirty.bounds());
- GLvoid* data = 0;
- if (texture->width != t.width || texture->height != t.height) {
- texture->width = t.width;
- texture->height = t.height;
-
- // texture size changed, we need to create a new one
- bounds.set(Rect(t.width, t.height));
- if (t.width == texture->potWidth &&
- t.height == texture->potHeight) {
- // we can do it one pass
- data = t.data;
- }
-
- if (t.format == HAL_PIXEL_FORMAT_RGB_565) {
- glTexImage2D(GL_TEXTURE_2D, 0,
- GL_RGB, texture->potWidth, texture->potHeight, 0,
- GL_RGB, GL_UNSIGNED_SHORT_5_6_5, data);
- } else if (t.format == HAL_PIXEL_FORMAT_RGBA_4444) {
- glTexImage2D(GL_TEXTURE_2D, 0,
- GL_RGBA, texture->potWidth, texture->potHeight, 0,
- GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, data);
- } else if (t.format == HAL_PIXEL_FORMAT_RGBA_8888 ||
- t.format == HAL_PIXEL_FORMAT_RGBX_8888) {
- glTexImage2D(GL_TEXTURE_2D, 0,
- GL_RGBA, texture->potWidth, texture->potHeight, 0,
- GL_RGBA, GL_UNSIGNED_BYTE, data);
- } else if (isSupportedYuvFormat(t.format)) {
- // just show the Y plane of YUV buffers
- glTexImage2D(GL_TEXTURE_2D, 0,
- GL_LUMINANCE, texture->potWidth, texture->potHeight, 0,
- GL_LUMINANCE, GL_UNSIGNED_BYTE, data);
- } else {
- // oops, we don't handle this format!
- LOGE("texture=%d, using format %d, which is not "
- "supported by the GL", texture->name, t.format);
- }
- }
- if (!data) {
- if (t.format == HAL_PIXEL_FORMAT_RGB_565) {
- glTexSubImage2D(GL_TEXTURE_2D, 0,
- 0, bounds.top, t.width, bounds.height(),
- GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
- t.data + bounds.top*t.stride*2);
- } else if (t.format == HAL_PIXEL_FORMAT_RGBA_4444) {
- glTexSubImage2D(GL_TEXTURE_2D, 0,
- 0, bounds.top, t.width, bounds.height(),
- GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4,
- t.data + bounds.top*t.stride*2);
- } else if (t.format == HAL_PIXEL_FORMAT_RGBA_8888 ||
- t.format == HAL_PIXEL_FORMAT_RGBX_8888) {
- glTexSubImage2D(GL_TEXTURE_2D, 0,
- 0, bounds.top, t.width, bounds.height(),
- GL_RGBA, GL_UNSIGNED_BYTE,
- t.data + bounds.top*t.stride*4);
- } else if (isSupportedYuvFormat(t.format)) {
- // just show the Y plane of YUV buffers
- glTexSubImage2D(GL_TEXTURE_2D, 0,
- 0, bounds.top, t.width, bounds.height(),
- GL_LUMINANCE, GL_UNSIGNED_BYTE,
- t.data + bounds.top*t.stride);
- }
- }
- return NO_ERROR;
-}
-
-void TextureManager::activateTexture(const Texture& texture, bool filter)
-{
- const GLenum target = getTextureTarget(&texture);
- if (target == GL_TEXTURE_2D) {
- glBindTexture(GL_TEXTURE_2D, texture.name);
- glEnable(GL_TEXTURE_2D);
-#if defined(GL_OES_EGL_image_external)
- if (GLExtensions::getInstance().haveTextureExternal()) {
- glDisable(GL_TEXTURE_EXTERNAL_OES);
- }
- } else {
- glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture.name);
- glEnable(GL_TEXTURE_EXTERNAL_OES);
- glDisable(GL_TEXTURE_2D);
-#endif
- }
-
- if (filter) {
- glTexParameterx(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameterx(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- } else {
- glTexParameterx(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameterx(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- }
-}
-
-void TextureManager::deactivateTextures()
-{
- glDisable(GL_TEXTURE_2D);
-#if defined(GL_OES_EGL_image_external)
- if (GLExtensions::getInstance().haveTextureExternal()) {
- glDisable(GL_TEXTURE_EXTERNAL_OES);
- }
-#endif
-}
-
-// ---------------------------------------------------------------------------
-
-}; // namespace android
diff --git a/services/surfaceflinger/TextureManager.h b/services/surfaceflinger/TextureManager.h
deleted file mode 100644
index 18c4348..0000000
--- a/services/surfaceflinger/TextureManager.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * 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 ANDROID_TEXTURE_MANAGER_H
-#define ANDROID_TEXTURE_MANAGER_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
-#include <GLES/gl.h>
-
-#include <ui/Region.h>
-
-#include <pixelflinger/pixelflinger.h>
-
-namespace android {
-
-// ---------------------------------------------------------------------------
-
-class GLExtensions;
-class GraphicBuffer;
-
-// ---------------------------------------------------------------------------
-
-struct Image {
- enum { TEXTURE_2D=0, TEXTURE_EXTERNAL=1 };
- Image() : name(-1U), image(EGL_NO_IMAGE_KHR), width(0), height(0),
- dirty(1), target(TEXTURE_2D) { }
- GLuint name;
- EGLImageKHR image;
- GLuint width;
- GLuint height;
- unsigned dirty : 1;
- unsigned target : 1;
-};
-
-struct Texture : public Image {
- Texture() : Image(), NPOTAdjust(0) { }
- GLuint potWidth;
- GLuint potHeight;
- GLfloat wScale;
- GLfloat hScale;
- unsigned NPOTAdjust : 1;
-};
-
-// ---------------------------------------------------------------------------
-
-class TextureManager {
- const GLExtensions& mGLExtensions;
- static status_t initTexture(Image* texture, int32_t format);
- static status_t initTexture(Texture* texture);
- static bool isSupportedYuvFormat(int format);
- static bool isYuvFormat(int format);
- static GLenum getTextureTarget(const Image* pImage);
-public:
-
- TextureManager();
-
- // load bitmap data into the active buffer
- status_t loadTexture(Texture* texture,
- const Region& dirty, const GGLSurface& t);
-
- // make active buffer an EGLImage if needed
- status_t initEglImage(Image* texture,
- EGLDisplay dpy, const sp<GraphicBuffer>& buffer);
-
- // activate a texture
- static void activateTexture(const Texture& texture, bool filter);
-
- // deactivate a texture
- static void deactivateTextures();
-};
-
-// ---------------------------------------------------------------------------
-
-}; // namespace android
-
-#endif // ANDROID_TEXTURE_MANAGER_H