1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31

gpu / vulkan / tests / native_window_android.cc [blame]

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "gpu/vulkan/tests/native_window.h"

#include "ui/gl/android/scoped_a_native_window.h"
#include "ui/gl/android/surface_texture.h"

namespace gpu {

scoped_refptr<gl::SurfaceTexture> g_surface_texture;
gl::ScopedANativeWindow g_widget;

gfx::AcceleratedWidget CreateNativeWindow(const gfx::Rect& bounds) {
  DCHECK(!g_surface_texture);
  DCHECK(g_widget.a_native_window() == gfx::kNullAcceleratedWidget);
  // TODO(penghuang): Not depend on gl.
  uint texture = 0;
  g_surface_texture = gl::SurfaceTexture::Create(texture);
  g_widget = g_surface_texture->CreateSurface();
  return g_widget.a_native_window();
}

void DestroyNativeWindow(gfx::AcceleratedWidget window) {
  DCHECK_EQ(g_widget.a_native_window(), window);
  g_widget = nullptr;
  g_surface_texture = nullptr;
}

}  // namespace gpu