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

Side by Side 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: libs = [] 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 unified diff | Download patch
« no previous file with comments | « ui/gl/gl_image_surface_texture.cc ('k') | ui/gl/gl_tests.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <android/native_window.h>
6 #include <android/native_window_jni.h>
7
8 #include "base/android/jni_android.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/gfx/buffer_format_util.h"
11 #include "ui/gl/android/scoped_java_surface.h"
12 #include "ui/gl/android/surface_texture.h"
13 #include "ui/gl/gl_image_surface_texture.h"
14 #include "ui/gl/test/gl_image_test_template.h"
15
16 namespace gl {
17 namespace {
18
19 class GLImageSurfaceTextureTestDelegate {
20 public:
21 scoped_refptr<GLImage> CreateSolidColorImage(const gfx::Size& size,
22 const uint8_t color[4]) const {
23 scoped_refptr<GLImageSurfaceTexture> image(new GLImageSurfaceTexture(size));
24
25 GLuint texture_id = 0;
26 glGenTextures(1, &texture_id);
27 scoped_refptr<gfx::SurfaceTexture> surface_texture =
28 gfx::SurfaceTexture::Create(texture_id);
29 gfx::ScopedJavaSurface surface(surface_texture.get());
30 JNIEnv* env = base::android::AttachCurrentThread();
31 ANativeWindow* native_window =
32 ANativeWindow_fromSurface(env, surface.j_surface().obj());
33 ANativeWindow_setBuffersGeometry(native_window, size.width(), size.height(),
34 WINDOW_FORMAT_RGBA_8888);
35 ANativeWindow_Buffer buffer;
36 bool rv = ANativeWindow_lock(native_window, &buffer, nullptr);
37 EXPECT_TRUE(rv);
38 GLImageTestSupport::SetBufferDataToColor(
39 size.width(), size.height(), buffer.stride * 4, 0,
40 gfx::BufferFormat::RGBA_8888, color,
41 static_cast<uint8_t*>(buffer.bits));
42 ANativeWindow_unlockAndPost(native_window);
43
44 rv = image->Initialize(surface_texture.get());
45 EXPECT_TRUE(rv);
46
47 return image;
48 }
49 };
50
51 INSTANTIATE_TYPED_TEST_CASE_P(GLImageSurfaceTexture,
52 GLImageTest,
53 GLImageSurfaceTextureTestDelegate);
54
55 INSTANTIATE_TYPED_TEST_CASE_P(GLImageSurfaceTexture,
56 GLImageCopyTest,
57 GLImageSurfaceTextureTestDelegate);
58
59 } // namespace
60 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/gl_image_surface_texture.cc ('k') | ui/gl/gl_tests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698