• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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)15 NativeBufferImageSiblingAndroid::NativeBufferImageSiblingAndroid(EGLClientBuffer buffer)
16     : mBuffer(buffer), mFormat(GL_NONE), mYUV(false)
17 {}
18 
~NativeBufferImageSiblingAndroid()19 NativeBufferImageSiblingAndroid::~NativeBufferImageSiblingAndroid() {}
20 
initialize(const egl::Display * display)21 egl::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() const35 gl::Format NativeBufferImageSiblingAndroid::getFormat() const
36 {
37     return mFormat;
38 }
39 
isRenderable(const gl::Context * context) const40 bool NativeBufferImageSiblingAndroid::isRenderable(const gl::Context *context) const
41 {
42     return true;
43 }
44 
isTexturable(const gl::Context * context) const45 bool NativeBufferImageSiblingAndroid::isTexturable(const gl::Context *context) const
46 {
47     return true;
48 }
49 
isYUV() const50 bool NativeBufferImageSiblingAndroid::isYUV() const
51 {
52     return mYUV;
53 }
54 
hasProtectedContent() const55 bool NativeBufferImageSiblingAndroid::hasProtectedContent() const
56 {
57     return mHasProtectedContent;
58 }
59 
getSize() const60 gl::Extents NativeBufferImageSiblingAndroid::getSize() const
61 {
62     return mSize;
63 }
64 
getSamples() const65 size_t NativeBufferImageSiblingAndroid::getSamples() const
66 {
67     return 0;
68 }
69 
getBuffer() const70 EGLClientBuffer NativeBufferImageSiblingAndroid::getBuffer() const
71 {
72     return mBuffer;
73 }
74 
75 }  // namespace rx
76