widget/gonk/libdisplay/GraphicBufferAlloc.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/widget/gonk/libdisplay/GraphicBufferAlloc.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,53 @@
     1.4 +/*
     1.5 + **
     1.6 + ** Copyright 2012 The Android Open Source Project
     1.7 + **
     1.8 + ** Licensed under the Apache License Version 2.0(the "License");
     1.9 + ** you may not use this file except in compliance with the License.
    1.10 + ** You may obtain a copy of the License at
    1.11 + **
    1.12 + **     http://www.apache.org/licenses/LICENSE-2.0
    1.13 + **
    1.14 + ** Unless required by applicable law or agreed to in writing software
    1.15 + ** distributed under the License is distributed on an "AS IS" BASIS
    1.16 + ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
    1.17 + ** See the License for the specific language governing permissions and
    1.18 + ** limitations under the License.
    1.19 + */
    1.20 +
    1.21 +#include <cutils/log.h>
    1.22 +
    1.23 +#include <ui/GraphicBuffer.h>
    1.24 +
    1.25 +#include "GraphicBufferAlloc.h"
    1.26 +
    1.27 +// ----------------------------------------------------------------------------
    1.28 +namespace android {
    1.29 +// ----------------------------------------------------------------------------
    1.30 +
    1.31 +GraphicBufferAlloc::GraphicBufferAlloc() {
    1.32 +}
    1.33 +
    1.34 +GraphicBufferAlloc::~GraphicBufferAlloc() {
    1.35 +}
    1.36 +
    1.37 +sp<GraphicBuffer> GraphicBufferAlloc::createGraphicBuffer(uint32_t w, uint32_t h,
    1.38 +        PixelFormat format, uint32_t usage, status_t* error) {
    1.39 +    sp<GraphicBuffer> graphicBuffer(new GraphicBuffer(w, h, format, usage));
    1.40 +    status_t err = graphicBuffer->initCheck();
    1.41 +    *error = err;
    1.42 +    if (err != 0 || graphicBuffer->handle == 0) {
    1.43 +        if (err == NO_MEMORY) {
    1.44 +            GraphicBuffer::dumpAllocationsToSystemLog();
    1.45 +        }
    1.46 +        ALOGE("GraphicBufferAlloc::createGraphicBuffer(w=%d, h=%d) "
    1.47 +             "failed (%s), handle=%p",
    1.48 +                w, h, strerror(-err), graphicBuffer->handle);
    1.49 +        return 0;
    1.50 +    }
    1.51 +    return graphicBuffer;
    1.52 +}
    1.53 +
    1.54 +// ----------------------------------------------------------------------------
    1.55 +}; // namespace android
    1.56 +// ----------------------------------------------------------------------------

mercurial