SurfaceTextureLayer.cpp revision 97c602c5af5f3ffd69009bf496d86347b71a2b4c
1/* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#include <stdlib.h> 18#include <stdint.h> 19#include <sys/types.h> 20 21#include <utils/Errors.h> 22 23#include "Layer.h" 24#include "SurfaceTextureLayer.h" 25 26namespace android { 27// --------------------------------------------------------------------------- 28 29 30SurfaceTextureLayer::SurfaceTextureLayer(GLuint tex, const sp<Layer>& layer) 31 : SurfaceTexture(tex), mLayer(layer) { 32} 33 34SurfaceTextureLayer::~SurfaceTextureLayer() { 35} 36 37 38status_t SurfaceTextureLayer::setDefaultBufferSize(uint32_t w, uint32_t h) 39{ 40 //LOGD("%s, w=%u, h=%u", __PRETTY_FUNCTION__, w, h); 41 return SurfaceTexture::setDefaultBufferSize(w, h); 42} 43 44status_t SurfaceTextureLayer::setDefaultBufferFormat(uint32_t format) 45{ 46 mDefaultFormat = format; 47 return NO_ERROR; 48} 49 50status_t SurfaceTextureLayer::setBufferCount(int bufferCount) { 51 status_t res = SurfaceTexture::setBufferCount(bufferCount); 52 return res; 53} 54 55status_t SurfaceTextureLayer::queueBuffer(int buf, int64_t timestamp, 56 uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform) { 57 58 status_t res = SurfaceTexture::queueBuffer(buf, timestamp, 59 outWidth, outHeight, outTransform); 60 61 sp<Layer> layer(mLayer.promote()); 62 if (layer != NULL) { 63 *outTransform = layer->getOrientation(); 64 } 65 66 return res; 67} 68 69status_t SurfaceTextureLayer::dequeueBuffer(int *buf, 70 uint32_t w, uint32_t h, uint32_t format, uint32_t usage) { 71 72 status_t res(NO_INIT); 73 sp<Layer> layer(mLayer.promote()); 74 if (layer != NULL) { 75 if (format == 0) 76 format = mDefaultFormat; 77 uint32_t effectiveUsage = layer->getEffectiveUsage(usage); 78 //LOGD("%s, w=%u, h=%u, format=%u, usage=%08x, effectiveUsage=%08x", 79 // __PRETTY_FUNCTION__, w, h, format, usage, effectiveUsage); 80 res = SurfaceTexture::dequeueBuffer(buf, w, h, format, effectiveUsage); 81 } 82 return res; 83} 84 85 86// --------------------------------------------------------------------------- 87}; // namespace android 88