OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/gl2chromium.h> | 6 #include <GLES2/gl2chromium.h> |
7 #include <GLES2/gl2ext.h> | 7 #include <GLES2/gl2ext.h> |
8 #include <GLES2/gl2extchromium.h> | 8 #include <GLES2/gl2extchromium.h> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 mapped_buffer[y * stride + x * kImageBytesPerPixel + 1] = pixels[1]; | 89 mapped_buffer[y * stride + x * kImageBytesPerPixel + 1] = pixels[1]; |
90 mapped_buffer[y * stride + x * kImageBytesPerPixel + 2] = pixels[2]; | 90 mapped_buffer[y * stride + x * kImageBytesPerPixel + 2] = pixels[2]; |
91 mapped_buffer[y * stride + x * kImageBytesPerPixel + 3] = pixels[3]; | 91 mapped_buffer[y * stride + x * kImageBytesPerPixel + 3] = pixels[3]; |
92 } | 92 } |
93 } | 93 } |
94 | 94 |
95 // Unmap the buffer. | 95 // Unmap the buffer. |
96 buffer->Unmap(); | 96 buffer->Unmap(); |
97 | 97 |
98 // Create the image. This should add the image ID to the ImageManager. | 98 // Create the image. This should add the image ID to the ImageManager. |
| 99 ClientBuffer client_buffer = buffer->AsClientBuffer(); |
99 GLuint image_id = glCreateImageCHROMIUM( | 100 GLuint image_id = glCreateImageCHROMIUM( |
100 buffer->AsClientBuffer(), kImageWidth, kImageHeight, GL_RGBA); | 101 const_cast<const ClientBuffer* const>(&client_buffer), kImageWidth, |
| 102 kImageHeight, GL_RGBA); |
101 EXPECT_NE(0u, image_id); | 103 EXPECT_NE(0u, image_id); |
102 EXPECT_TRUE(gl_.decoder()->GetImageManager()->LookupImage(image_id) != NULL); | 104 EXPECT_TRUE(gl_.decoder()->GetImageManager()->LookupImage(image_id) != NULL); |
103 | 105 |
104 // Bind the texture and the image. | 106 // Bind the texture and the image. |
105 glBindTexture(GL_TEXTURE_2D, texture_ids_[0]); | 107 glBindTexture(GL_TEXTURE_2D, texture_ids_[0]); |
106 glBindTexImage2DCHROMIUM(GL_TEXTURE_2D, image_id); | 108 glBindTexImage2DCHROMIUM(GL_TEXTURE_2D, image_id); |
107 | 109 |
108 // Copy texture so we can verify result using CheckPixels. | 110 // Copy texture so we can verify result using CheckPixels. |
109 glCopyTextureCHROMIUM(GL_TEXTURE_2D, | 111 glCopyTextureCHROMIUM(GL_TEXTURE_2D, |
110 texture_ids_[0], | 112 texture_ids_[0], |
111 texture_ids_[1], | 113 texture_ids_[1], |
112 0, | 114 0, |
113 GL_RGBA, | 115 GL_RGBA, |
114 GL_UNSIGNED_BYTE); | 116 GL_UNSIGNED_BYTE); |
115 EXPECT_TRUE(glGetError() == GL_NO_ERROR); | 117 EXPECT_TRUE(glGetError() == GL_NO_ERROR); |
116 | 118 |
117 // Check if pixels match the values that were assigned to the mapped buffer. | 119 // Check if pixels match the values that were assigned to the mapped buffer. |
118 GLTestHelper::CheckPixels(0, 0, kImageWidth, kImageHeight, 0, pixels); | 120 GLTestHelper::CheckPixels(0, 0, kImageWidth, kImageHeight, 0, pixels); |
119 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 121 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
120 | 122 |
121 // Release the image. | 123 // Release the image. |
122 glReleaseTexImage2DCHROMIUM(GL_TEXTURE_2D, image_id); | 124 glReleaseTexImage2DCHROMIUM(GL_TEXTURE_2D, image_id); |
123 | 125 |
124 // Destroy the image. | 126 // Destroy the image. |
125 glDestroyImageCHROMIUM(image_id); | 127 glDestroyImageCHROMIUM(image_id); |
126 } | 128 } |
127 | 129 |
128 } // namespace gles2 | 130 } // namespace gles2 |
129 } // namespace gpu | 131 } // namespace gpu |
OLD | NEW |