diff options
author | Chris Craik <ccraik@google.com> | 2014-12-22 17:16:56 -0800 |
---|---|---|
committer | Chris Craik <ccraik@google.com> | 2014-12-23 16:53:56 -0800 |
commit | 51d6a3db97bdd5315f1a17a4b447d10a92217b98 (patch) | |
tree | 80803f8d2a5507e2d29bd58c7243a23fca343454 /libs/hwui/PixelBuffer.cpp | |
parent | e84a208317e0ed388fcdad1e6743c7849acb51b0 (diff) | |
download | frameworks_base-51d6a3db97bdd5315f1a17a4b447d10a92217b98.zip frameworks_base-51d6a3db97bdd5315f1a17a4b447d10a92217b98.tar.gz frameworks_base-51d6a3db97bdd5315f1a17a4b447d10a92217b98.tar.bz2 |
Cleanup various clang warnings, use unique_ptrs in several places
Change-Id: I347904b25e51fcc7de14b1e72f1acd0f6ba26f3f
Diffstat (limited to 'libs/hwui/PixelBuffer.cpp')
-rw-r--r-- | libs/hwui/PixelBuffer.cpp | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/libs/hwui/PixelBuffer.cpp b/libs/hwui/PixelBuffer.cpp index 5b642b9..6c448f0 100644 --- a/libs/hwui/PixelBuffer.cpp +++ b/libs/hwui/PixelBuffer.cpp @@ -34,7 +34,6 @@ namespace uirenderer { class CpuPixelBuffer: public PixelBuffer { public: CpuPixelBuffer(GLenum format, uint32_t width, uint32_t height); - ~CpuPixelBuffer(); uint8_t* map(AccessMode mode = kAccessMode_ReadWrite); void unmap(); @@ -44,23 +43,19 @@ public: void upload(uint32_t x, uint32_t y, uint32_t width, uint32_t height, int offset); private: - uint8_t* mBuffer; + std::unique_ptr<uint8_t[]> mBuffer; }; -CpuPixelBuffer::CpuPixelBuffer(GLenum format, uint32_t width, uint32_t height): - PixelBuffer(format, width, height) { - mBuffer = new uint8_t[width * height * formatSize(format)]; -} - -CpuPixelBuffer::~CpuPixelBuffer() { - delete[] mBuffer; +CpuPixelBuffer::CpuPixelBuffer(GLenum format, uint32_t width, uint32_t height) + : PixelBuffer(format, width, height) + , mBuffer(new uint8_t[width * height * formatSize(format)]) { } uint8_t* CpuPixelBuffer::map(AccessMode mode) { if (mAccessMode == kAccessMode_None) { mAccessMode = mode; } - return mBuffer; + return mBuffer.get(); } void CpuPixelBuffer::unmap() { @@ -68,12 +63,12 @@ void CpuPixelBuffer::unmap() { } uint8_t* CpuPixelBuffer::getMappedPointer() const { - return mAccessMode == kAccessMode_None ? NULL : mBuffer; + return mAccessMode == kAccessMode_None ? nullptr : mBuffer.get(); } void CpuPixelBuffer::upload(uint32_t x, uint32_t y, uint32_t width, uint32_t height, int offset) { glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, width, height, - mFormat, GL_UNSIGNED_BYTE, mBuffer + offset); + mFormat, GL_UNSIGNED_BYTE, &mBuffer[offset]); } /////////////////////////////////////////////////////////////////////////////// |