Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1211)

Unified Diff: ui/gl/gl_image_surface_texture_unittest.cc

Issue 1419623008: ui: Use single buffer SurfaceTexture mode for native GpuMemoryBuffers on Android. Base URL: https://chromium.googlesource.com/chromium/src.git@1419733005
Patch Set: rebase Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/gl/gl_image_surface_texture_unittest.cc
diff --git a/ui/gl/gl_image_surface_texture_unittest.cc b/ui/gl/gl_image_surface_texture_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..bffc55e1911a2f9b583f36d457b33f7c605a3be0
--- /dev/null
+++ b/ui/gl/gl_image_surface_texture_unittest.cc
@@ -0,0 +1,61 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <android/native_window.h>
+#include <android/native_window_jni.h>
+
+#include "base/android/jni_android.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/gfx/buffer_format_util.h"
+#include "ui/gl/android/scoped_java_surface.h"
+#include "ui/gl/android/surface_texture.h"
+#include "ui/gl/gl_image_surface_texture.h"
+#include "ui/gl/test/gl_image_test_template.h"
+
+namespace gfx {
Daniele Castagna 2015/12/05 23:43:57 This should be gl.
reveman 2015/12/05 23:54:07 Done.
+namespace {
+
+class GLImageSurfaceTextureTestDelegate {
+ public:
+ scoped_refptr<gl::GLImage> CreateSolidColorImage(
+ const Size& size,
+ const uint8_t color[4]) const {
+ scoped_refptr<gl::GLImageSurfaceTexture> image(
+ new gl::GLImageSurfaceTexture(size));
+
+ GLuint texture_id = 0;
+ glGenTextures(1, &texture_id);
+ scoped_refptr<gfx::SurfaceTexture> surface_texture =
+ gfx::SurfaceTexture::Create(texture_id);
+ gfx::ScopedJavaSurface surface(surface_texture.get());
+ JNIEnv* env = base::android::AttachCurrentThread();
+ ANativeWindow* native_window =
+ ANativeWindow_fromSurface(env, surface.j_surface().obj());
+ ANativeWindow_setBuffersGeometry(native_window, size.width(), size.height(),
+ WINDOW_FORMAT_RGBA_8888);
+ ANativeWindow_Buffer buffer;
+ bool rv = ANativeWindow_lock(native_window, &buffer, nullptr);
+ EXPECT_TRUE(rv);
+ GLImageTestSupport::SetBufferDataToColor(
+ size.width(), size.height(), buffer.stride * 4, 0,
+ BufferFormat::RGBA_8888, color, static_cast<uint8_t*>(buffer.bits));
+ ANativeWindow_unlockAndPost(native_window);
+
+ rv = image->Initialize(surface_texture.get());
+ EXPECT_TRUE(rv);
+
+ return image;
+ }
+};
+
+INSTANTIATE_TYPED_TEST_CASE_P(GLImageSurfaceTexture,
+ GLImageTest,
+ GLImageSurfaceTextureTestDelegate);
+
+INSTANTIATE_TYPED_TEST_CASE_P(GLImageSurfaceTexture,
+ GLImageCopyTest,
+ GLImageSurfaceTextureTestDelegate);
+
+} // namespace
+} // namespace gfx

Powered by Google App Engine
This is Rietveld 408576698