1 // 2 // Copyright 2018 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 7 // NativeBufferImageSiblingAndroid.cpp: Implements the NativeBufferImageSiblingAndroid class 8 9 #include "libANGLE/renderer/gl/egl/android/NativeBufferImageSiblingAndroid.h" 10 11 #include "common/android_util.h" 12 13 namespace rx 14 { NativeBufferImageSiblingAndroid(EGLClientBuffer buffer)15NativeBufferImageSiblingAndroid::NativeBufferImageSiblingAndroid(EGLClientBuffer buffer) 16 : mBuffer(buffer), mFormat(GL_NONE), mYUV(false) 17 {} 18 ~NativeBufferImageSiblingAndroid()19NativeBufferImageSiblingAndroid::~NativeBufferImageSiblingAndroid() {} 20 initialize(const egl::Display * display)21egl::Error NativeBufferImageSiblingAndroid::initialize(const egl::Display *display) 22 { 23 int pixelFormat = 0; 24 angle::android::GetANativeWindowBufferProperties( 25 angle::android::ClientBufferToANativeWindowBuffer(mBuffer), &mSize.width, &mSize.height, 26 &mSize.depth, &pixelFormat); 27 mFormat = gl::Format(angle::android::NativePixelFormatToGLInternalFormat(pixelFormat)); 28 mYUV = angle::android::NativePixelFormatIsYUV(pixelFormat); 29 30 return egl::NoError(); 31 } 32 getFormat() const33gl::Format NativeBufferImageSiblingAndroid::getFormat() const 34 { 35 return mFormat; 36 } 37 isRenderable(const gl::Context * context) const38bool NativeBufferImageSiblingAndroid::isRenderable(const gl::Context *context) const 39 { 40 return true; 41 } 42 isTexturable(const gl::Context * context) const43bool NativeBufferImageSiblingAndroid::isTexturable(const gl::Context *context) const 44 { 45 return true; 46 } 47 isYUV() const48bool NativeBufferImageSiblingAndroid::isYUV() const 49 { 50 return mYUV; 51 } 52 getSize() const53gl::Extents NativeBufferImageSiblingAndroid::getSize() const 54 { 55 return mSize; 56 } 57 getSamples() const58size_t NativeBufferImageSiblingAndroid::getSamples() const 59 { 60 return 0; 61 } 62 getBuffer() const63EGLClientBuffer NativeBufferImageSiblingAndroid::getBuffer() const 64 { 65 return mBuffer; 66 } 67 68 } // namespace rx 69