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

Side by Side Diff: gpu/command_buffer/tests/gl_native_gmb_backbuffer_unittest.cc

Issue 2129523004: Fix a bug with emulated RGB offscreen native GpuMemoryBuffers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months 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 | « gpu/command_buffer/service/gles2_cmd_decoder.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <GLES2/gl2.h> 5 #include <GLES2/gl2.h>
6 #include <GLES2/gl2ext.h> 6 #include <GLES2/gl2ext.h>
7 #include <GLES2/gl2extchromium.h> 7 #include <GLES2/gl2extchromium.h>
8 8
9 #include "gpu/command_buffer/client/gles2_lib.h" 9 #include "gpu/command_buffer/client/gles2_lib.h"
10 #include "gpu/command_buffer/service/image_factory.h" 10 #include "gpu/command_buffer/service/image_factory.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 GLManager::Options options; 43 GLManager::Options options;
44 options.image_factory = &image_factory_; 44 options.image_factory = &image_factory_;
45 options.multisampled = msaa == 1; 45 options.multisampled = msaa == 1;
46 options.backbuffer_alpha = has_alpha == 1; 46 options.backbuffer_alpha = has_alpha == 1;
47 options.enable_arb_texture_rectangle = true; 47 options.enable_arb_texture_rectangle = true;
48 48
49 GLManager gl; 49 GLManager gl;
50 gl.Initialize(options); 50 gl.Initialize(options);
51 gl.MakeCurrent(); 51 gl.MakeCurrent();
52 52
53 glResizeCHROMIUM(10, 10, 1, true); 53 // Clear the back buffer and check that it has the right values.
54 glClearColor(0.0f, 0.25f, 0.5f, 0.7f); 54 glClearColor(0.0f, 0.25f, 0.5f, 0.7f);
55 glClear(GL_COLOR_BUFFER_BIT); 55 glClear(GL_COLOR_BUFFER_BIT);
56
57 uint8_t pixel[4]; 56 uint8_t pixel[4];
58 memset(pixel, 0, 4); 57 memset(pixel, 0, 4);
59 glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel); 58 glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel);
60 EXPECT_NEAR(0u, pixel[0], 2); 59 EXPECT_NEAR(0u, pixel[0], 2);
61 EXPECT_NEAR(64u, pixel[1], 2); 60 EXPECT_NEAR(64u, pixel[1], 2);
62 EXPECT_NEAR(127u, pixel[2], 2); 61 EXPECT_NEAR(127u, pixel[2], 2);
63 uint8_t alpha = has_alpha ? 178 : 255; 62 uint8_t alpha = has_alpha ? 178 : 255;
64 EXPECT_NEAR(alpha, pixel[3], 2); 63 EXPECT_NEAR(alpha, pixel[3], 2);
65 64
65 // Resize, then clear the back buffer and check its contents.
66 glResizeCHROMIUM(10, 10, 1, true);
67 glClearColor(0.5f, 0.6f, 0.7f, 0.8f);
68 glClear(GL_COLOR_BUFFER_BIT);
69 memset(pixel, 0, 4);
70 glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel);
71 EXPECT_NEAR(128u, pixel[0], 2);
72 EXPECT_NEAR(153u, pixel[1], 2);
73 EXPECT_NEAR(178u, pixel[2], 2);
74 uint8_t alpha2 = has_alpha ? 204 : 255;
75 EXPECT_NEAR(alpha2, pixel[3], 2);
76
77 // Swap buffers, then clear the back buffer and check its contents.
66 ::gles2::GetGLContext()->SwapBuffers(); 78 ::gles2::GetGLContext()->SwapBuffers();
67 glClearColor(0.1f, 0.2f, 0.3f, 0.4f); 79 glClearColor(0.1f, 0.2f, 0.3f, 0.4f);
68 glClear(GL_COLOR_BUFFER_BIT); 80 glClear(GL_COLOR_BUFFER_BIT);
69 memset(pixel, 0, 4); 81 memset(pixel, 0, 4);
70 glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel); 82 glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel);
71 EXPECT_NEAR(25u, pixel[0], 2); 83 EXPECT_NEAR(25u, pixel[0], 2);
72 EXPECT_NEAR(51u, pixel[1], 2); 84 EXPECT_NEAR(51u, pixel[1], 2);
73 EXPECT_NEAR(76u, pixel[2], 2); 85 EXPECT_NEAR(76u, pixel[2], 2);
74 uint8_t alpha2 = has_alpha ? 102 : 255; 86 uint8_t alpha3 = has_alpha ? 102 : 255;
75 EXPECT_NEAR(alpha2, pixel[3], 2); 87 EXPECT_NEAR(alpha3, pixel[3], 2);
76 88
77 gl.Destroy(); 89 gl.Destroy();
78 } 90 }
79 } 91 }
80 } 92 }
81 93
82 } // namespace gpu 94 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698