summaryrefslogtreecommitdiffstats
path: root/services/surfaceflinger/tests
diff options
context:
space:
mode:
Diffstat (limited to 'services/surfaceflinger/tests')
-rw-r--r--services/surfaceflinger/tests/Transaction_test.cpp12
-rw-r--r--services/surfaceflinger/tests/resize/resize.cpp19
-rw-r--r--services/surfaceflinger/tests/surface/Android.mk18
-rw-r--r--services/surfaceflinger/tests/surface/surface.cpp66
4 files changed, 16 insertions, 99 deletions
diff --git a/services/surfaceflinger/tests/Transaction_test.cpp b/services/surfaceflinger/tests/Transaction_test.cpp
index 0592c5b..4d363c8 100644
--- a/services/surfaceflinger/tests/Transaction_test.cpp
+++ b/services/surfaceflinger/tests/Transaction_test.cpp
@@ -31,14 +31,14 @@ namespace android {
// Fill an RGBA_8888 formatted surface with a single color.
static void fillSurfaceRGBA8(const sp<SurfaceControl>& sc,
uint8_t r, uint8_t g, uint8_t b) {
- Surface::SurfaceInfo info;
+ ANativeWindow_Buffer outBuffer;
sp<Surface> s = sc->getSurface();
ASSERT_TRUE(s != NULL);
- ASSERT_EQ(NO_ERROR, s->lock(&info));
- uint8_t* img = reinterpret_cast<uint8_t*>(info.bits);
- for (uint32_t y = 0; y < info.h; y++) {
- for (uint32_t x = 0; x < info.w; x++) {
- uint8_t* pixel = img + (4 * (y*info.s + x));
+ ASSERT_EQ(NO_ERROR, s->lock(&outBuffer, NULL));
+ uint8_t* img = reinterpret_cast<uint8_t*>(outBuffer.bits);
+ for (uint32_t y = 0; y < outBuffer.height; y++) {
+ for (uint32_t x = 0; x < outBuffer.width; x++) {
+ uint8_t* pixel = img + (4 * (y*outBuffer.stride + x));
pixel[0] = r;
pixel[1] = g;
pixel[2] = b;
diff --git a/services/surfaceflinger/tests/resize/resize.cpp b/services/surfaceflinger/tests/resize/resize.cpp
index d61ea70..8b051e8 100644
--- a/services/surfaceflinger/tests/resize/resize.cpp
+++ b/services/surfaceflinger/tests/resize/resize.cpp
@@ -38,26 +38,27 @@ int main(int argc, char** argv)
// create a client to surfaceflinger
sp<SurfaceComposerClient> client = new SurfaceComposerClient();
- sp<Surface> surface = client->createSurface(String8("resize"),
+ sp<SurfaceControl> surfaceControl = client->createSurface(String8("resize"),
160, 240, PIXEL_FORMAT_RGB_565, 0);
+ sp<Surface> surface = surfaceControl->getSurface();
SurfaceComposerClient::openGlobalTransaction();
- surface->setLayer(100000);
+ surfaceControl->setLayer(100000);
SurfaceComposerClient::closeGlobalTransaction();
- Surface::SurfaceInfo info;
- surface->lock(&info);
- ssize_t bpr = info.s * bytesPerPixel(info.format);
- android_memset16((uint16_t*)info.bits, 0xF800, bpr*info.h);
+ ANativeWindow_Buffer outBuffer;
+ surface->lock(&outBuffer, NULL);
+ ssize_t bpr = outBuffer.stride * bytesPerPixel(outBuffer.format);
+ android_memset16((uint16_t*)outBuffer.bits, 0xF800, bpr*outBuffer.height);
surface->unlockAndPost();
- surface->lock(&info);
- android_memset16((uint16_t*)info.bits, 0x07E0, bpr*info.h);
+ surface->lock(&outBuffer);
+ android_memset16((uint16_t*)outBuffer.bits, 0x07E0, bpr*outBuffer.height);
surface->unlockAndPost();
SurfaceComposerClient::openGlobalTransaction();
- surface->setSize(320, 240);
+ surfaceControl->setSize(320, 240);
SurfaceComposerClient::closeGlobalTransaction();
diff --git a/services/surfaceflinger/tests/surface/Android.mk b/services/surfaceflinger/tests/surface/Android.mk
deleted file mode 100644
index c59060e..0000000
--- a/services/surfaceflinger/tests/surface/Android.mk
+++ /dev/null
@@ -1,18 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- surface.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libcutils \
- libutils \
- libbinder \
- libui \
- libgui
-
-LOCAL_MODULE:= test-surface
-
-LOCAL_MODULE_TAGS := tests
-
-include $(BUILD_EXECUTABLE)
diff --git a/services/surfaceflinger/tests/surface/surface.cpp b/services/surfaceflinger/tests/surface/surface.cpp
deleted file mode 100644
index 9c41cc3..0000000
--- a/services/surfaceflinger/tests/surface/surface.cpp
+++ /dev/null
@@ -1,66 +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 <cutils/memory.h>
-
-#include <utils/Log.h>
-
-#include <binder/IPCThreadState.h>
-#include <binder/ProcessState.h>
-#include <binder/IServiceManager.h>
-
-#include <gui/Surface.h>
-#include <gui/SurfaceComposerClient.h>
-
-using namespace android;
-
-int main(int argc, char** argv)
-{
- // set up the thread-pool
- sp<ProcessState> proc(ProcessState::self());
- ProcessState::self()->startThreadPool();
-
- // create a client to surfaceflinger
- sp<SurfaceComposerClient> client = new SurfaceComposerClient();
-
- sp<SurfaceControl> surfaceControl = client->createSurface(
- String8("surface"), 160, 240, PIXEL_FORMAT_RGB_565, 0);
- SurfaceComposerClient::openGlobalTransaction();
- surfaceControl->setLayer(100000);
- SurfaceComposerClient::closeGlobalTransaction();
-
- // pretend it went cross-process
- Parcel parcel;
- SurfaceControl::writeSurfaceToParcel(surfaceControl, &parcel);
- parcel.setDataPosition(0);
- sp<Surface> surface = Surface::readFromParcel(parcel);
- ANativeWindow* window = surface.get();
-
- printf("window=%p\n", window);
-
- int err = native_window_set_buffer_count(window, 8);
- ANativeWindowBuffer* buffer;
-
- for (int i=0 ; i<8 ; i++) {
- window->dequeueBuffer(window, &buffer);
- printf("buffer %d: %p\n", i, buffer);
- }
-
- printf("test complete. CTRL+C to finish.\n");
-
- IPCThreadState::self()->joinThreadPool();
- return 0;
-}