Skip to content

Commit

Permalink
gapii: Only read ANativeWindowBuffer.layer_count on Android O or later.
Browse files Browse the repository at this point in the history
Fixes: #1554
  • Loading branch information
ben-clayton committed Jan 26, 2018
1 parent 3edac9f commit b465e77
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
8 changes: 8 additions & 0 deletions core/os/device/deviceinfo/cc/android/query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,14 @@ bool createContext(void* platform_data) {
}

switch (gContext.mOSVersion) {
case 27: // Oreo
gContext.mOSVersionMajor = 8;
gContext.mOSVersionMinor = 1;
break;
case 26: // Oreo
gContext.mOSVersionMajor = 8;
gContext.mOSVersionMinor = 0;
break;
case 25: // Nougat
gContext.mOSVersionMajor = 7;
gContext.mOSVersionMinor = 1;
Expand Down
17 changes: 14 additions & 3 deletions gapii/cc/gles_extras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@

#include "gapis/api/gles/gles_pb/extras.pb.h"

#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
#endif // __STDC_FORMAT_MACROS
#include <inttypes.h>

#define ANDROID_NATIVE_MAKE_CONSTANT(a,b,c,d) \
(((unsigned)(a)<<24)|((unsigned)(b)<<16)|((unsigned)(c)<<8)|(unsigned)(d))

Expand Down Expand Up @@ -536,16 +541,22 @@ std::shared_ptr<AndroidNativeBufferExtra> GlesSpy::GetAndroidNativeBufferExtra(C
return nullptr;
}

auto android_version_major = device_instance()->configuration().os().major();

bool use_layer_count = android_version_major >= 8; // Android O

std::shared_ptr<AndroidNativeBufferExtra> extra(new AndroidNativeBufferExtra(
buffer->width,
buffer->height,
buffer->stride,
buffer->format,
buffer->usage,
buffer->layer_count
use_layer_count ? buffer->layer_count : 0
));
GAPID_INFO("Created AndroidNativeBufferExtra: width=%i, height=%i, layers=%llx",
buffer->width, buffer->height, (uint64_t)buffer->layer_count);

GAPID_INFO("Created AndroidNativeBufferExtra: os_version:%i, width=%i, height=%i, layers=%" PRIx64,
(int)android_version_major, buffer->width, buffer->height, (uint64_t)buffer->layer_count);

observer->encodeAndDelete(extra->toProto());
return extra;
#else
Expand Down

0 comments on commit b465e77

Please sign in to comment.