diff options
author | Michael Lentine <mlentine@google.com> | 2015-05-22 22:09:01 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-05-22 22:09:01 +0000 |
commit | a6d93f5573888574d63afd0b6b1941c0b4dfa7cf (patch) | |
tree | a3f14a15cb831bdef9f9f58a7edb782239656781 /services | |
parent | 5b46737df029600ee546564c15648b92dedbec28 (diff) | |
parent | 20828e633dd929b87c0297dadcdebb867f2b41d4 (diff) | |
download | frameworks_native-a6d93f5573888574d63afd0b6b1941c0b4dfa7cf.zip frameworks_native-a6d93f5573888574d63afd0b6b1941c0b4dfa7cf.tar.gz frameworks_native-a6d93f5573888574d63afd0b6b1941c0b4dfa7cf.tar.bz2 |
am 20828e63: Merge "Fix surfaceflinger tests." into mnc-dev
* commit '20828e633dd929b87c0297dadcdebb867f2b41d4':
Fix surfaceflinger tests.
Diffstat (limited to 'services')
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 6 | ||||
-rw-r--r-- | services/surfaceflinger/tests/Transaction_test.cpp | 46 |
2 files changed, 29 insertions, 23 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 0d57ae5..c612026 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -3337,8 +3337,8 @@ status_t SurfaceFlinger::captureScreenImplLocked( sp<Surface> sur = new Surface(producer, false); ANativeWindow* window = sur.get(); - status_t result = NO_ERROR; - if (native_window_api_connect(window, NATIVE_WINDOW_API_EGL) == NO_ERROR) { + status_t result = native_window_api_connect(window, NATIVE_WINDOW_API_EGL); + if (result == NO_ERROR) { uint32_t usage = GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN | GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE; @@ -3428,7 +3428,7 @@ status_t SurfaceFlinger::captureScreenImplLocked( result = BAD_VALUE; } // queueBuffer takes ownership of syncFd - window->queueBuffer(window, buffer, syncFd); + result = window->queueBuffer(window, buffer, syncFd); } } else { result = BAD_VALUE; diff --git a/services/surfaceflinger/tests/Transaction_test.cpp b/services/surfaceflinger/tests/Transaction_test.cpp index 4d363c8..dcde512 100644 --- a/services/surfaceflinger/tests/Transaction_test.cpp +++ b/services/surfaceflinger/tests/Transaction_test.cpp @@ -16,6 +16,8 @@ #include <gtest/gtest.h> +#include <android/native_window.h> + #include <binder/IMemory.h> #include <gui/ISurfaceComposer.h> @@ -53,21 +55,23 @@ static void fillSurfaceRGBA8(const sp<SurfaceControl>& sc, class ScreenCapture : public RefBase { public: static void captureScreen(sp<ScreenCapture>* sc) { - sp<IMemoryHeap> heap; - uint32_t w=0, h=0; - PixelFormat fmt=0; + sp<IGraphicBufferProducer> producer; + sp<IGraphicBufferConsumer> consumer; + BufferQueue::createBufferQueue(&producer, &consumer); + IGraphicBufferProducer::QueueBufferOutput bufferOutput; + sp<CpuConsumer> cpuConsumer = new CpuConsumer(consumer, 1); sp<ISurfaceComposer> sf(ComposerService::getComposerService()); - sp<IBinder> display(sf->getBuiltInDisplay(ISurfaceComposer::eDisplayIdMain)); - ASSERT_EQ(NO_ERROR, sf->captureScreen(display, &heap, &w, &h, &fmt, 0, 0, - 0, INT_MAX)); - ASSERT_TRUE(heap != NULL); - ASSERT_EQ(PIXEL_FORMAT_RGBA_8888, fmt); - *sc = new ScreenCapture(w, h, heap); + sp<IBinder> display(sf->getBuiltInDisplay( + ISurfaceComposer::eDisplayIdMain)); + ASSERT_EQ(NO_ERROR, sf->captureScreen(display, producer, Rect(), 0, 0, + 0, INT_MAX, false)); + *sc = new ScreenCapture(cpuConsumer); } void checkPixel(uint32_t x, uint32_t y, uint8_t r, uint8_t g, uint8_t b) { - const uint8_t* img = reinterpret_cast<const uint8_t*>(mHeap->base()); - const uint8_t* pixel = img + (4 * (y*mWidth + x)); + ASSERT_EQ(HAL_PIXEL_FORMAT_RGBA_8888, mBuf.format); + const uint8_t* img = static_cast<const uint8_t*>(mBuf.data); + const uint8_t* pixel = img + (4 * (y * mBuf.stride + x)); if (r != pixel[0] || g != pixel[1] || b != pixel[2]) { String8 err(String8::format("pixel @ (%3d, %3d): " "expected [%3d, %3d, %3d], got [%3d, %3d, %3d]", @@ -77,15 +81,17 @@ public: } private: - ScreenCapture(uint32_t w, uint32_t h, const sp<IMemoryHeap>& heap) : - mWidth(w), - mHeight(h), - mHeap(heap) - {} - - const uint32_t mWidth; - const uint32_t mHeight; - sp<IMemoryHeap> mHeap; + ScreenCapture(const sp<CpuConsumer>& cc) : + mCC(cc) { + EXPECT_EQ(NO_ERROR, mCC->lockNextBuffer(&mBuf)); + } + + ~ScreenCapture() { + mCC->unlockBuffer(mBuf); + } + + sp<CpuConsumer> mCC; + CpuConsumer::LockedBuffer mBuf; }; class LayerUpdateTest : public ::testing::Test { |