diff options
author | 2018-01-09 18:22:43 -0800 | |
---|---|---|
committer | 2018-01-10 10:54:38 -0800 | |
commit | 566a3b4a1d1a2a6d38257113700eea92aa44ea2b (patch) | |
tree | c65bbfda9d8315e611bcadc4274b6ba5165d8fbc | |
parent | 44c26300d9dbd478d91cba2aab1861fc4d5f3f41 (diff) |
[SurfaceFlinger] Replace NULL with nullptr.
Test: make
Change-Id: Ia0ecb3160cd5fddf22fb7100c1759d62e723d0b7
19 files changed, 88 insertions, 87 deletions
diff --git a/services/surfaceflinger/BufferLayer.cpp b/services/surfaceflinger/BufferLayer.cpp index 5f70ab54da..d860f58509 100644 --- a/services/surfaceflinger/BufferLayer.cpp +++ b/services/surfaceflinger/BufferLayer.cpp @@ -105,7 +105,8 @@ bool BufferLayer::isProtected() const { bool BufferLayer::isVisible() const { return !(isHiddenByPolicy()) && getAlpha() > 0.0f && - (getBE().compositionInfo.mBuffer != NULL || getBE().compositionInfo.hwc.sidebandStream != NULL); + (getBE().compositionInfo.mBuffer != nullptr || + getBE().compositionInfo.hwc.sidebandStream != nullptr); } bool BufferLayer::isFixedSize() const { @@ -377,7 +378,7 @@ Region BufferLayer::latchBuffer(bool& recomputeVisibleRegions, nsecs_t latchTime mSidebandStream = mConsumer->getSidebandStream(); // replicated in LayerBE until FE/BE is ready to be synchronized getBE().compositionInfo.hwc.sidebandStream = mSidebandStream; - if (getBE().compositionInfo.hwc.sidebandStream != NULL) { + if (getBE().compositionInfo.hwc.sidebandStream != nullptr) { setTransactionFlags(eTransactionNeeded); mFlinger->setTransactionFlags(eTraversalNeeded); } @@ -492,7 +493,7 @@ Region BufferLayer::latchBuffer(bool& recomputeVisibleRegions, nsecs_t latchTime mConsumer->getCurrentBuffer(&getBE().compositionInfo.mBufferSlot); // replicated in LayerBE until FE/BE is ready to be synchronized mActiveBuffer = getBE().compositionInfo.mBuffer; - if (getBE().compositionInfo.mBuffer == NULL) { + if (getBE().compositionInfo.mBuffer == nullptr) { // this can only happen if the very first buffer was rejected. return outDirtyRegion; } @@ -508,7 +509,7 @@ Region BufferLayer::latchBuffer(bool& recomputeVisibleRegions, nsecs_t latchTime mRefreshPending = true; mFrameLatencyNeeded = true; - if (oldBuffer == NULL) { + if (oldBuffer == nullptr) { // the first time we receive a buffer, we need to trigger a // geometry invalidation. recomputeVisibleRegions = true; @@ -528,7 +529,7 @@ Region BufferLayer::latchBuffer(bool& recomputeVisibleRegions, nsecs_t latchTime recomputeVisibleRegions = true; } - if (oldBuffer != NULL) { + if (oldBuffer != nullptr) { uint32_t bufWidth = getBE().compositionInfo.mBuffer->getWidth(); uint32_t bufHeight = getBE().compositionInfo.mBuffer->getHeight(); if (bufWidth != uint32_t(oldBuffer->width) || diff --git a/services/surfaceflinger/BufferLayerConsumer.cpp b/services/surfaceflinger/BufferLayerConsumer.cpp index bf61236663..8f5c9c740b 100644 --- a/services/surfaceflinger/BufferLayerConsumer.cpp +++ b/services/surfaceflinger/BufferLayerConsumer.cpp @@ -271,7 +271,7 @@ status_t BufferLayerConsumer::acquireBufferLocked(BufferItem* item, nsecs_t pres // If item->mGraphicBuffer is not null, this buffer has not been acquired // before, so any prior EglImage created is using a stale buffer. This // replaces any old EglImage with a new one (using the new buffer). - if (item->mGraphicBuffer != NULL) { + if (item->mGraphicBuffer != nullptr) { mImages[item->mSlot] = new Image(item->mGraphicBuffer, mRE); } @@ -306,8 +306,8 @@ status_t BufferLayerConsumer::updateAndReleaseLocked(const BufferItem& item, } BLC_LOGV("updateAndRelease: (slot=%d buf=%p) -> (slot=%d buf=%p)", mCurrentTexture, - mCurrentTextureImage != NULL ? mCurrentTextureImage->graphicBufferHandle() : 0, slot, - mSlots[slot].mGraphicBuffer->handle); + mCurrentTextureImage != nullptr ? mCurrentTextureImage->graphicBufferHandle() : 0, + slot, mSlots[slot].mGraphicBuffer->handle); // Hang onto the pointer so that it isn't freed in the call to // releaseBufferLocked() if we're in shared buffer mode and both buffers are @@ -355,7 +355,7 @@ status_t BufferLayerConsumer::updateAndReleaseLocked(const BufferItem& item, status_t BufferLayerConsumer::bindTextureImageLocked() { mRE.checkErrors(); - if (mCurrentTexture == BufferQueue::INVALID_BUFFER_SLOT && mCurrentTextureImage == NULL) { + if (mCurrentTexture == BufferQueue::INVALID_BUFFER_SLOT && mCurrentTextureImage == nullptr) { BLC_LOGE("bindTextureImage: no currently-bound texture"); mRE.bindExternalTextureImage(mTexName, RE::Image(mRE)); return NO_INIT; @@ -414,11 +414,11 @@ void BufferLayerConsumer::setFilteringEnabled(bool enabled) { bool needsRecompute = mFilteringEnabled != enabled; mFilteringEnabled = enabled; - if (needsRecompute && mCurrentTextureImage == NULL) { - BLC_LOGD("setFilteringEnabled called with mCurrentTextureImage == NULL"); + if (needsRecompute && mCurrentTextureImage == nullptr) { + BLC_LOGD("setFilteringEnabled called with mCurrentTextureImage == nullptr"); } - if (needsRecompute && mCurrentTextureImage != NULL) { + if (needsRecompute && mCurrentTextureImage != nullptr) { computeCurrentTransformMatrixLocked(); } } @@ -429,7 +429,7 @@ void BufferLayerConsumer::computeCurrentTransformMatrixLocked() { (mCurrentTextureImage == nullptr) ? nullptr : mCurrentTextureImage->graphicBuffer(); if (buf == nullptr) { BLC_LOGD("computeCurrentTransformMatrixLocked: " - "mCurrentTextureImage is NULL"); + "mCurrentTextureImage is nullptr"); } const Rect& cropRect = canUseImageCrop(mCurrentCrop) ? Rect::EMPTY_RECT : mCurrentCrop; GLConsumer::computeTransformMatrix(mCurrentTransformMatrix, buf, cropRect, mCurrentTransform, @@ -476,7 +476,7 @@ sp<GraphicBuffer> BufferLayerConsumer::getCurrentBuffer(int* outSlot) const { *outSlot = mCurrentTexture; } - return (mCurrentTextureImage == nullptr) ? NULL : mCurrentTextureImage->graphicBuffer(); + return (mCurrentTextureImage == nullptr) ? nullptr : mCurrentTextureImage->graphicBuffer(); } Rect BufferLayerConsumer::getCurrentCrop() const { @@ -564,7 +564,7 @@ void BufferLayerConsumer::onSidebandStreamChanged() { listener = mContentsChangedListener.promote(); } - if (listener != NULL) { + if (listener != nullptr) { listener->onSidebandStreamChanged(); } } diff --git a/services/surfaceflinger/BufferLayerConsumer.h b/services/surfaceflinger/BufferLayerConsumer.h index 51c2b414d7..f473390ea7 100644 --- a/services/surfaceflinger/BufferLayerConsumer.h +++ b/services/surfaceflinger/BufferLayerConsumer.h @@ -228,7 +228,7 @@ private: const sp<GraphicBuffer>& graphicBuffer() { return mGraphicBuffer; } const native_handle* graphicBufferHandle() { - return mGraphicBuffer == NULL ? NULL : mGraphicBuffer->handle; + return mGraphicBuffer == nullptr ? nullptr : mGraphicBuffer->handle; } const RE::Image& image() const { return mImage; } @@ -265,7 +265,7 @@ private: // computeCurrentTransformMatrixLocked computes the transform matrix for the // current texture. It uses mCurrentTransform and the current GraphicBuffer // to compute this matrix and stores it in mCurrentTransformMatrix. - // mCurrentTextureImage must not be NULL. + // mCurrentTextureImage must not be nullptr. void computeCurrentTransformMatrixLocked(); // doFenceWaitLocked inserts a wait command into the RenderEngine command diff --git a/services/surfaceflinger/Client.cpp b/services/surfaceflinger/Client.cpp index ea6541a734..a69940a42e 100644 --- a/services/surfaceflinger/Client.cpp +++ b/services/surfaceflinger/Client.cpp @@ -206,7 +206,7 @@ status_t Client::destroySurface(const sp<IBinder>& handle) { status_t Client::clearLayerFrameStats(const sp<IBinder>& handle) const { sp<Layer> layer = getLayerUser(handle); - if (layer == NULL) { + if (layer == nullptr) { return NAME_NOT_FOUND; } layer->clearFrameStats(); @@ -215,7 +215,7 @@ status_t Client::clearLayerFrameStats(const sp<IBinder>& handle) const { status_t Client::getLayerFrameStats(const sp<IBinder>& handle, FrameStats* outStats) const { sp<Layer> layer = getLayerUser(handle); - if (layer == NULL) { + if (layer == nullptr) { return NAME_NOT_FOUND; } layer->getFrameStats(outStats); diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp index 2753f11097..9772f9a1be 100644 --- a/services/surfaceflinger/DisplayDevice.cpp +++ b/services/surfaceflinger/DisplayDevice.cpp @@ -160,7 +160,7 @@ void DisplayDevice::disconnect(HWComposer& hwc) { } bool DisplayDevice::isValid() const { - return mFlinger != NULL; + return mFlinger != nullptr; } int DisplayDevice::getWidth() const { diff --git a/services/surfaceflinger/DisplayHardware/FramebufferSurface.h b/services/surfaceflinger/DisplayHardware/FramebufferSurface.h index 4186b7aac4..eaa54553ed 100644 --- a/services/surfaceflinger/DisplayHardware/FramebufferSurface.h +++ b/services/surfaceflinger/DisplayHardware/FramebufferSurface.h @@ -80,7 +80,7 @@ private: // on/off. android_dataspace mDataSpace; - // mCurrentBuffer is the current buffer or NULL to indicate that there is + // mCurrentBuffer is the current buffer or nullptr to indicate that there is // no current buffer. sp<GraphicBuffer> mCurrentBuffer; diff --git a/services/surfaceflinger/DisplayHardware/HWComposer_hwc1.h b/services/surfaceflinger/DisplayHardware/HWComposer_hwc1.h index 4bc63bbac8..fe7944f635 100644 --- a/services/surfaceflinger/DisplayHardware/HWComposer_hwc1.h +++ b/services/surfaceflinger/DisplayHardware/HWComposer_hwc1.h @@ -190,7 +190,7 @@ public: virtual status_t setLayer(size_t index) = 0; virtual HWCLayer* dup() = 0; static HWCLayer* copy(HWCLayer *rhs) { - return rhs ? rhs->dup() : NULL; + return rhs ? rhs->dup() : nullptr; } protected: virtual ~HWCLayer() { } @@ -205,7 +205,7 @@ public: HWCLayer* const mLayerList; size_t mIndex; - LayerListIterator() : mLayerList(NULL), mIndex(0) { } + LayerListIterator() : mLayerList(nullptr), mIndex(0) { } LayerListIterator(HWCLayer* layer, size_t index) : mLayerList(layer), mIndex(index) { } @@ -371,8 +371,8 @@ private: sp<SurfaceFlinger> mFlinger; framebuffer_device_t* mFbDev; struct hwc_composer_device_1* mHwc; - // invariant: mLists[0] != NULL iff mHwc != NULL - // mLists[i>0] can be NULL. that display is to be ignored + // invariant: mLists[0] != nullptr iff mHwc != nullptr + // mLists[i>0] can be nullptr. that display is to be ignored struct hwc_display_contents_1* mLists[MAX_HWC_DISPLAYS]; DisplayData mDisplayData[MAX_HWC_DISPLAYS]; // protect mDisplayData from races between prepare and dump diff --git a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp index cde96e4162..3480b24390 100644 --- a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp +++ b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp @@ -108,7 +108,7 @@ VirtualDisplaySurface::VirtualDisplaySurface(HWComposer& hwc, int32_t dispId, mConsumer->setDefaultBufferSize(sinkWidth, sinkHeight); sink->setAsyncMode(true); IGraphicBufferProducer::QueueBufferOutput output; - mSource[SOURCE_SCRATCH]->connect(NULL, NATIVE_WINDOW_API_EGL, false, &output); + mSource[SOURCE_SCRATCH]->connect(nullptr, NATIVE_WINDOW_API_EGL, false, &output); } VirtualDisplaySurface::~VirtualDisplaySurface() { @@ -203,7 +203,7 @@ status_t VirtualDisplaySurface::advanceFrame() { } sp<GraphicBuffer> fbBuffer = mFbProducerSlot >= 0 ? - mProducerBuffers[mFbProducerSlot] : sp<GraphicBuffer>(NULL); + mProducerBuffers[mFbProducerSlot] : sp<GraphicBuffer>(nullptr); sp<GraphicBuffer> outBuffer = mProducerBuffers[mOutputProducerSlot]; VDS_LOGV("advanceFrame: fb=%d(%p) out=%d(%p)", mFbProducerSlot, fbBuffer.get(), @@ -214,7 +214,7 @@ status_t VirtualDisplaySurface::advanceFrame() { mHwc.setOutputBuffer(mDisplayId, mOutputFence, outBuffer); status_t result = NO_ERROR; - if (fbBuffer != NULL) { + if (fbBuffer != nullptr) { uint32_t hwcSlot = 0; sp<GraphicBuffer> hwcBuffer; mHwcBufferCache.getHwcBuffer(mFbProducerSlot, fbBuffer, diff --git a/services/surfaceflinger/EventThread.cpp b/services/surfaceflinger/EventThread.cpp index a1a042039c..5c0e3b37f3 100644 --- a/services/surfaceflinger/EventThread.cpp +++ b/services/surfaceflinger/EventThread.cpp @@ -216,7 +216,7 @@ Vector< sp<EventThread::Connection> > EventThread::waitForEvent( size_t count = mDisplayEventConnections.size(); for (size_t i=0 ; i<count ; ) { sp<Connection> connection(mDisplayEventConnections[i].promote()); - if (connection != NULL) { + if (connection != nullptr) { bool added = false; if (connection->count >= 0) { // we need vsync events because at least @@ -346,7 +346,7 @@ void EventThread::dump(String8& result) const { sp<Connection> connection = mDisplayEventConnections.itemAt(i).promote(); result.appendFormat(" %p: count=%d\n", - connection.get(), connection!=NULL ? connection->count : 0); + connection.get(), connection != nullptr ? connection->count : 0); } } diff --git a/services/surfaceflinger/FrameTracker.cpp b/services/surfaceflinger/FrameTracker.cpp index 99c4daaba5..1539873aaa 100644 --- a/services/surfaceflinger/FrameTracker.cpp +++ b/services/surfaceflinger/FrameTracker.cpp @@ -82,17 +82,17 @@ void FrameTracker::advanceFrame() { mFrameRecords[mOffset].frameReadyTime = INT64_MAX; mFrameRecords[mOffset].actualPresentTime = INT64_MAX; - if (mFrameRecords[mOffset].frameReadyFence != NULL) { + if (mFrameRecords[mOffset].frameReadyFence != nullptr) { // We're clobbering an unsignaled fence, so we need to decrement the // fence count. - mFrameRecords[mOffset].frameReadyFence = NULL; + mFrameRecords[mOffset].frameReadyFence = nullptr; mNumFences--; } - if (mFrameRecords[mOffset].actualPresentFence != NULL) { + if (mFrameRecords[mOffset].actualPresentFence != nullptr) { // We're clobbering an unsignaled fence, so we need to decrement the // fence count. - mFrameRecords[mOffset].actualPresentFence = NULL; + mFrameRecords[mOffset].actualPresentFence = nullptr; mNumFences--; } } @@ -153,10 +153,10 @@ void FrameTracker::processFencesLocked() const { bool updated = false; const std::shared_ptr<FenceTime>& rfence = records[idx].frameReadyFence; - if (rfence != NULL) { + if (rfence != nullptr) { records[idx].frameReadyTime = rfence->getSignalTime(); if (records[idx].frameReadyTime < INT64_MAX) { - records[idx].frameReadyFence = NULL; + records[idx].frameReadyFence = nullptr; numFences--; updated = true; } @@ -164,10 +164,10 @@ void FrameTracker::processFencesLocked() const { const std::shared_ptr<FenceTime>& pfence = records[idx].actualPresentFence; - if (pfence != NULL) { + if (pfence != nullptr) { records[idx].actualPresentTime = pfence->getSignalTime(); if (records[idx].actualPresentTime < INT64_MAX) { - records[idx].actualPresentFence = NULL; + records[idx].actualPresentFence = nullptr; numFences--; updated = true; } diff --git a/services/surfaceflinger/FrameTracker.h b/services/surfaceflinger/FrameTracker.h index adcdfb528d..b4a9fd68fb 100644 --- a/services/surfaceflinger/FrameTracker.h +++ b/services/surfaceflinger/FrameTracker.h @@ -35,7 +35,7 @@ class String8; // possible. // // Some of the time values tracked may be set either as a specific timestamp -// or a fence. When a non-NULL fence is set for a given time value, the +// or a fence. When a non-nullptr fence is set for a given time value, the // signal time of that fence is used instead of the timestamp. class FrameTracker { diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index cc675c491b..63f6781f02 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -265,7 +265,7 @@ Rect Layer::getContentCrop() const { if (!mCurrentCrop.isEmpty()) { // if the buffer crop is defined, we use that crop = mCurrentCrop; - } else if (getBE().compositionInfo.mBuffer != NULL) { + } else if (getBE().compositionInfo.mBuffer != nullptr) { // otherwise we use the whole buffer crop = getBE().compositionInfo.mBuffer->getBounds(); } else { diff --git a/services/surfaceflinger/LayerRejecter.cpp b/services/surfaceflinger/LayerRejecter.cpp index e8646076a5..a5f0b9878c 100644 --- a/services/surfaceflinger/LayerRejecter.cpp +++ b/services/surfaceflinger/LayerRejecter.cpp @@ -41,7 +41,7 @@ LayerRejecter::LayerRejecter(Layer::State& front, mFreezeGeometryUpdates(freezePositionUpdates) {} bool LayerRejecter::reject(const sp<GraphicBuffer>& buf, const BufferItem& item) { - if (buf == NULL) { + if (buf == nullptr) { return false; } diff --git a/services/surfaceflinger/RenderEngine/Program.cpp b/services/surfaceflinger/RenderEngine/Program.cpp index baf92ebf60..225bcf0327 100644 --- a/services/surfaceflinger/RenderEngine/Program.cpp +++ b/services/surfaceflinger/RenderEngine/Program.cpp @@ -115,7 +115,7 @@ String8& Program::dumpShader(String8& result, GLenum /*type*/) { GLint l; glGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &l); char* src = new char[l]; - glGetShaderSource(shader, l, NULL, src); + glGetShaderSource(shader, l, nullptr, src); result.append(src); delete[] src; return result; diff --git a/services/surfaceflinger/RenderEngine/ProgramCache.cpp b/services/surfaceflinger/RenderEngine/ProgramCache.cpp index 4f138dc14c..3b8ac0e58c 100644 --- a/services/surfaceflinger/RenderEngine/ProgramCache.cpp +++ b/services/surfaceflinger/RenderEngine/ProgramCache.cpp @@ -98,7 +98,7 @@ void ProgramCache::primeCache() { continue; } Program* program = mCache.valueFor(shaderKey); - if (program == NULL) { + if (program == nullptr) { program = generateProgram(shaderKey); mCache.add(shaderKey, program); shaderCount++; @@ -273,7 +273,7 @@ void ProgramCache::useProgram(const Description& description) { // look-up the program in the cache Program* program = mCache.valueFor(needs); - if (program == NULL) { + if (program == nullptr) { // we didn't find our program, so generate one... nsecs_t time = -systemTime(); program = generateProgram(needs); diff --git a/services/surfaceflinger/RenderEngine/RenderEngine.cpp b/services/surfaceflinger/RenderEngine/RenderEngine.cpp index 314333f044..179b79003c 100644 --- a/services/surfaceflinger/RenderEngine/RenderEngine.cpp +++ b/services/surfaceflinger/RenderEngine/RenderEngine.cpp @@ -36,11 +36,11 @@ namespace android { std::unique_ptr<RenderEngine> RenderEngine::create(int hwcFormat, uint32_t featureFlags) { // initialize EGL for the default display EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); - if (!eglInitialize(display, NULL, NULL)) { + if (!eglInitialize(display, nullptr, nullptr)) { LOG_ALWAYS_FATAL("failed to initialize EGL"); } - GLExtensions& extensions(GLExtensions::getInstance()); + GLExtensions& extensions = GLExtensions::getInstance(); extensions.initWithEGLStrings(eglQueryStringImplementationANDROID(display, EGL_VERSION), eglQueryStringImplementationANDROID(display, EGL_EXTENSIONS)); @@ -79,7 +79,7 @@ std::unique_ptr<RenderEngine> RenderEngine::create(int hwcFormat, uint32_t featu contextAttributes.push_back(EGL_NONE); contextAttributes.push_back(EGL_NONE); - EGLContext ctxt = eglCreateContext(display, config, NULL, contextAttributes.data()); + EGLContext ctxt = eglCreateContext(display, config, nullptr, contextAttributes.data()); // if can't create a GL context, we can only abort. LOG_ALWAYS_FATAL_IF(ctxt == EGL_NO_CONTEXT, "EGLContext creation failed"); @@ -132,7 +132,7 @@ std::unique_ptr<RenderEngine> RenderEngine::create(int hwcFormat, uint32_t featu } RenderEngine::RenderEngine() - : mEGLDisplay(EGL_NO_DISPLAY), mEGLConfig(NULL), mEGLContext(EGL_NO_CONTEXT) {} + : mEGLDisplay(EGL_NO_DISPLAY), mEGLConfig(nullptr), mEGLContext(EGL_NO_CONTEXT) {} RenderEngine::~RenderEngine() { eglMakeCurrent(mEGLDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); @@ -183,7 +183,7 @@ base::unique_fd RenderEngine::flush() { return base::unique_fd(); } - EGLSyncKHR sync = eglCreateSyncKHR(mEGLDisplay, EGL_SYNC_NATIVE_FENCE_ANDROID, NULL); + EGLSyncKHR sync = eglCreateSyncKHR(mEGLDisplay, EGL_SYNC_NATIVE_FENCE_ANDROID, nullptr); if (sync == EGL_NO_SYNC_KHR) { ALOGW("failed to create EGL native fence sync: %#x", eglGetError()); return base::unique_fd(); @@ -208,7 +208,7 @@ bool RenderEngine::finish() { return false; } - EGLSyncKHR sync = eglCreateSyncKHR(mEGLDisplay, EGL_SYNC_FENCE_KHR, NULL); + EGLSyncKHR sync = eglCreateSyncKHR(mEGLDisplay, EGL_SYNC_FENCE_KHR, nullptr); if (sync == EGL_NO_SYNC_KHR) { ALOGW("failed to create EGL fence sync: %#x", eglGetError()); return false; @@ -347,7 +347,7 @@ void RenderEngine::readPixels(size_t l, size_t b, size_t w, size_t h, uint32_t* } void RenderEngine::dump(String8& result) { - const GLExtensions& extensions(GLExtensions::getInstance()); + const GLExtensions& extensions = GLExtensions::getInstance(); result.appendFormat("EGL implementation : %s\n", extensions.getEGLVersion()); result.appendFormat("%s\n", extensions.getEGLExtensions()); @@ -363,7 +363,7 @@ RenderEngine::BindNativeBufferAsFramebuffer::BindNativeBufferAsFramebuffer( RenderEngine& engine, ANativeWindowBuffer* buffer) : mEngine(engine) { mImage = eglCreateImageKHR(mEngine.mEGLDisplay, EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID, - buffer, NULL); + buffer, nullptr); if (mImage == EGL_NO_IMAGE_KHR) { mStatus = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; return; @@ -394,7 +394,7 @@ status_t RenderEngine::BindNativeBufferAsFramebuffer::getStatus() const { static status_t selectConfigForAttribute(EGLDisplay dpy, EGLint const* attrs, EGLint attribute, EGLint wanted, EGLConfig* outConfig) { EGLint numConfigs = -1, n = 0; - eglGetConfigs(dpy, NULL, 0, &numConfigs); + eglGetConfigs(dpy, nullptr, 0, &numConfigs); EGLConfig* const configs = new EGLConfig[numConfigs]; eglChooseConfig(dpy, attrs, configs, numConfigs, &n); diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index db13b99dcc..0210592c81 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -382,7 +382,7 @@ void SurfaceFlinger::createBuiltinDisplayLocked(DisplayDevice::DisplayType type) sp<IBinder> SurfaceFlinger::getBuiltInDisplay(int32_t id) { if (uint32_t(id) >= DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES) { ALOGE("getDefaultDisplay: id=%d is not a valid default display id", id); - return NULL; + return nullptr; } return mBuiltinDisplays[id]; } @@ -531,7 +531,7 @@ private: } } - if (callback != NULL) { + if (callback != nullptr) { callback->onVSyncEvent(when); } } @@ -737,7 +737,7 @@ status_t SurfaceFlinger::getSupportedFrameTimestamps( status_t SurfaceFlinger::getDisplayConfigs(const sp<IBinder>& display, Vector<DisplayInfo>* configs) { - if ((configs == NULL) || (display.get() == NULL)) { + if (configs == nullptr || display.get() == nullptr) { return BAD_VALUE; } @@ -761,7 +761,7 @@ status_t SurfaceFlinger::getDisplayConfigs(const sp<IBinder>& display, static int getDensityFromProperty(char const* propName) { char property[PROPERTY_VALUE_MAX]; int density = 0; - if (property_get(propName, property, NULL) > 0) { + if (property_get(propName, property, nullptr) > 0) { density = atoi(property); } return density; @@ -842,7 +842,7 @@ status_t SurfaceFlinger::getDisplayConfigs(const sp<IBinder>& display, status_t SurfaceFlinger::getDisplayStats(const sp<IBinder>& /* display */, DisplayStatInfo* stats) { - if (stats == NULL) { + if (stats == nullptr) { return BAD_VALUE; } @@ -854,13 +854,13 @@ status_t SurfaceFlinger::getDisplayStats(const sp<IBinder>& /* display */, } int SurfaceFlinger::getActiveConfig(const sp<IBinder>& display) { - if (display == NULL) { - ALOGE("%s : display is NULL", __func__); + if (display == nullptr) { + ALOGE("%s : display is nullptr", __func__); return BAD_VALUE; } sp<const DisplayDevice> device(getDisplayDevice(display)); - if (device != NULL) { + if (device != nullptr) { return device->getActiveConfig(); } @@ -905,7 +905,7 @@ status_t SurfaceFlinger::setActiveConfig(const sp<IBinder>& display, int mode) { return true; } sp<DisplayDevice> hw(mFlinger.getDisplayDevice(mDisplay)); - if (hw == NULL) { + if (hw == nullptr) { ALOGE("Attempt to set active config = %d for null display %p", mMode, mDisplay.get()); } else if (hw->getDisplayType() >= DisplayDevice::DISPLAY_VIRTUAL) { @@ -2165,7 +2165,7 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags) const sp<const DisplayDevice> defaultDisplay(getDefaultDisplayDeviceLocked()); defaultDisplay->makeCurrent(); sp<DisplayDevice> hw(getDisplayDeviceLocked(draw.keyAt(i))); - if (hw != NULL) + if (hw != nullptr) hw->disconnect(getHwComposer()); if (draw[i].type < DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES) mEventThread->onHotplugReceived(draw[i].type, false); @@ -2185,7 +2185,7 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags) // from the drawing state, so that it get re-added // below. sp<DisplayDevice> hw(getDisplayDeviceLocked(display)); - if (hw != NULL) + if (hw != nullptr) hw->disconnect(getHwComposer()); mDisplays.removeItem(display); mDrawingState.displays.removeItemsAt(i); @@ -2195,7 +2195,7 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags) } const sp<DisplayDevice> disp(getDisplayDeviceLocked(display)); - if (disp != NULL) { + if (disp != nullptr) { if (state.layerStack != draw[i].layerStack) { disp->setLayerStack(state.layerStack); } @@ -2231,7 +2231,7 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags) // Virtual displays without a surface are dormant: // they have external state (layer stack, projection, // etc.) but no internal state (i.e. a DisplayDevice). - if (state.surface != NULL) { + if (state.surface != nullptr) { // Allow VR composer to use virtual displays. if (mUseHwcVirtualDisplays || getBE().mHwc->isUsingVrComposer()) { @@ -2268,7 +2268,7 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags) producer = vds; } } else { - ALOGE_IF(state.surface!=NULL, + ALOGE_IF(state.surface != nullptr, "adding a supported display, but rendering " "surface is provided (%p), ignoring it", state.surface.get()); @@ -2279,7 +2279,7 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags) } const wp<IBinder>& display(curr.keyAt(i)); - if (dispSurface != NULL) { + if (dispSurface != nullptr) { sp<DisplayDevice> hw = new DisplayDevice(this, state.type, hwcId, state.isSecure, display, dispSurface, producer, hasWideColorDisplay); @@ -2334,10 +2334,10 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags) for (size_t dpy=0 ; dpy<mDisplays.size() ; dpy++) { sp<const DisplayDevice> hw(mDisplays[dpy]); if (layer->belongsToDisplay(hw->getLayerStack(), hw->isPrimary())) { - if (disp == NULL) { + if (disp == nullptr) { disp = std::move(hw); } else { - disp = NULL; + disp = nullptr; break; } } @@ -2345,7 +2345,7 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags) } if (transactionFlags & eDisplayTransactionNeeded) { - if (disp == NULL) { + if (disp == nullptr) { // NOTE: TEMPORARY FIX ONLY. Real fix should cause layers to // redraw after transform hint changes. See bug 8508397. @@ -2941,16 +2941,16 @@ void SurfaceFlinger::setTransactionState( for (size_t i=0 ; i<count ; i++) { const ComposerState& s(state[i]); // Here we need to check that the interface we're given is indeed - // one of our own. A malicious client could give us a NULL + // one of our own. A malicious client could give us a nullptr // IInterface, or one of its own or even one of our own but a // different type. All these situations would cause us to crash. // // NOTE: it would be better to use RTTI as we could directly check // that we have a Client*. however, RTTI is disabled in Android. - if (s.client != NULL) { + if (s.client != nullptr) { sp<IBinder> binder = IInterface::asBinder(s.client); - if (binder != NULL) { - if (binder->queryLocalInterface(ISurfaceComposerClient::descriptor) != NULL) { + if (binder != nullptr) { + if (binder->queryLocalInterface(ISurfaceComposerClient::descriptor) != nullptr) { sp<Client> client( static_cast<Client *>(s.client.get()) ); transactionFlags |= setClientStateLocked(client, s.state); } @@ -3324,7 +3324,7 @@ status_t SurfaceFlinger::onLayerRemoved(const sp<Client>& client, const sp<IBind // called by a client when it wants to remove a Layer status_t err = NO_ERROR; sp<Layer> l(client->getLayerUser(handle)); - if (l != NULL) { + if (l != nullptr) { mInterceptor.saveSurfaceDeletion(l); err = removeLayer(l); ALOGE_IF(err<0 && err != NAME_NOT_FOUND, @@ -3489,7 +3489,7 @@ void SurfaceFlinger::setPowerMode(const sp<IBinder>& display, int mode) { mDisplay(disp) { mMode = mode; } virtual bool handler() { sp<DisplayDevice> hw(mFlinger.getDisplayDevice(mDisplay)); - if (hw == NULL) { + if (hw == nullptr) { ALOGE("Attempt to set power mode = %d for null display %p", mMode, mDisplay.get()); } else if (hw->getDisplayType() >= DisplayDevice::DISPLAY_VIRTUAL) { @@ -3978,7 +3978,7 @@ SurfaceFlinger::getLayerSortedByZForHwcDisplay(int id) { break; } } - if (dpy == NULL) { + if (dpy == nullptr) { ALOGE("getLayerSortedByZForHwcDisplay: invalid hwc display id %d", id); // Just use the primary display so we have something to return dpy = getBuiltInDisplay(DisplayDevice::DISPLAY_PRIMARY); diff --git a/services/surfaceflinger/tests/SurfaceInterceptor_test.cpp b/services/surfaceflinger/tests/SurfaceInterceptor_test.cpp index ed806b87f5..de78c3f355 100644 --- a/services/surfaceflinger/tests/SurfaceInterceptor_test.cpp +++ b/services/surfaceflinger/tests/SurfaceInterceptor_test.cpp @@ -148,7 +148,7 @@ protected: mBGSurfaceControl = mComposerClient->createSurface( String8("BG Interceptor Test Surface"), displayWidth, displayHeight, PIXEL_FORMAT_RGBA_8888, 0); - ASSERT_TRUE(mBGSurfaceControl != NULL); + ASSERT_TRUE(mBGSurfaceControl != nullptr); ASSERT_TRUE(mBGSurfaceControl->isValid()); mBGLayerId = getSurfaceId("BG Interceptor Test Surface"); diff --git a/services/surfaceflinger/tests/Transaction_test.cpp b/services/surfaceflinger/tests/Transaction_test.cpp index ff81dc9461..ac8a2ad868 100644 --- a/services/surfaceflinger/tests/Transaction_test.cpp +++ b/services/surfaceflinger/tests/Transaction_test.cpp @@ -148,8 +148,8 @@ static void fillSurfaceRGBA8(const sp<SurfaceControl>& sc, uint8_t r, uint8_t g, bool unlock = true) { ANativeWindow_Buffer outBuffer; sp<Surface> s = sc->getSurface(); - ASSERT_TRUE(s != NULL); - ASSERT_EQ(NO_ERROR, s->lock(&outBuffer, NULL)); + ASSERT_TRUE(s != nullptr); + ASSERT_EQ(NO_ERROR, s->lock(&outBuffer, nullptr)); uint8_t* img = reinterpret_cast<uint8_t*>(outBuffer.bits); for (int y = 0; y < outBuffer.height; y++) { for (int x = 0; x < outBuffer.width; x++) { @@ -279,7 +279,7 @@ public: private: sp<GraphicBuffer> mOutBuffer; - uint8_t* mPixels = NULL; + uint8_t* mPixels = nullptr; }; class LayerTransactionTest : public ::testing::Test { @@ -1483,14 +1483,14 @@ protected: mBGSurfaceControl = mComposerClient->createSurface(String8("BG Test Surface"), displayWidth, displayHeight, PIXEL_FORMAT_RGBA_8888, 0); - ASSERT_TRUE(mBGSurfaceControl != NULL); + ASSERT_TRUE(mBGSurfaceControl != nullptr); ASSERT_TRUE(mBGSurfaceControl->isValid()); fillSurfaceRGBA8(mBGSurfaceControl, 63, 63, 195); // Foreground surface mFGSurfaceControl = mComposerClient->createSurface(String8("FG Test Surface"), 64, 64, PIXEL_FORMAT_RGBA_8888, 0); - ASSERT_TRUE(mFGSurfaceControl != NULL); + ASSERT_TRUE(mFGSurfaceControl != nullptr); ASSERT_TRUE(mFGSurfaceControl->isValid()); fillSurfaceRGBA8(mFGSurfaceControl, 195, 63, 63); @@ -1498,7 +1498,7 @@ protected: // Synchronization surface mSyncSurfaceControl = mComposerClient->createSurface(String8("Sync Test Surface"), 1, 1, PIXEL_FORMAT_RGBA_8888, 0); - ASSERT_TRUE(mSyncSurfaceControl != NULL); + ASSERT_TRUE(mSyncSurfaceControl != nullptr); ASSERT_TRUE(mSyncSurfaceControl->isValid()); fillSurfaceRGBA8(mSyncSurfaceControl, 31, 31, 31); @@ -2018,7 +2018,7 @@ TEST_F(ChildLayerTest, DetachChildrenDifferentClient) { mNewComposerClient->createSurface(String8("New Child Test Surface"), 10, 10, PIXEL_FORMAT_RGBA_8888, 0, mFGSurfaceControl.get()); - ASSERT_TRUE(mChildNewClient != NULL); + ASSERT_TRUE(mChildNewClient != nullptr); ASSERT_TRUE(mChildNewClient->isValid()); fillSurfaceRGBA8(mChildNewClient, 200, 200, 200); @@ -2210,7 +2210,7 @@ TEST_F(ChildLayerTest, ReparentToNoParent) { TEST_F(ChildLayerTest, ReparentFromNoParent) { sp<SurfaceControl> newSurface = mComposerClient->createSurface(String8("New Surface"), 10, 10, PIXEL_FORMAT_RGBA_8888, 0); - ASSERT_TRUE(newSurface != NULL); + ASSERT_TRUE(newSurface != nullptr); ASSERT_TRUE(newSurface->isValid()); fillSurfaceRGBA8(newSurface, 63, 195, 63); |