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 uint64_t usage = 0; 25 angle::android::GetANativeWindowBufferProperties( 26 angle::android::ClientBufferToANativeWindowBuffer(mBuffer), &mSize.width, &mSize.height, 27 &mSize.depth, &pixelFormat, &usage); 28 mFormat = gl::Format(angle::android::NativePixelFormatToGLInternalFormat(pixelFormat)); 29 mYUV = angle::android::NativePixelFormatIsYUV(pixelFormat); 30 mHasProtectedContent = false; 31 32 return egl::NoError(); 33 } 34 getFormat() const35gl::Format NativeBufferImageSiblingAndroid::getFormat() const 36 { 37 return mFormat; 38 } 39 isRenderable(const gl::Context * context) const40bool NativeBufferImageSiblingAndroid::isRenderable(const gl::Context *context) const 41 { 42 return true; 43 } 44 isTexturable(const gl::Context * context) const45bool NativeBufferImageSiblingAndroid::isTexturable(const gl::Context *context) const 46 { 47 return true; 48 } 49 isYUV() const50bool NativeBufferImageSiblingAndroid::isYUV() const 51 { 52 return mYUV; 53 } 54 hasProtectedContent() const55bool NativeBufferImageSiblingAndroid::hasProtectedContent() const 56 { 57 return mHasProtectedContent; 58 } 59 getSize() const60gl::Extents NativeBufferImageSiblingAndroid::getSize() const 61 { 62 return mSize; 63 } 64 getSamples() const65size_t NativeBufferImageSiblingAndroid::getSamples() const 66 { 67 return 0; 68 } 69 getBuffer() const70EGLClientBuffer NativeBufferImageSiblingAndroid::getBuffer() const 71 { 72 return mBuffer; 73 } 74 75 } // namespace rx 76