• 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     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() const33 gl::Format NativeBufferImageSiblingAndroid::getFormat() const
34 {
35     return mFormat;
36 }
37 
isRenderable(const gl::Context * context) const38 bool NativeBufferImageSiblingAndroid::isRenderable(const gl::Context *context) const
39 {
40     return true;
41 }
42 
isTexturable(const gl::Context * context) const43 bool NativeBufferImageSiblingAndroid::isTexturable(const gl::Context *context) const
44 {
45     return true;
46 }
47 
isYUV() const48 bool NativeBufferImageSiblingAndroid::isYUV() const
49 {
50     return mYUV;
51 }
52 
getSize() const53 gl::Extents NativeBufferImageSiblingAndroid::getSize() const
54 {
55     return mSize;
56 }
57 
getSamples() const58 size_t NativeBufferImageSiblingAndroid::getSamples() const
59 {
60     return 0;
61 }
62 
getBuffer() const63 EGLClientBuffer NativeBufferImageSiblingAndroid::getBuffer() const
64 {
65     return mBuffer;
66 }
67 
68 }  // namespace rx
69