diff options
37 files changed, 741 insertions, 390 deletions
diff --git a/include/gui/Sensor.h b/include/gui/Sensor.h index 28a08e2238..59b4d4dd60 100644 --- a/include/gui/Sensor.h +++ b/include/gui/Sensor.h @@ -98,7 +98,7 @@ private: String8 mStringType; String8 mRequiredPermission; int32_t mMaxDelay; - int32_t mFlags; + uint32_t mFlags; static void flattenString8(void*& buffer, size_t& size, const String8& string8); static bool unflattenString8(void const*& buffer, size_t& size, String8& outputString8); }; diff --git a/include/input/IInputFlinger.h b/include/input/IInputFlinger.h new file mode 100644 index 0000000000..79ff12a664 --- /dev/null +++ b/include/input/IInputFlinger.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2013 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 _LIBINPUT_IINPUT_FLINGER_H +#define _LIBINPUT_IINPUT_FLINGER_H + +#include <stdint.h> +#include <sys/types.h> + +#include <binder/IInterface.h> + +namespace android { + +/* + * This class defines the Binder IPC interface for accessing various + * InputFlinger features. + */ +class IInputFlinger : public IInterface { +public: + DECLARE_META_INTERFACE(InputFlinger); + + virtual status_t doSomething() = 0; +}; + + +/** + * Binder implementation. + */ +class BnInputFlinger : public BnInterface<IInputFlinger> { +public: + enum { + DO_SOMETHING_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION, + }; + + virtual status_t onTransact(uint32_t code, const Parcel& data, + Parcel* reply, uint32_t flags = 0); +}; + +} // namespace android + +#endif // _LIBINPUT_IINPUT_FLINGER_H diff --git a/include/media/openmax/OMX_IVCommon.h b/include/media/openmax/OMX_IVCommon.h index a5b9d18764..f9b6f4b0fd 100644 --- a/include/media/openmax/OMX_IVCommon.h +++ b/include/media/openmax/OMX_IVCommon.h @@ -157,6 +157,7 @@ typedef enum OMX_COLOR_FORMATTYPE { * an acceptable range once that is done. * */ OMX_COLOR_FormatAndroidOpaque = 0x7F000789, + OMX_COLOR_Format32BitRGBA8888 = 0x7F00A000, /** Flexible 8-bit YUV format. Codec should report this format * as being supported if it supports any YUV420 packed planar * or semiplanar formats. When port is set to use this format, diff --git a/include/ui/Fence.h b/include/ui/Fence.h index 20466b616e..b431bd52aa 100644 --- a/include/ui/Fence.h +++ b/include/ui/Fence.h @@ -65,7 +65,7 @@ public: // before the fence signals then -ETIME is returned. A timeout of // TIMEOUT_NEVER may be used to indicate that the call should wait // indefinitely for the fence to signal. - status_t wait(unsigned int timeout); + status_t wait(int timeout); // waitForever is a convenience function for waiting forever for a fence to // signal (just like wait(TIMEOUT_NEVER)), but issuing an error to the diff --git a/include/ui/FramebufferNativeWindow.h b/include/ui/FramebufferNativeWindow.h index 5cd8101d30..6b66d5f66b 100644 --- a/include/ui/FramebufferNativeWindow.h +++ b/include/ui/FramebufferNativeWindow.h @@ -14,11 +14,13 @@ * limitations under the License. */ +#ifndef INCLUDED_FROM_FRAMEBUFFER_NATIVE_WINDOW_CPP +#warning "FramebufferNativeWindow is deprecated" +#endif + #ifndef ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H #define ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H -#warning "FramebufferNativeWindow is deprecated" - #include <stdint.h> #include <sys/types.h> diff --git a/include/ui/GraphicBuffer.h b/include/ui/GraphicBuffer.h index 7630faa762..cea94fc7b4 100644 --- a/include/ui/GraphicBuffer.h +++ b/include/ui/GraphicBuffer.h @@ -49,7 +49,7 @@ public: USAGE_SW_READ_RARELY = GRALLOC_USAGE_SW_READ_RARELY, USAGE_SW_READ_OFTEN = GRALLOC_USAGE_SW_READ_OFTEN, USAGE_SW_READ_MASK = GRALLOC_USAGE_SW_READ_MASK, - + USAGE_SW_WRITE_NEVER = GRALLOC_USAGE_SW_WRITE_NEVER, USAGE_SW_WRITE_RARELY = GRALLOC_USAGE_SW_WRITE_RARELY, USAGE_SW_WRITE_OFTEN = GRALLOC_USAGE_SW_WRITE_OFTEN, @@ -72,11 +72,13 @@ public: GraphicBuffer(); // creates w * h buffer - GraphicBuffer(uint32_t w, uint32_t h, PixelFormat format, uint32_t usage); + GraphicBuffer(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat, + uint32_t inUsage); // create a buffer from an existing handle - GraphicBuffer(uint32_t w, uint32_t h, PixelFormat format, uint32_t usage, - uint32_t stride, native_handle_t* handle, bool keepOwnership); + GraphicBuffer(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat, + uint32_t inUsage, uint32_t inStride, native_handle_t* inHandle, + bool keepOwnership); // create a buffer from an existing ANativeWindowBuffer GraphicBuffer(ANativeWindowBuffer* buffer, bool keepOwnership); @@ -84,26 +86,31 @@ public: // return status status_t initCheck() const; - uint32_t getWidth() const { return width; } - uint32_t getHeight() const { return height; } - uint32_t getStride() const { return stride; } - uint32_t getUsage() const { return usage; } + uint32_t getWidth() const { return static_cast<uint32_t>(width); } + uint32_t getHeight() const { return static_cast<uint32_t>(height); } + uint32_t getStride() const { return static_cast<uint32_t>(stride); } + uint32_t getUsage() const { return static_cast<uint32_t>(usage); } PixelFormat getPixelFormat() const { return format; } Rect getBounds() const { return Rect(width, height); } uint64_t getId() const { return mId; } - status_t reallocate(uint32_t w, uint32_t h, PixelFormat f, uint32_t usage); + status_t reallocate(uint32_t inWidth, uint32_t inHeight, + PixelFormat inFormat, uint32_t inUsage); - status_t lock(uint32_t usage, void** vaddr); - status_t lock(uint32_t usage, const Rect& rect, void** vaddr); + status_t lock(uint32_t inUsage, void** vaddr); + status_t lock(uint32_t inUsage, const Rect& rect, void** vaddr); // For HAL_PIXEL_FORMAT_YCbCr_420_888 - status_t lockYCbCr(uint32_t usage, android_ycbcr *ycbcr); - status_t lockYCbCr(uint32_t usage, const Rect& rect, android_ycbcr *ycbcr); + status_t lockYCbCr(uint32_t inUsage, android_ycbcr *ycbcr); + status_t lockYCbCr(uint32_t inUsage, const Rect& rect, + android_ycbcr *ycbcr); status_t unlock(); - status_t lockAsync(uint32_t usage, void** vaddr, int fenceFd); - status_t lockAsync(uint32_t usage, const Rect& rect, void** vaddr, int fenceFd); - status_t lockAsyncYCbCr(uint32_t usage, android_ycbcr *ycbcr, int fenceFd); - status_t lockAsyncYCbCr(uint32_t usage, const Rect& rect, android_ycbcr *ycbcr, int fenceFd); + status_t lockAsync(uint32_t inUsage, void** vaddr, int fenceFd); + status_t lockAsync(uint32_t inUsage, const Rect& rect, void** vaddr, + int fenceFd); + status_t lockAsyncYCbCr(uint32_t inUsage, android_ycbcr *ycbcr, + int fenceFd); + status_t lockAsyncYCbCr(uint32_t inUsage, const Rect& rect, + android_ycbcr *ycbcr, int fenceFd); status_t unlockAsync(int *fenceFd); ANativeWindowBuffer* getNativeBuffer() const; @@ -143,8 +150,8 @@ private: GraphicBuffer& operator = (const GraphicBuffer& rhs); const GraphicBuffer& operator = (const GraphicBuffer& rhs) const; - status_t initSize(uint32_t w, uint32_t h, PixelFormat format, - uint32_t usage); + status_t initSize(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat, + uint32_t inUsage); void free_handle(); diff --git a/include/ui/GraphicBufferAllocator.h b/include/ui/GraphicBufferAllocator.h index dffa788f46..5443f09a10 100644 --- a/include/ui/GraphicBufferAllocator.h +++ b/include/ui/GraphicBufferAllocator.h @@ -1,17 +1,17 @@ -/* +/* ** ** Copyright 2009, 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 +** 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 +** 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 +** 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. */ @@ -45,14 +45,14 @@ public: USAGE_SW_READ_RARELY = GRALLOC_USAGE_SW_READ_RARELY, USAGE_SW_READ_OFTEN = GRALLOC_USAGE_SW_READ_OFTEN, USAGE_SW_READ_MASK = GRALLOC_USAGE_SW_READ_MASK, - + USAGE_SW_WRITE_NEVER = GRALLOC_USAGE_SW_WRITE_NEVER, USAGE_SW_WRITE_RARELY = GRALLOC_USAGE_SW_WRITE_RARELY, USAGE_SW_WRITE_OFTEN = GRALLOC_USAGE_SW_WRITE_OFTEN, USAGE_SW_WRITE_MASK = GRALLOC_USAGE_SW_WRITE_MASK, - + USAGE_SOFTWARE_MASK = USAGE_SW_READ_MASK|USAGE_SW_WRITE_MASK, - + USAGE_HW_TEXTURE = GRALLOC_USAGE_HW_TEXTURE, USAGE_HW_RENDER = GRALLOC_USAGE_HW_RENDER, USAGE_HW_2D = GRALLOC_USAGE_HW_2D, @@ -60,10 +60,9 @@ public: }; static inline GraphicBufferAllocator& get() { return getInstance(); } - - status_t alloc(uint32_t w, uint32_t h, PixelFormat format, int usage, - buffer_handle_t* handle, int32_t* stride); + status_t alloc(uint32_t w, uint32_t h, PixelFormat format, uint32_t usage, + buffer_handle_t* handle, uint32_t* stride); status_t free(buffer_handle_t handle); @@ -72,21 +71,21 @@ public: private: struct alloc_rec_t { - uint32_t w; - uint32_t h; - uint32_t s; + uint32_t width; + uint32_t height; + uint32_t stride; PixelFormat format; uint32_t usage; size_t size; }; - + static Mutex sLock; static KeyedVector<buffer_handle_t, alloc_rec_t> sAllocList; - + friend class Singleton<GraphicBufferAllocator>; GraphicBufferAllocator(); ~GraphicBufferAllocator(); - + alloc_device_t *mAllocDev; }; diff --git a/include/ui/GraphicBufferMapper.h b/include/ui/GraphicBufferMapper.h index 98fff0ef31..6099548aaf 100644 --- a/include/ui/GraphicBufferMapper.h +++ b/include/ui/GraphicBufferMapper.h @@ -41,23 +41,24 @@ public: status_t registerBuffer(buffer_handle_t handle); status_t unregisterBuffer(buffer_handle_t handle); - + status_t lock(buffer_handle_t handle, - int usage, const Rect& bounds, void** vaddr); + uint32_t usage, const Rect& bounds, void** vaddr); status_t lockYCbCr(buffer_handle_t handle, - int usage, const Rect& bounds, android_ycbcr *ycbcr); + uint32_t usage, const Rect& bounds, android_ycbcr *ycbcr); status_t unlock(buffer_handle_t handle); status_t lockAsync(buffer_handle_t handle, - int usage, const Rect& bounds, void** vaddr, int fenceFd); + uint32_t usage, const Rect& bounds, void** vaddr, int fenceFd); status_t lockAsyncYCbCr(buffer_handle_t handle, - int usage, const Rect& bounds, android_ycbcr *ycbcr, int fenceFd); + uint32_t usage, const Rect& bounds, android_ycbcr *ycbcr, + int fenceFd); status_t unlockAsync(buffer_handle_t handle, int *fenceFd); - + // dumps information about the mapping of this handle void dump(buffer_handle_t handle); diff --git a/include/ui/PixelFormat.h b/include/ui/PixelFormat.h index 7e469453fd..e7e8ffc29b 100644 --- a/include/ui/PixelFormat.h +++ b/include/ui/PixelFormat.h @@ -25,9 +25,6 @@ #ifndef UI_PIXELFORMAT_H #define UI_PIXELFORMAT_H -#include <stdint.h> -#include <sys/types.h> -#include <utils/Errors.h> #include <hardware/hardware.h> namespace android { @@ -69,8 +66,8 @@ enum { typedef int32_t PixelFormat; -ssize_t bytesPerPixel(PixelFormat format); -ssize_t bitsPerPixel(PixelFormat format); +uint32_t bytesPerPixel(PixelFormat format); +uint32_t bitsPerPixel(PixelFormat format); }; // namespace android diff --git a/include/ui/Region.h b/include/ui/Region.h index 0d1c68c951..873cd34508 100644 --- a/include/ui/Region.h +++ b/include/ui/Region.h @@ -55,11 +55,11 @@ public: // the region becomes its bounds Region& makeBoundsSelf(); - + void clear(); void set(const Rect& r); - void set(uint32_t w, uint32_t h); - + void set(int32_t w, int32_t h); + Region& orSelf(const Rect& rhs); Region& xorSelf(const Rect& rhs); Region& andSelf(const Rect& rhs); @@ -110,14 +110,14 @@ public: inline Region& operator -= (const Region& rhs); inline Region& operator += (const Point& pt); - + // returns true if the regions share the same underlying storage bool isTriviallyEqual(const Region& region) const; /* various ways to access the rectangle list */ - + // STL-like iterators typedef Rect const* const_iterator; const_iterator begin() const; @@ -133,7 +133,7 @@ public: SharedBuffer const* getSharedBuffer(size_t* count) const; /* no user serviceable parts here... */ - + // add a rectangle to the internal list. This rectangle must // be sorted in Y and X and must not make the region invalid. void addRectUnchecked(int l, int t, int r, int b); @@ -149,7 +149,7 @@ public: private: class rasterizer; friend class rasterizer; - + Region& operationSelf(const Rect& r, int op); Region& operationSelf(const Region& r, int op); Region& operationSelf(const Region& r, int dx, int dy, int op); @@ -172,7 +172,7 @@ private: static bool validate(const Region& reg, const char* name, bool silent = false); - + // mStorage is a (manually) sorted array of Rects describing the region // with an extra Rect as the last element which is set to the // bounds of the region. However, if the region is diff --git a/libs/gui/Android.mk b/libs/gui/Android.mk index ca94aa3990..fffe28af11 100644 --- a/libs/gui/Android.mk +++ b/libs/gui/Android.mk @@ -1,7 +1,10 @@ -LOCAL_PATH:= $(call my-dir) +LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) -LOCAL_SRC_FILES:= \ +LOCAL_CLANG := true +LOCAL_CPPFLAGS := -std=c++11 + +LOCAL_SRC_FILES := \ IGraphicBufferConsumer.cpp \ IConsumerListener.cpp \ BitTube.cpp \ @@ -47,7 +50,7 @@ LOCAL_SHARED_LIBRARIES := \ liblog -LOCAL_MODULE:= libgui +LOCAL_MODULE := libgui ifeq ($(TARGET_BOARD_PLATFORM), tegra) LOCAL_CFLAGS += -DDONT_USE_FENCE_SYNC diff --git a/libs/gui/SensorEventQueue.cpp b/libs/gui/SensorEventQueue.cpp index 1305e9f63a..6f5f204fe3 100644 --- a/libs/gui/SensorEventQueue.cpp +++ b/libs/gui/SensorEventQueue.cpp @@ -157,7 +157,7 @@ void SensorEventQueue::sendAck(const ASensorEvent* events, int count) { ssize_t size = ::send(mSensorChannel->getFd(), &mNumAcksToSend, sizeof(mNumAcksToSend), MSG_DONTWAIT | MSG_NOSIGNAL); if (size < 0) { - ALOGE("sendAck failure %d %d", size, mNumAcksToSend); + ALOGE("sendAck failure %zd %d", size, mNumAcksToSend); } else { mNumAcksToSend = 0; } diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp index 04ee1b976b..1be7895e74 100644 --- a/libs/gui/SurfaceComposerClient.cpp +++ b/libs/gui/SurfaceComposerClient.cpp @@ -752,14 +752,14 @@ status_t ScreenshotClient::update(const sp<IBinder>& display, status_t ScreenshotClient::update(const sp<IBinder>& display, Rect sourceCrop, bool useIdentityTransform) { - return ScreenshotClient::update(display, sourceCrop, 0, 0, 0, -1UL, + return ScreenshotClient::update(display, sourceCrop, 0, 0, 0, -1U, useIdentityTransform, ISurfaceComposer::eRotateNone); } status_t ScreenshotClient::update(const sp<IBinder>& display, Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight, bool useIdentityTransform) { return ScreenshotClient::update(display, sourceCrop, reqWidth, reqHeight, - 0, -1UL, useIdentityTransform, ISurfaceComposer::eRotateNone); + 0, -1U, useIdentityTransform, ISurfaceComposer::eRotateNone); } void ScreenshotClient::release() { diff --git a/libs/input/Android.mk b/libs/input/Android.mk index f1921a4e0d..944ac7f653 100644 --- a/libs/input/Android.mk +++ b/libs/input/Android.mk @@ -27,6 +27,7 @@ commonSources := \ deviceSources := \ $(commonSources) \ + IInputFlinger.cpp \ InputTransport.cpp \ VelocityControl.cpp \ VelocityTracker.cpp diff --git a/libs/input/IInputFlinger.cpp b/libs/input/IInputFlinger.cpp new file mode 100644 index 0000000000..e00973149c --- /dev/null +++ b/libs/input/IInputFlinger.cpp @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2013 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 <stdint.h> +#include <sys/types.h> + +#include <binder/Parcel.h> +#include <binder/IPCThreadState.h> +#include <binder/IServiceManager.h> + +#include <input/IInputFlinger.h> + + +namespace android { + +class BpInputFlinger : public BpInterface<IInputFlinger> { +public: + BpInputFlinger(const sp<IBinder>& impl) : + BpInterface<IInputFlinger>(impl) { } + + virtual status_t doSomething() { + Parcel data, reply; + data.writeInterfaceToken(IInputFlinger::getInterfaceDescriptor()); + remote()->transact(BnInputFlinger::DO_SOMETHING_TRANSACTION, data, &reply); + return reply.readInt32(); + } +}; + +IMPLEMENT_META_INTERFACE(InputFlinger, "android.input.IInputFlinger"); + + +status_t BnInputFlinger::onTransact( + uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { + switch(code) { + case DO_SOMETHING_TRANSACTION: { + CHECK_INTERFACE(IInputFlinger, data, reply); + reply->writeInt32(0); + break; + } + default: + return BBinder::onTransact(code, data, reply, flags); + } + return NO_ERROR; +} + +}; diff --git a/libs/ui/Android.mk b/libs/ui/Android.mk index eec97be0cb..1ce8626522 100644 --- a/libs/ui/Android.mk +++ b/libs/ui/Android.mk @@ -12,10 +12,28 @@ # See the License for the specific language governing permissions and # limitations under the License. -LOCAL_PATH:= $(call my-dir) +LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) -LOCAL_SRC_FILES:= \ +LOCAL_CLANG := true +LOCAL_CPPFLAGS := -std=c++1y -Weverything -Werror + +# The static constructors and destructors in this library have not been noted to +# introduce significant overheads +LOCAL_CPPFLAGS += -Wno-exit-time-destructors +LOCAL_CPPFLAGS += -Wno-global-constructors + +# We only care about compiling as C++14 +LOCAL_CPPFLAGS += -Wno-c++98-compat-pedantic + +# We use four-character constants for the GraphicBuffer header, and don't care +# that they're non-portable as long as they're consistent within one execution +LOCAL_CPPFLAGS += -Wno-four-char-constants + +# Don't warn about struct padding +LOCAL_CPPFLAGS += -Wno-padded + +LOCAL_SRC_FILES := \ Fence.cpp \ FramebufferNativeWindow.cpp \ FrameStats.cpp \ @@ -38,7 +56,7 @@ ifneq ($(BOARD_FRAMEBUFFER_FORCE_FORMAT),) LOCAL_CFLAGS += -DFRAMEBUFFER_FORCE_FORMAT=$(BOARD_FRAMEBUFFER_FORCE_FORMAT) endif -LOCAL_MODULE:= libui +LOCAL_MODULE := libui include $(BUILD_SHARED_LIBRARY) diff --git a/libs/ui/Fence.cpp b/libs/ui/Fence.cpp index 3c0306cf0b..9cf2881787 100644 --- a/libs/ui/Fence.cpp +++ b/libs/ui/Fence.cpp @@ -18,10 +18,13 @@ #define ATRACE_TAG ATRACE_TAG_GRAPHICS //#define LOG_NDEBUG 0 - // This is needed for stdint.h to define INT64_MAX in C++ - #define __STDC_LIMIT_MACROS - +// We would eliminate the non-conforming zero-length array, but we can't since +// this is effectively included from the Linux kernel +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wzero-length-array" #include <sync/sync.h> +#pragma clang diagnostic pop + #include <ui/Fence.h> #include <unistd.h> #include <utils/Log.h> @@ -45,7 +48,7 @@ Fence::~Fence() { } } -status_t Fence::wait(unsigned int timeout) { +status_t Fence::wait(int timeout) { ATRACE_CALL(); if (mFenceFd == -1) { return NO_ERROR; @@ -59,7 +62,7 @@ status_t Fence::waitForever(const char* logname) { if (mFenceFd == -1) { return NO_ERROR; } - unsigned int warningTimeout = 3000; + int warningTimeout = 3000; int err = sync_wait(mFenceFd, warningTimeout); if (err < 0 && errno == ETIME) { ALOGE("%s: fence %d didn't signal in %u ms", logname, mFenceFd, @@ -138,7 +141,7 @@ status_t Fence::flatten(void*& buffer, size_t& size, int*& fds, size_t& count) c if (size < getFlattenedSize() || count < getFdCount()) { return NO_MEMORY; } - FlattenableUtils::write(buffer, size, (uint32_t)getFdCount()); + FlattenableUtils::write(buffer, size, getFdCount()); if (isValid()) { *fds++ = mFenceFd; count--; diff --git a/libs/ui/FramebufferNativeWindow.cpp b/libs/ui/FramebufferNativeWindow.cpp index 918f2e7567..30f2ae203c 100644 --- a/libs/ui/FramebufferNativeWindow.cpp +++ b/libs/ui/FramebufferNativeWindow.cpp @@ -1,17 +1,17 @@ -/* +/* ** ** Copyright 2007 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 +** 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 +** 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 +** 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. */ @@ -29,7 +29,9 @@ #include <ui/ANativeObjectBase.h> #include <ui/Fence.h> +#define INCLUDED_FROM_FRAMEBUFFER_NATIVE_WINDOW_CPP #include <ui/FramebufferNativeWindow.h> +#undef INCLUDED_FROM_FRAMEBUFFER_NATIVE_WINDOW_CPP #include <ui/Rect.h> #include <EGL/egl.h> @@ -41,11 +43,11 @@ namespace android { // ---------------------------------------------------------------------------- -class NativeBuffer +class NativeBuffer final : public ANativeObjectBase< - ANativeWindowBuffer, - NativeBuffer, - LightRefBase<NativeBuffer> > + ANativeWindowBuffer, + NativeBuffer, + LightRefBase<NativeBuffer>> { public: NativeBuffer(int w, int h, int f, int u) : BASE() { @@ -55,24 +57,23 @@ public: ANativeWindowBuffer::usage = u; } private: - friend class LightRefBase<NativeBuffer>; - ~NativeBuffer() { }; // this class cannot be overloaded + friend class LightRefBase<NativeBuffer>; }; /* * This implements the (main) framebuffer management. This class is used * mostly by SurfaceFlinger, but also by command line GL application. - * + * * In fact this is an implementation of ANativeWindow on top of * the framebuffer. - * - * Currently it is pretty simple, it manages only two buffers (the front and + * + * Currently it is pretty simple, it manages only two buffers (the front and * back buffer). - * + * */ -FramebufferNativeWindow::FramebufferNativeWindow() +FramebufferNativeWindow::FramebufferNativeWindow() : BASE(), fbDev(0), grDev(0), mUpdateOnDemand(false) { hw_module_t const* module; @@ -82,16 +83,16 @@ FramebufferNativeWindow::FramebufferNativeWindow() int i; err = framebuffer_open(module, &fbDev); ALOGE_IF(err, "couldn't open framebuffer HAL (%s)", strerror(-err)); - + err = gralloc_open(module, &grDev); ALOGE_IF(err, "couldn't open gralloc HAL (%s)", strerror(-err)); // bail out if we can't initialize the modules if (!fbDev || !grDev) return; - + mUpdateOnDemand = (fbDev->setUpdateRect != 0); - + // initialize the buffer FIFO if(fbDev->numFramebuffers >= MIN_NUM_FRAME_BUFFERS && fbDev->numFramebuffers <= MAX_NUM_FRAME_BUFFERS){ @@ -114,36 +115,37 @@ FramebufferNativeWindow::FramebufferNativeWindow() *((uint32_t *)&fbDev->format) = FRAMEBUFFER_FORCE_FORMAT; #endif - for (i = 0; i < mNumBuffers; i++) - { - buffers[i] = new NativeBuffer( - fbDev->width, fbDev->height, fbDev->format, GRALLOC_USAGE_HW_FB); + for (i = 0; i < mNumBuffers; i++) { + buffers[i] = new NativeBuffer( + static_cast<int>(fbDev->width), + static_cast<int>(fbDev->height), + fbDev->format, GRALLOC_USAGE_HW_FB); } - for (i = 0; i < mNumBuffers; i++) - { - err = grDev->alloc(grDev, - fbDev->width, fbDev->height, fbDev->format, - GRALLOC_USAGE_HW_FB, &buffers[i]->handle, &buffers[i]->stride); - - ALOGE_IF(err, "fb buffer %d allocation failed w=%d, h=%d, err=%s", - i, fbDev->width, fbDev->height, strerror(-err)); - - if (err) - { - mNumBuffers = i; - mNumFreeBuffers = i; - mBufferHead = mNumBuffers-1; - break; - } + for (i = 0; i < mNumBuffers; i++) { + err = grDev->alloc(grDev, + static_cast<int>(fbDev->width), + static_cast<int>(fbDev->height), + fbDev->format, GRALLOC_USAGE_HW_FB, + &buffers[i]->handle, &buffers[i]->stride); + + ALOGE_IF(err, "fb buffer %d allocation failed w=%d, h=%d, err=%s", + i, fbDev->width, fbDev->height, strerror(-err)); + + if (err) { + mNumBuffers = i; + mNumFreeBuffers = i; + mBufferHead = mNumBuffers-1; + break; + } } - const_cast<uint32_t&>(ANativeWindow::flags) = fbDev->flags; + const_cast<uint32_t&>(ANativeWindow::flags) = fbDev->flags; const_cast<float&>(ANativeWindow::xdpi) = fbDev->xdpi; const_cast<float&>(ANativeWindow::ydpi) = fbDev->ydpi; - const_cast<int&>(ANativeWindow::minSwapInterval) = + const_cast<int&>(ANativeWindow::minSwapInterval) = fbDev->minSwapInterval; - const_cast<int&>(ANativeWindow::maxSwapInterval) = + const_cast<int&>(ANativeWindow::maxSwapInterval) = fbDev->maxSwapInterval; } else { ALOGE("Couldn't get gralloc module"); @@ -160,7 +162,7 @@ FramebufferNativeWindow::FramebufferNativeWindow() ANativeWindow::queueBuffer_DEPRECATED = queueBuffer_DEPRECATED; } -FramebufferNativeWindow::~FramebufferNativeWindow() +FramebufferNativeWindow::~FramebufferNativeWindow() { if (grDev) { for(int i = 0; i < mNumBuffers; i++) { @@ -176,7 +178,7 @@ FramebufferNativeWindow::~FramebufferNativeWindow() } } -status_t FramebufferNativeWindow::setUpdateRectangle(const Rect& r) +status_t FramebufferNativeWindow::setUpdateRectangle(const Rect& r) { if (!mUpdateOnDemand) { return INVALID_OPERATION; @@ -193,7 +195,7 @@ status_t FramebufferNativeWindow::compositionComplete() } int FramebufferNativeWindow::setSwapInterval( - ANativeWindow* window, int interval) + ANativeWindow* window, int interval) { framebuffer_device_t* fb = getSelf(window)->fbDev; return fb->setSwapInterval(fb, interval); @@ -217,7 +219,7 @@ int FramebufferNativeWindow::getCurrentBufferIndex() const return index; } -int FramebufferNativeWindow::dequeueBuffer_DEPRECATED(ANativeWindow* window, +int FramebufferNativeWindow::dequeueBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer** buffer) { int fenceFd = -1; @@ -232,7 +234,7 @@ int FramebufferNativeWindow::dequeueBuffer_DEPRECATED(ANativeWindow* window, return result; } -int FramebufferNativeWindow::dequeueBuffer(ANativeWindow* window, +int FramebufferNativeWindow::dequeueBuffer(ANativeWindow* window, ANativeWindowBuffer** buffer, int* fenceFd) { FramebufferNativeWindow* self = getSelf(window); @@ -247,7 +249,7 @@ int FramebufferNativeWindow::dequeueBuffer(ANativeWindow* window, while (self->mNumFreeBuffers < 2) { self->mCondition.wait(self->mutex); } - ALOG_ASSERT(self->buffers[index] != self->front); + ALOG_ASSERT(self->buffers[index] != self->front, ""); // get this buffer self->mNumFreeBuffers--; @@ -259,19 +261,19 @@ int FramebufferNativeWindow::dequeueBuffer(ANativeWindow* window, return 0; } -int FramebufferNativeWindow::lockBuffer_DEPRECATED(ANativeWindow* /*window*/, +int FramebufferNativeWindow::lockBuffer_DEPRECATED(ANativeWindow* /*window*/, ANativeWindowBuffer* /*buffer*/) { return NO_ERROR; } -int FramebufferNativeWindow::queueBuffer_DEPRECATED(ANativeWindow* window, +int FramebufferNativeWindow::queueBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer* buffer) { return queueBuffer(window, buffer, -1); } -int FramebufferNativeWindow::queueBuffer(ANativeWindow* window, +int FramebufferNativeWindow::queueBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd) { FramebufferNativeWindow* self = getSelf(window); @@ -291,17 +293,17 @@ int FramebufferNativeWindow::queueBuffer(ANativeWindow* window, } int FramebufferNativeWindow::query(const ANativeWindow* window, - int what, int* value) + int what, int* value) { const FramebufferNativeWindow* self = getSelf(window); Mutex::Autolock _l(self->mutex); framebuffer_device_t* fb = self->fbDev; switch (what) { case NATIVE_WINDOW_WIDTH: - *value = fb->width; + *value = static_cast<int>(fb->width); return NO_ERROR; case NATIVE_WINDOW_HEIGHT: - *value = fb->height; + *value = static_cast<int>(fb->height); return NO_ERROR; case NATIVE_WINDOW_FORMAT: *value = fb->format; @@ -313,10 +315,10 @@ int FramebufferNativeWindow::query(const ANativeWindow* window, *value = 0; return NO_ERROR; case NATIVE_WINDOW_DEFAULT_WIDTH: - *value = fb->width; + *value = static_cast<int>(fb->width); return NO_ERROR; case NATIVE_WINDOW_DEFAULT_HEIGHT: - *value = fb->height; + *value = static_cast<int>(fb->height); return NO_ERROR; case NATIVE_WINDOW_TRANSFORM_HINT: *value = 0; @@ -357,7 +359,8 @@ int FramebufferNativeWindow::perform(ANativeWindow* /*window*/, }; // namespace android // ---------------------------------------------------------------------------- -using namespace android; +using android::sp; +using android::FramebufferNativeWindow; EGLNativeWindowType android_createDisplaySurface(void) { @@ -368,5 +371,5 @@ EGLNativeWindowType android_createDisplaySurface(void) sp<FramebufferNativeWindow> ref(w); return NULL; } - return (EGLNativeWindowType)w; + return static_cast<EGLNativeWindowType>(w); } diff --git a/libs/ui/GraphicBuffer.cpp b/libs/ui/GraphicBuffer.cpp index e768f13cf4..425df389bf 100644 --- a/libs/ui/GraphicBuffer.cpp +++ b/libs/ui/GraphicBuffer.cpp @@ -45,40 +45,40 @@ GraphicBuffer::GraphicBuffer() : BASE(), mOwner(ownData), mBufferMapper(GraphicBufferMapper::get()), mInitCheck(NO_ERROR), mId(getUniqueId()) { - width = - height = - stride = - format = + width = + height = + stride = + format = usage = 0; handle = NULL; } -GraphicBuffer::GraphicBuffer(uint32_t w, uint32_t h, - PixelFormat reqFormat, uint32_t reqUsage) +GraphicBuffer::GraphicBuffer(uint32_t inWidth, uint32_t inHeight, + PixelFormat inFormat, uint32_t inUsage) : BASE(), mOwner(ownData), mBufferMapper(GraphicBufferMapper::get()), mInitCheck(NO_ERROR), mId(getUniqueId()) { - width = - height = - stride = - format = + width = + height = + stride = + format = usage = 0; handle = NULL; - mInitCheck = initSize(w, h, reqFormat, reqUsage); + mInitCheck = initSize(inWidth, inHeight, inFormat, inUsage); } -GraphicBuffer::GraphicBuffer(uint32_t w, uint32_t h, - PixelFormat inFormat, uint32_t inUsage, - uint32_t inStride, native_handle_t* inHandle, bool keepOwnership) +GraphicBuffer::GraphicBuffer(uint32_t inWidth, uint32_t inHeight, + PixelFormat inFormat, uint32_t inUsage, uint32_t inStride, + native_handle_t* inHandle, bool keepOwnership) : BASE(), mOwner(keepOwnership ? ownHandle : ownNone), mBufferMapper(GraphicBufferMapper::get()), mInitCheck(NO_ERROR), mId(getUniqueId()) { - width = w; - height = h; - stride = inStride; + width = static_cast<int>(inWidth); + height = static_cast<int>(inHeight); + stride = static_cast<int>(inStride); format = inFormat; - usage = inUsage; + usage = static_cast<int>(inUsage); handle = inHandle; } @@ -116,7 +116,7 @@ void GraphicBuffer::free_handle() } status_t GraphicBuffer::initCheck() const { - return mInitCheck; + return static_cast<status_t>(mInitCheck); } void GraphicBuffer::dumpAllocationsToSystemLog() @@ -131,13 +131,17 @@ ANativeWindowBuffer* GraphicBuffer::getNativeBuffer() const const_cast<GraphicBuffer*>(this)); } -status_t GraphicBuffer::reallocate(uint32_t w, uint32_t h, PixelFormat f, - uint32_t reqUsage) +status_t GraphicBuffer::reallocate(uint32_t inWidth, uint32_t inHeight, + PixelFormat inFormat, uint32_t inUsage) { if (mOwner != ownData) return INVALID_OPERATION; - if (handle && w==width && h==height && f==format && reqUsage==usage) + if (handle && + static_cast<int>(inWidth) == width && + static_cast<int>(inHeight) == height && + inFormat == format && + static_cast<int>(inUsage) == usage) return NO_ERROR; if (handle) { @@ -145,61 +149,64 @@ status_t GraphicBuffer::reallocate(uint32_t w, uint32_t h, PixelFormat f, allocator.free(handle); handle = 0; } - return initSize(w, h, f, reqUsage); + return initSize(inWidth, inHeight, inFormat, inUsage); } -status_t GraphicBuffer::initSize(uint32_t w, uint32_t h, PixelFormat format, - uint32_t reqUsage) +status_t GraphicBuffer::initSize(uint32_t inWidth, uint32_t inHeight, + PixelFormat inFormat, uint32_t inUsage) { GraphicBufferAllocator& allocator = GraphicBufferAllocator::get(); - status_t err = allocator.alloc(w, h, format, reqUsage, &handle, &stride); + uint32_t outStride = 0; + status_t err = allocator.alloc(inWidth, inHeight, inFormat, inUsage, + &handle, &outStride); if (err == NO_ERROR) { - this->width = w; - this->height = h; - this->format = format; - this->usage = reqUsage; + width = static_cast<int>(inWidth); + height = static_cast<int>(inHeight); + format = inFormat; + usage = static_cast<int>(inUsage); + stride = static_cast<int>(outStride); } return err; } -status_t GraphicBuffer::lock(uint32_t usage, void** vaddr) +status_t GraphicBuffer::lock(uint32_t inUsage, void** vaddr) { const Rect lockBounds(width, height); - status_t res = lock(usage, lockBounds, vaddr); + status_t res = lock(inUsage, lockBounds, vaddr); return res; } -status_t GraphicBuffer::lock(uint32_t usage, const Rect& rect, void** vaddr) +status_t GraphicBuffer::lock(uint32_t inUsage, const Rect& rect, void** vaddr) { - if (rect.left < 0 || rect.right > this->width || - rect.top < 0 || rect.bottom > this->height) { + if (rect.left < 0 || rect.right > width || + rect.top < 0 || rect.bottom > height) { ALOGE("locking pixels (%d,%d,%d,%d) outside of buffer (w=%d, h=%d)", - rect.left, rect.top, rect.right, rect.bottom, - this->width, this->height); + rect.left, rect.top, rect.right, rect.bottom, + width, height); return BAD_VALUE; } - status_t res = getBufferMapper().lock(handle, usage, rect, vaddr); + status_t res = getBufferMapper().lock(handle, inUsage, rect, vaddr); return res; } -status_t GraphicBuffer::lockYCbCr(uint32_t usage, android_ycbcr *ycbcr) +status_t GraphicBuffer::lockYCbCr(uint32_t inUsage, android_ycbcr* ycbcr) { const Rect lockBounds(width, height); - status_t res = lockYCbCr(usage, lockBounds, ycbcr); + status_t res = lockYCbCr(inUsage, lockBounds, ycbcr); return res; } -status_t GraphicBuffer::lockYCbCr(uint32_t usage, const Rect& rect, - android_ycbcr *ycbcr) +status_t GraphicBuffer::lockYCbCr(uint32_t inUsage, const Rect& rect, + android_ycbcr* ycbcr) { - if (rect.left < 0 || rect.right > this->width || - rect.top < 0 || rect.bottom > this->height) { + if (rect.left < 0 || rect.right > width || + rect.top < 0 || rect.bottom > height) { ALOGE("locking pixels (%d,%d,%d,%d) outside of buffer (w=%d, h=%d)", rect.left, rect.top, rect.right, rect.bottom, - this->width, this->height); + width, height); return BAD_VALUE; } - status_t res = getBufferMapper().lockYCbCr(handle, usage, rect, ycbcr); + status_t res = getBufferMapper().lockYCbCr(handle, inUsage, rect, ycbcr); return res; } @@ -209,43 +216,48 @@ status_t GraphicBuffer::unlock() return res; } -status_t GraphicBuffer::lockAsync(uint32_t usage, void** vaddr, int fenceFd) +status_t GraphicBuffer::lockAsync(uint32_t inUsage, void** vaddr, int fenceFd) { const Rect lockBounds(width, height); - status_t res = lockAsync(usage, lockBounds, vaddr, fenceFd); + status_t res = lockAsync(inUsage, lockBounds, vaddr, fenceFd); return res; } -status_t GraphicBuffer::lockAsync(uint32_t usage, const Rect& rect, void** vaddr, int fenceFd) +status_t GraphicBuffer::lockAsync(uint32_t inUsage, const Rect& rect, + void** vaddr, int fenceFd) { - if (rect.left < 0 || rect.right > this->width || - rect.top < 0 || rect.bottom > this->height) { + if (rect.left < 0 || rect.right > width || + rect.top < 0 || rect.bottom > height) { ALOGE("locking pixels (%d,%d,%d,%d) outside of buffer (w=%d, h=%d)", rect.left, rect.top, rect.right, rect.bottom, - this->width, this->height); + width, height); return BAD_VALUE; } - status_t res = getBufferMapper().lockAsync(handle, usage, rect, vaddr, fenceFd); + status_t res = getBufferMapper().lockAsync(handle, inUsage, rect, vaddr, + fenceFd); return res; } -status_t GraphicBuffer::lockAsyncYCbCr(uint32_t usage, android_ycbcr *ycbcr, int fenceFd) +status_t GraphicBuffer::lockAsyncYCbCr(uint32_t inUsage, android_ycbcr* ycbcr, + int fenceFd) { const Rect lockBounds(width, height); - status_t res = lockAsyncYCbCr(usage, lockBounds, ycbcr, fenceFd); + status_t res = lockAsyncYCbCr(inUsage, lockBounds, ycbcr, fenceFd); return res; } -status_t GraphicBuffer::lockAsyncYCbCr(uint32_t usage, const Rect& rect, android_ycbcr *ycbcr, int fenceFd) +status_t GraphicBuffer::lockAsyncYCbCr(uint32_t inUsage, const Rect& rect, + android_ycbcr* ycbcr, int fenceFd) { - if (rect.left < 0 || rect.right > this->width || - rect.top < 0 || rect.bottom > this->height) { + if (rect.left < 0 || rect.right > width || + rect.top < 0 || rect.bottom > height) { ALOGE("locking pixels (%d,%d,%d,%d) outside of buffer (w=%d, h=%d)", rect.left, rect.top, rect.right, rect.bottom, - this->width, this->height); + width, height); return BAD_VALUE; } - status_t res = getBufferMapper().lockAsyncYCbCr(handle, usage, rect, ycbcr, fenceFd); + status_t res = getBufferMapper().lockAsyncYCbCr(handle, inUsage, rect, + ycbcr, fenceFd); return res; } @@ -256,11 +268,11 @@ status_t GraphicBuffer::unlockAsync(int *fenceFd) } size_t GraphicBuffer::getFlattenedSize() const { - return (10 + (handle ? handle->numInts : 0))*sizeof(int); + return static_cast<size_t>(10 + (handle ? handle->numInts : 0)) * sizeof(int); } size_t GraphicBuffer::getFdCount() const { - return handle ? handle->numFds : 0; + return static_cast<size_t>(handle ? handle->numFds : 0); } status_t GraphicBuffer::flatten(void*& buffer, size_t& size, int*& fds, size_t& count) const { @@ -285,16 +297,17 @@ status_t GraphicBuffer::flatten(void*& buffer, size_t& size, int*& fds, size_t& if (handle) { buf[8] = handle->numFds; buf[9] = handle->numInts; - native_handle_t const* const h = handle; - memcpy(fds, h->data, h->numFds*sizeof(int)); - memcpy(&buf[10], h->data + h->numFds, h->numInts*sizeof(int)); + memcpy(fds, handle->data, + static_cast<size_t>(handle->numFds) * sizeof(int)); + memcpy(&buf[10], handle->data + handle->numFds, + static_cast<size_t>(handle->numInts) * sizeof(int)); } buffer = reinterpret_cast<void*>(static_cast<int*>(buffer) + sizeNeeded); size -= sizeNeeded; if (handle) { fds += handle->numFds; - count -= handle->numFds; + count -= static_cast<size_t>(handle->numFds); } return NO_ERROR; @@ -307,14 +320,14 @@ status_t GraphicBuffer::unflatten( int const* buf = static_cast<int const*>(buffer); if (buf[0] != 'GBFR') return BAD_TYPE; - const size_t numFds = buf[8]; - const size_t numInts = buf[9]; + const size_t numFds = static_cast<size_t>(buf[8]); + const size_t numInts = static_cast<size_t>(buf[9]); const size_t maxNumber = UINT_MAX / sizeof(int); if (numFds >= maxNumber || numInts >= (maxNumber - 10)) { width = height = stride = format = usage = 0; handle = NULL; - ALOGE("unflatten: numFds or numInts is too large: %d, %d", + ALOGE("unflatten: numFds or numInts is too large: %zd, %zd", numFds, numInts); return BAD_VALUE; } @@ -336,15 +349,16 @@ status_t GraphicBuffer::unflatten( stride = buf[3]; format = buf[4]; usage = buf[5]; - native_handle* h = native_handle_create(numFds, numInts); + native_handle* h = native_handle_create( + static_cast<int>(numFds), static_cast<int>(numInts)); if (!h) { width = height = stride = format = usage = 0; handle = NULL; ALOGE("unflatten: native_handle_create failed"); return NO_MEMORY; } - memcpy(h->data, fds, numFds*sizeof(int)); - memcpy(h->data + numFds, &buf[10], numInts*sizeof(int)); + memcpy(h->data, fds, numFds * sizeof(int)); + memcpy(h->data + numFds, &buf[10], numInts * sizeof(int)); handle = h; } else { width = height = stride = format = usage = 0; diff --git a/libs/ui/GraphicBufferAllocator.cpp b/libs/ui/GraphicBufferAllocator.cpp index ff550d961e..85e967567e 100644 --- a/libs/ui/GraphicBufferAllocator.cpp +++ b/libs/ui/GraphicBufferAllocator.cpp @@ -1,17 +1,17 @@ -/* +/* ** ** Copyright 2009, 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 +** 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 +** 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 +** 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. */ @@ -66,11 +66,11 @@ void GraphicBufferAllocator::dump(String8& result) const if (rec.size) { snprintf(buffer, SIZE, "%10p: %7.2f KiB | %4u (%4u) x %4u | %8X | 0x%08x\n", list.keyAt(i), rec.size/1024.0f, - rec.w, rec.s, rec.h, rec.format, rec.usage); + rec.width, rec.stride, rec.height, rec.format, rec.usage); } else { snprintf(buffer, SIZE, "%10p: unknown | %4u (%4u) x %4u | %8X | 0x%08x\n", list.keyAt(i), - rec.w, rec.s, rec.h, rec.format, rec.usage); + rec.width, rec.stride, rec.height, rec.format, rec.usage); } result.append(buffer); total += rec.size; @@ -90,39 +90,40 @@ void GraphicBufferAllocator::dumpToSystemLog() ALOGD("%s", s.string()); } -status_t GraphicBufferAllocator::alloc(uint32_t w, uint32_t h, PixelFormat format, - int usage, buffer_handle_t* handle, int32_t* stride) +status_t GraphicBufferAllocator::alloc(uint32_t width, uint32_t height, + PixelFormat format, uint32_t usage, buffer_handle_t* handle, + uint32_t* stride) { ATRACE_CALL(); + // make sure to not allocate a N x 0 or 0 x N buffer, since this is // allowed from an API stand-point allocate a 1x1 buffer instead. - if (!w || !h) - w = h = 1; + if (!width || !height) + width = height = 1; // we have a h/w allocator and h/w buffer is requested - status_t err; - - err = mAllocDev->alloc(mAllocDev, w, h, format, usage, handle, stride); + status_t err; + + int outStride = 0; + err = mAllocDev->alloc(mAllocDev, static_cast<int>(width), + static_cast<int>(height), format, static_cast<int>(usage), handle, + &outStride); + *stride = static_cast<uint32_t>(outStride); ALOGW_IF(err, "alloc(%u, %u, %d, %08x, ...) failed %d (%s)", - w, h, format, usage, err, strerror(-err)); - + width, height, format, usage, err, strerror(-err)); + if (err == NO_ERROR) { Mutex::Autolock _l(sLock); KeyedVector<buffer_handle_t, alloc_rec_t>& list(sAllocList); - int bpp = bytesPerPixel(format); - if (bpp < 0) { - // probably a HAL custom format. in any case, we don't know - // what its pixel size is. - bpp = 0; - } + uint32_t bpp = bytesPerPixel(format); alloc_rec_t rec; - rec.w = w; - rec.h = h; - rec.s = *stride; + rec.width = width; + rec.height = height; + rec.stride = *stride; rec.format = format; rec.usage = usage; - rec.size = h * stride[0] * bpp; + rec.size = static_cast<size_t>(height * (*stride) * bpp); list.add(*handle, rec); } diff --git a/libs/ui/GraphicBufferMapper.cpp b/libs/ui/GraphicBufferMapper.cpp index 320b6c03d4..01acdc8b4a 100644 --- a/libs/ui/GraphicBufferMapper.cpp +++ b/libs/ui/GraphicBufferMapper.cpp @@ -20,7 +20,12 @@ #include <stdint.h> #include <errno.h> +// We would eliminate the non-conforming zero-length array, but we can't since +// this is effectively included from the Linux kernel +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wzero-length-array" #include <sync/sync.h> +#pragma clang diagnostic pop #include <utils/Errors.h> #include <utils/Log.h> @@ -44,7 +49,7 @@ GraphicBufferMapper::GraphicBufferMapper() int err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module); ALOGE_IF(err, "FATAL: can't find the %s module", GRALLOC_HARDWARE_MODULE_ID); if (err == 0) { - mAllocMod = (gralloc_module_t const *)module; + mAllocMod = reinterpret_cast<gralloc_module_t const *>(module); } } @@ -72,13 +77,13 @@ status_t GraphicBufferMapper::unregisterBuffer(buffer_handle_t handle) return err; } -status_t GraphicBufferMapper::lock(buffer_handle_t handle, - int usage, const Rect& bounds, void** vaddr) +status_t GraphicBufferMapper::lock(buffer_handle_t handle, + uint32_t usage, const Rect& bounds, void** vaddr) { ATRACE_CALL(); status_t err; - err = mAllocMod->lock(mAllocMod, handle, usage, + err = mAllocMod->lock(mAllocMod, handle, static_cast<int>(usage), bounds.left, bounds.top, bounds.width(), bounds.height(), vaddr); @@ -87,12 +92,12 @@ status_t GraphicBufferMapper::lock(buffer_handle_t handle, } status_t GraphicBufferMapper::lockYCbCr(buffer_handle_t handle, - int usage, const Rect& bounds, android_ycbcr *ycbcr) + uint32_t usage, const Rect& bounds, android_ycbcr *ycbcr) { ATRACE_CALL(); status_t err; - err = mAllocMod->lock_ycbcr(mAllocMod, handle, usage, + err = mAllocMod->lock_ycbcr(mAllocMod, handle, static_cast<int>(usage), bounds.left, bounds.top, bounds.width(), bounds.height(), ycbcr); @@ -112,19 +117,19 @@ status_t GraphicBufferMapper::unlock(buffer_handle_t handle) } status_t GraphicBufferMapper::lockAsync(buffer_handle_t handle, - int usage, const Rect& bounds, void** vaddr, int fenceFd) + uint32_t usage, const Rect& bounds, void** vaddr, int fenceFd) { ATRACE_CALL(); status_t err; if (mAllocMod->common.module_api_version >= GRALLOC_MODULE_API_VERSION_0_3) { - err = mAllocMod->lockAsync(mAllocMod, handle, usage, + err = mAllocMod->lockAsync(mAllocMod, handle, static_cast<int>(usage), bounds.left, bounds.top, bounds.width(), bounds.height(), vaddr, fenceFd); } else { sync_wait(fenceFd, -1); close(fenceFd); - err = mAllocMod->lock(mAllocMod, handle, usage, + err = mAllocMod->lock(mAllocMod, handle, static_cast<int>(usage), bounds.left, bounds.top, bounds.width(), bounds.height(), vaddr); } @@ -134,19 +139,19 @@ status_t GraphicBufferMapper::lockAsync(buffer_handle_t handle, } status_t GraphicBufferMapper::lockAsyncYCbCr(buffer_handle_t handle, - int usage, const Rect& bounds, android_ycbcr *ycbcr, int fenceFd) + uint32_t usage, const Rect& bounds, android_ycbcr *ycbcr, int fenceFd) { ATRACE_CALL(); status_t err; if (mAllocMod->common.module_api_version >= GRALLOC_MODULE_API_VERSION_0_3) { - err = mAllocMod->lockAsync_ycbcr(mAllocMod, handle, usage, - bounds.left, bounds.top, bounds.width(), bounds.height(), - ycbcr, fenceFd); + err = mAllocMod->lockAsync_ycbcr(mAllocMod, handle, + static_cast<int>(usage), bounds.left, bounds.top, + bounds.width(), bounds.height(), ycbcr, fenceFd); } else { sync_wait(fenceFd, -1); close(fenceFd); - err = mAllocMod->lock_ycbcr(mAllocMod, handle, usage, + err = mAllocMod->lock_ycbcr(mAllocMod, handle, static_cast<int>(usage), bounds.left, bounds.top, bounds.width(), bounds.height(), ycbcr); } diff --git a/libs/ui/PixelFormat.cpp b/libs/ui/PixelFormat.cpp index 5ce7fba54e..99ed6f7830 100644 --- a/libs/ui/PixelFormat.cpp +++ b/libs/ui/PixelFormat.cpp @@ -15,13 +15,12 @@ */ #include <ui/PixelFormat.h> -#include <hardware/hardware.h> // ---------------------------------------------------------------------------- namespace android { // ---------------------------------------------------------------------------- -ssize_t bytesPerPixel(PixelFormat format) { +uint32_t bytesPerPixel(PixelFormat format) { switch (format) { case PIXEL_FORMAT_RGBA_8888: case PIXEL_FORMAT_RGBX_8888: @@ -36,10 +35,10 @@ ssize_t bytesPerPixel(PixelFormat format) { case PIXEL_FORMAT_RGBA_4444: return 2; } - return BAD_VALUE; + return 0; } -ssize_t bitsPerPixel(PixelFormat format) { +uint32_t bitsPerPixel(PixelFormat format) { switch (format) { case PIXEL_FORMAT_RGBA_8888: case PIXEL_FORMAT_RGBX_8888: @@ -52,7 +51,7 @@ ssize_t bitsPerPixel(PixelFormat format) { case PIXEL_FORMAT_RGBA_4444: return 16; } - return BAD_VALUE; + return 0; } // ---------------------------------------------------------------------------- diff --git a/libs/ui/Region.cpp b/libs/ui/Region.cpp index fa812f4dae..06ab3d0d18 100644 --- a/libs/ui/Region.cpp +++ b/libs/ui/Region.cpp @@ -102,8 +102,8 @@ static void reverseRectsResolvingJunctions(const Rect* begin, const Rect* end, current--; } while (current->top == lastTop && current >= begin); - unsigned int beginLastSpan = -1; - unsigned int endLastSpan = -1; + int beginLastSpan = -1; + int endLastSpan = -1; int top = -1; int bottom = -1; @@ -118,7 +118,7 @@ static void reverseRectsResolvingJunctions(const Rect* begin, const Rect* end, } else { beginLastSpan = endLastSpan + 1; } - endLastSpan = dst.size() - 1; + endLastSpan = static_cast<int>(dst.size()) - 1; top = current->top; bottom = current->bottom; @@ -126,8 +126,12 @@ static void reverseRectsResolvingJunctions(const Rect* begin, const Rect* end, int left = current->left; int right = current->right; - for (unsigned int prevIndex = beginLastSpan; prevIndex <= endLastSpan; prevIndex++) { - const Rect* prev = &dst[prevIndex]; + for (int prevIndex = beginLastSpan; prevIndex <= endLastSpan; prevIndex++) { + // prevIndex can't be -1 here because if endLastSpan is set to a + // value greater than -1 (allowing the loop to execute), + // beginLastSpan (and therefore prevIndex) will also be increased + const Rect* prev = &dst[static_cast<size_t>(prevIndex)]; + if (spanDirection == direction_RTL) { // iterating over previous span RTL, quit if it's too far left if (prev->right <= left) break; @@ -250,10 +254,10 @@ void Region::set(const Rect& r) mStorage.add(r); } -void Region::set(uint32_t w, uint32_t h) +void Region::set(int32_t w, int32_t h) { mStorage.clear(); - mStorage.add(Rect(w,h)); + mStorage.add(Rect(w, h)); } bool Region::isTriviallyEqual(const Region& region) const { @@ -404,7 +408,7 @@ const Region Region::operation(const Region& rhs, int dx, int dy, int op) const // This is our region rasterizer, which merges rects and spans together // to obtain an optimal region. -class Region::rasterizer : public region_operator<Rect>::region_rasterizer +class Region::rasterizer : public region_operator<Rect>::region_rasterizer { Rect bounds; Vector<Rect>& storage; @@ -413,80 +417,91 @@ class Region::rasterizer : public region_operator<Rect>::region_rasterizer Vector<Rect> span; Rect* cur; public: - rasterizer(Region& reg) + rasterizer(Region& reg) : bounds(INT_MAX, 0, INT_MIN, 0), storage(reg.mStorage), head(), tail(), cur() { storage.clear(); } - ~rasterizer() { - if (span.size()) { - flushSpan(); - } - if (storage.size()) { - bounds.top = storage.itemAt(0).top; - bounds.bottom = storage.top().bottom; - if (storage.size() == 1) { - storage.clear(); - } - } else { - bounds.left = 0; - bounds.right = 0; + virtual ~rasterizer(); + + virtual void operator()(const Rect& rect); + +private: + template<typename T> + static inline T min(T rhs, T lhs) { return rhs < lhs ? rhs : lhs; } + template<typename T> + static inline T max(T rhs, T lhs) { return rhs > lhs ? rhs : lhs; } + + void flushSpan(); +}; + +Region::rasterizer::~rasterizer() +{ + if (span.size()) { + flushSpan(); + } + if (storage.size()) { + bounds.top = storage.itemAt(0).top; + bounds.bottom = storage.top().bottom; + if (storage.size() == 1) { + storage.clear(); } - storage.add(bounds); + } else { + bounds.left = 0; + bounds.right = 0; } - - virtual void operator()(const Rect& rect) { - //ALOGD(">>> %3d, %3d, %3d, %3d", - // rect.left, rect.top, rect.right, rect.bottom); - if (span.size()) { - if (cur->top != rect.top) { - flushSpan(); - } else if (cur->right == rect.left) { - cur->right = rect.right; - return; - } + storage.add(bounds); +} + +void Region::rasterizer::operator()(const Rect& rect) +{ + //ALOGD(">>> %3d, %3d, %3d, %3d", + // rect.left, rect.top, rect.right, rect.bottom); + if (span.size()) { + if (cur->top != rect.top) { + flushSpan(); + } else if (cur->right == rect.left) { + cur->right = rect.right; + return; } - span.add(rect); - cur = span.editArray() + (span.size() - 1); } -private: - template<typename T> - static inline T min(T rhs, T lhs) { return rhs < lhs ? rhs : lhs; } - template<typename T> - static inline T max(T rhs, T lhs) { return rhs > lhs ? rhs : lhs; } - void flushSpan() { - bool merge = false; - if (tail-head == ssize_t(span.size())) { - Rect const* p = span.editArray(); - Rect const* q = head; - if (p->top == q->bottom) { - merge = true; - while (q != tail) { - if ((p->left != q->left) || (p->right != q->right)) { - merge = false; - break; - } - p++, q++; + span.add(rect); + cur = span.editArray() + (span.size() - 1); +} + +void Region::rasterizer::flushSpan() +{ + bool merge = false; + if (tail-head == ssize_t(span.size())) { + Rect const* p = span.editArray(); + Rect const* q = head; + if (p->top == q->bottom) { + merge = true; + while (q != tail) { + if ((p->left != q->left) || (p->right != q->right)) { + merge = false; + break; } + p++, q++; } } - if (merge) { - const int bottom = span[0].bottom; - Rect* r = head; - while (r != tail) { - r->bottom = bottom; - r++; - } - } else { - bounds.left = min(span.itemAt(0).left, bounds.left); - bounds.right = max(span.top().right, bounds.right); - storage.appendVector(span); - tail = storage.editArray() + storage.size(); - head = tail - span.size(); + } + if (merge) { + const int bottom = span[0].bottom; + Rect* r = head; + while (r != tail) { + r->bottom = bottom; + r++; } - span.clear(); + } else { + bounds.left = min(span.itemAt(0).left, bounds.left); + bounds.right = max(span.top().right, bounds.right); + storage.appendVector(span); + tail = storage.editArray() + storage.size(); + head = tail - span.size(); } -}; + span.clear(); +} bool Region::validate(const Region& reg, const char* name, bool silent) { @@ -786,10 +801,8 @@ Region::const_iterator Region::end() const { } Rect const* Region::getArray(size_t* count) const { - const_iterator const b(begin()); - const_iterator const e(end()); - if (count) *count = e-b; - return b; + if (count) *count = static_cast<size_t>(end() - begin()); + return begin(); } SharedBuffer const* Region::getSharedBuffer(size_t* count) const { @@ -806,29 +819,22 @@ SharedBuffer const* Region::getSharedBuffer(size_t* count) const { // ---------------------------------------------------------------------------- -void Region::dump(String8& out, const char* what, uint32_t flags) const +void Region::dump(String8& out, const char* what, uint32_t /* flags */) const { - (void)flags; const_iterator head = begin(); const_iterator const tail = end(); - size_t SIZE = 256; - char buffer[SIZE]; - - snprintf(buffer, SIZE, " Region %s (this=%p, count=%" PRIdPTR ")\n", - what, this, tail-head); - out.append(buffer); + out.appendFormat(" Region %s (this=%p, count=%" PRIdPTR ")\n", + what, this, tail - head); while (head != tail) { - snprintf(buffer, SIZE, " [%3d, %3d, %3d, %3d]\n", - head->left, head->top, head->right, head->bottom); - out.append(buffer); - head++; + out.appendFormat(" [%3d, %3d, %3d, %3d]\n", head->left, head->top, + head->right, head->bottom); + ++head; } } -void Region::dump(const char* what, uint32_t flags) const +void Region::dump(const char* what, uint32_t /* flags */) const { - (void)flags; const_iterator head = begin(); const_iterator const tail = end(); ALOGD(" Region %s (this=%p, count=%" PRIdPTR ")\n", what, this, tail-head); diff --git a/libs/ui/UiConfig.cpp b/libs/ui/UiConfig.cpp index 8b2130e702..9e7ba8e886 100644 --- a/libs/ui/UiConfig.cpp +++ b/libs/ui/UiConfig.cpp @@ -18,8 +18,11 @@ namespace android { +#ifdef FRAMEBUFFER_FORCE_FORMAT +// We need the two-level macro to stringify the contents of a macro argument #define STRINGIFY(x) #x #define TOSTRING(x) STRINGIFY(x) +#endif void appendUiConfigString(String8& configStr) { diff --git a/opengl/libs/EGL/egl_display.cpp b/opengl/libs/EGL/egl_display.cpp index 7784ca6ace..77a5f11b77 100644 --- a/opengl/libs/EGL/egl_display.cpp +++ b/opengl/libs/EGL/egl_display.cpp @@ -171,6 +171,7 @@ EGLBoolean egl_display_t::initialize(EGLint *major, EGLint *minor) { } else { ALOGW("eglInitialize(%p) failed (%s)", idpy, egl_tls_t::egl_strerror(cnx->egl.eglGetError())); + return EGL_FALSE; } } diff --git a/services/inputflinger/Android.mk b/services/inputflinger/Android.mk index 85edbe5db4..2edc07da14 100644 --- a/services/inputflinger/Android.mk +++ b/services/inputflinger/Android.mk @@ -22,7 +22,8 @@ LOCAL_SRC_FILES:= \ InputListener.cpp \ InputManager.cpp \ InputReader.cpp \ - InputWindow.cpp + InputWindow.cpp \ + InputFlinger.cpp LOCAL_SHARED_LIBRARIES := \ libbinder \ @@ -48,3 +49,19 @@ LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) LOCAL_MODULE := libinputflinger include $(BUILD_SHARED_LIBRARY) + +######################################################################## +# build input flinger executable +include $(CLEAR_VARS) + +LOCAL_SRC_FILES:= \ + main.cpp + +LOCAL_SHARED_LIBRARIES := \ + libbinder \ + libinputflinger \ + libutils + +LOCAL_MODULE := inputflinger + +include $(BUILD_EXECUTABLE) diff --git a/services/inputflinger/InputFlinger.cpp b/services/inputflinger/InputFlinger.cpp new file mode 100644 index 0000000000..9ea6ce5843 --- /dev/null +++ b/services/inputflinger/InputFlinger.cpp @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2013 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. + */ + +#define LOG_TAG "InputFlinger" + +#include "InputFlinger.h" + +#include <stdint.h> +#include <unistd.h> + +#include <sys/types.h> + +#include <binder/IPCThreadState.h> +#include <binder/PermissionCache.h> +#include <cutils/log.h> +#include <private/android_filesystem_config.h> + +namespace android { + +const String16 sAccessInputFlingerPermission("android.permission.ACCESS_INPUT_FLINGER"); +const String16 sDumpPermission("android.permission.DUMP"); + + +InputFlinger::InputFlinger() : + BnInputFlinger() { + ALOGI("InputFlinger is starting"); +} + +InputFlinger::~InputFlinger() { +} + +status_t InputFlinger::onTransact( + uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { + switch (code) { + case DO_SOMETHING_TRANSACTION: + const IPCThreadState* ipc = IPCThreadState::self(); + const int pid = ipc->getCallingPid(); + const int uid = ipc->getCallingUid(); + if (!PermissionCache::checkPermission(sAccessInputFlingerPermission, pid, uid)) { + ALOGE("Permission Denial: " + "can't access InputFlinger from pid=%d, uid=%d", pid, uid); + return PERMISSION_DENIED; + } + break; + } + + return BnInputFlinger::onTransact(code, data, reply, flags); +} + +status_t InputFlinger::dump(int fd, const Vector<String16>& args) { + String8 result; + const IPCThreadState* ipc = IPCThreadState::self(); + const int pid = ipc->getCallingPid(); + const int uid = ipc->getCallingUid(); + if ((uid != AID_SHELL) + && !PermissionCache::checkPermission(sDumpPermission, pid, uid)) { + result.appendFormat("Permission Denial: " + "can't dump SurfaceFlinger from pid=%d, uid=%d\n", pid, uid); + } else { + dumpInternal(result); + } + write(fd, result.string(), result.size()); + return OK; +} + +void InputFlinger::dumpInternal(String8& result) { + result.append("INPUT FLINGER (dumpsys inputflinger)\n"); + result.append("... nothing here yet...\n"); +} + +status_t InputFlinger::doSomething() { + ALOGI("Did something..."); + return OK; +} + +}; // namespace android diff --git a/services/inputflinger/InputFlinger.h b/services/inputflinger/InputFlinger.h new file mode 100644 index 0000000000..731ab17e83 --- /dev/null +++ b/services/inputflinger/InputFlinger.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2013 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_INPUT_FLINGER_H +#define ANDROID_INPUT_FLINGER_H + +#include <stdint.h> +#include <sys/types.h> + +#include <cutils/compiler.h> +#include <input/IInputFlinger.h> +#include <utils/String8.h> +#include <utils/String16.h> + +namespace android { + +class InputFlinger : public BnInputFlinger { +public: + static char const* getServiceName() ANDROID_API { + return "inputflinger"; + } + + InputFlinger() ANDROID_API; + + // IBinder interface + virtual status_t onTransact(uint32_t code, + const Parcel& data, Parcel* reply, uint32_t flags); + virtual status_t dump(int fd, const Vector<String16>& args); + + // IInputFlinger interface + virtual status_t doSomething(); + +private: + virtual ~InputFlinger(); + + void dumpInternal(String8& result); +}; + +} // namespace android + +#endif // ANDROID_INPUT_FLINGER_H diff --git a/services/inputflinger/main.cpp b/services/inputflinger/main.cpp new file mode 100644 index 0000000000..0a517cc5d9 --- /dev/null +++ b/services/inputflinger/main.cpp @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2013 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 <binder/BinderService.h> +#include "InputFlinger.h" + +using namespace android; + +int main(int, char**) { + ProcessState::self()->setThreadPoolMaxThreadCount(4); + BinderService<InputFlinger>::publishAndJoinThreadPool(true); + return 0; +} diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk index 3123b63f67..61edbff31d 100644 --- a/services/surfaceflinger/Android.mk +++ b/services/surfaceflinger/Android.mk @@ -1,10 +1,10 @@ -LOCAL_PATH:= $(call my-dir) +LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_CLANG := true LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk -LOCAL_SRC_FILES:= \ +LOCAL_SRC_FILES := \ Client.cpp \ DisplayDevice.cpp \ DispSync.cpp \ @@ -37,7 +37,7 @@ LOCAL_SRC_FILES:= \ RenderEngine/GLES20RenderEngine.cpp -LOCAL_CFLAGS:= -DLOG_TAG=\"SurfaceFlinger\" +LOCAL_CFLAGS := -DLOG_TAG=\"SurfaceFlinger\" LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES ifeq ($(TARGET_BOARD_PLATFORM),omap4) @@ -90,7 +90,7 @@ else endif LOCAL_CFLAGS += -fvisibility=hidden -Werror=format -LOCAL_CFLAGS += -std=c++11 +LOCAL_CPPFLAGS := -std=c++11 LOCAL_SHARED_LIBRARIES := \ libcutils \ @@ -106,7 +106,7 @@ LOCAL_SHARED_LIBRARIES := \ libgui \ libpowermanager -LOCAL_MODULE:= libsurfaceflinger +LOCAL_MODULE := libsurfaceflinger LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code @@ -116,11 +116,13 @@ include $(BUILD_SHARED_LIBRARY) # build surfaceflinger's executable include $(CLEAR_VARS) +LOCAL_CLANG := true + LOCAL_LDFLAGS := -Wl,--version-script,art/sigchainlib/version-script.txt -Wl,--export-dynamic -LOCAL_CFLAGS:= -DLOG_TAG=\"SurfaceFlinger\" -LOCAL_CPPFLAGS:= -std=c++11 +LOCAL_CFLAGS := -DLOG_TAG=\"SurfaceFlinger\" +LOCAL_CPPFLAGS := -std=c++11 -LOCAL_SRC_FILES:= \ +LOCAL_SRC_FILES := \ main_surfaceflinger.cpp LOCAL_SHARED_LIBRARIES := \ @@ -133,7 +135,7 @@ LOCAL_SHARED_LIBRARIES := \ LOCAL_WHOLE_STATIC_LIBRARIES := libsigchain -LOCAL_MODULE:= surfaceflinger +LOCAL_MODULE := surfaceflinger ifdef TARGET_32_BIT_SURFACEFLINGER LOCAL_32_BIT_ONLY := true @@ -147,9 +149,13 @@ include $(BUILD_EXECUTABLE) # uses jni which may not be available in PDK ifneq ($(wildcard libnativehelper/include),) include $(CLEAR_VARS) -LOCAL_CFLAGS:= -DLOG_TAG=\"SurfaceFlinger\" -LOCAL_SRC_FILES:= \ +LOCAL_CLANG := true + +LOCAL_CFLAGS := -DLOG_TAG=\"SurfaceFlinger\" +LOCAL_CPPFLAGS := -std=c++11 + +LOCAL_SRC_FILES := \ DdmConnection.cpp LOCAL_SHARED_LIBRARIES := \ @@ -157,7 +163,7 @@ LOCAL_SHARED_LIBRARIES := \ liblog \ libdl -LOCAL_MODULE:= libsurfaceflinger_ddmconnection +LOCAL_MODULE := libsurfaceflinger_ddmconnection LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code diff --git a/services/surfaceflinger/DdmConnection.cpp b/services/surfaceflinger/DdmConnection.cpp index 5143b983ea..659c2c8e49 100644 --- a/services/surfaceflinger/DdmConnection.cpp +++ b/services/surfaceflinger/DdmConnection.cpp @@ -59,12 +59,14 @@ void DdmConnection::start(const char* name) { } jint (*JNI_CreateJavaVM)(JavaVM** p_vm, JNIEnv** p_env, void* vm_args); - JNI_CreateJavaVM = (__typeof__(JNI_CreateJavaVM))dlsym(libart_dso, "JNI_CreateJavaVM"); + JNI_CreateJavaVM = reinterpret_cast<decltype(JNI_CreateJavaVM)>( + dlsym(libart_dso, "JNI_CreateJavaVM")); ALOGE_IF(!JNI_CreateJavaVM, "DdmConnection: %s", dlerror()); jint (*registerNatives)(JNIEnv* env, jclass clazz); - registerNatives = (__typeof__(registerNatives))dlsym(libandroid_runtime_dso, - "Java_com_android_internal_util_WithFramework_registerNatives"); + registerNatives = reinterpret_cast<decltype(registerNatives)>( + dlsym(libandroid_runtime_dso, + "Java_com_android_internal_util_WithFramework_registerNatives")); ALOGE_IF(!registerNatives, "DdmConnection: %s", dlerror()); if (!JNI_CreateJavaVM || !registerNatives) { diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp index 9a2411ad92..13d44f39b5 100644 --- a/services/surfaceflinger/DisplayDevice.cpp +++ b/services/surfaceflinger/DisplayDevice.cpp @@ -517,6 +517,6 @@ void DisplayDevice::dump(String8& result) const { tr[0][2], tr[1][2], tr[2][2]); String8 surfaceDump; - mDisplaySurface->dump(surfaceDump); + mDisplaySurface->dumpAsString(surfaceDump); result.append(surfaceDump); } diff --git a/services/surfaceflinger/DisplayHardware/DisplaySurface.h b/services/surfaceflinger/DisplayHardware/DisplaySurface.h index e60c4fb7b9..2f743c1901 100644 --- a/services/surfaceflinger/DisplayHardware/DisplaySurface.h +++ b/services/surfaceflinger/DisplayHardware/DisplaySurface.h @@ -70,7 +70,7 @@ public: // frame's buffer. virtual void onFrameCommitted() = 0; - virtual void dump(String8& result) const = 0; + virtual void dumpAsString(String8& result) const = 0; virtual void resizeBuffers(const uint32_t w, const uint32_t h) = 0; diff --git a/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp b/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp index 22d3cecbfd..4885c5fc46 100644 --- a/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp +++ b/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp @@ -160,23 +160,7 @@ status_t FramebufferSurface::compositionComplete() return mHwc.fbCompositionComplete(); } -// Since DisplaySurface and ConsumerBase both have a method with this -// signature, results will vary based on the static pointer type the caller is -// using: -// void dump(FrameBufferSurface* fbs, String8& s) { -// // calls FramebufferSurface::dump() -// fbs->dump(s); -// -// // calls ConsumerBase::dump() since it is non-virtual -// static_cast<ConsumerBase*>(fbs)->dump(s); -// -// // calls FramebufferSurface::dump() since it is virtual -// static_cast<DisplaySurface*>(fbs)->dump(s); -// } -// To make sure that all of these end up doing the same thing, we just redirect -// to ConsumerBase::dump() here. It will take the internal lock, and then call -// virtual dumpLocked(), which is where the real work happens. -void FramebufferSurface::dump(String8& result) const { +void FramebufferSurface::dumpAsString(String8& result) const { ConsumerBase::dump(result); } diff --git a/services/surfaceflinger/DisplayHardware/FramebufferSurface.h b/services/surfaceflinger/DisplayHardware/FramebufferSurface.h index 8605862e5c..3d1784086e 100644 --- a/services/surfaceflinger/DisplayHardware/FramebufferSurface.h +++ b/services/surfaceflinger/DisplayHardware/FramebufferSurface.h @@ -44,10 +44,7 @@ public: virtual status_t compositionComplete(); virtual status_t advanceFrame(); virtual void onFrameCommitted(); - - // Implementation of DisplaySurface::dump(). Note that ConsumerBase also - // has a non-virtual dump() with the same signature. - virtual void dump(String8& result) const; + virtual void dumpAsString(String8& result) const; // Cannot resize a buffers in a FramebufferSurface. Only works with virtual // displays. diff --git a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp index c3d45ee09a..e0f32e99a4 100644 --- a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp +++ b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp @@ -254,7 +254,7 @@ void VirtualDisplaySurface::onFrameCommitted() { resetPerFrameState(); } -void VirtualDisplaySurface::dump(String8& /* result */) const { +void VirtualDisplaySurface::dumpAsString(String8& /* result */) const { } void VirtualDisplaySurface::resizeBuffers(const uint32_t w, const uint32_t h) { diff --git a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h index 0fab7e2be0..2c14d6d4bc 100644 --- a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h +++ b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h @@ -86,8 +86,7 @@ public: virtual status_t compositionComplete(); virtual status_t advanceFrame(); virtual void onFrameCommitted(); - using BBinder::dump; - virtual void dump(String8& result) const; + virtual void dumpAsString(String8& result) const; virtual void resizeBuffers(const uint32_t w, const uint32_t h); private: |