OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/gpu/gpu_video_layer_glx.h" | 5 #include "chrome/gpu/gpu_video_layer_glx.h" |
6 | 6 |
7 #include <GL/glew.h> | 7 #include "app/gfx/gl/gl_bindings.h" |
8 | |
9 #include "chrome/common/gpu_messages.h" | 8 #include "chrome/common/gpu_messages.h" |
10 #include "chrome/gpu/gpu_thread.h" | 9 #include "chrome/gpu/gpu_thread.h" |
11 #include "chrome/gpu/gpu_view_x.h" | 10 #include "chrome/gpu/gpu_view_x.h" |
12 | 11 |
13 // Handy constants for addressing YV12 data. | 12 // Handy constants for addressing YV12 data. |
14 static const int kYUVPlanes = 3; | 13 static const int kYUVPlanes = 3; |
15 static const int kYPlane = 0; | 14 static const int kYPlane = 0; |
16 static const int kUPlane = 1; | 15 static const int kUPlane = 1; |
17 static const int kVPlane = 2; | 16 static const int kVPlane = 2; |
18 | 17 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 memset(textures_, 0, sizeof(textures_)); | 99 memset(textures_, 0, sizeof(textures_)); |
101 | 100 |
102 // Load identity vertices. | 101 // Load identity vertices. |
103 gfx::Rect identity(0, 0, 1, 1); | 102 gfx::Rect identity(0, 0, 1, 1); |
104 CalculateVertices(identity.size(), identity, target_vertices_); | 103 CalculateVertices(identity.size(), identity, target_vertices_); |
105 | 104 |
106 gpu_thread_->AddRoute(routing_id_, this); | 105 gpu_thread_->AddRoute(routing_id_, this); |
107 | 106 |
108 view_->BindContext(); // Must do this before issuing OpenGl. | 107 view_->BindContext(); // Must do this before issuing OpenGl. |
109 | 108 |
110 glMatrixMode(GL_MODELVIEW); | 109 // TODO(apatrick): These functions are not available in GLES2. |
| 110 // glMatrixMode(GL_MODELVIEW); |
111 | 111 |
112 // Create 3 textures, one for each plane, and bind them to different | 112 // Create 3 textures, one for each plane, and bind them to different |
113 // texture units. | 113 // texture units. |
114 glGenTextures(kYUVPlanes, textures_); | 114 glGenTextures(kYUVPlanes, textures_); |
115 | 115 |
116 glBindTexture(GL_TEXTURE_2D, textures_[kYPlane]); | 116 glBindTexture(GL_TEXTURE_2D, textures_[kYPlane]); |
117 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 117 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
118 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 118 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
119 | 119 |
120 glBindTexture(GL_TEXTURE_2D, textures_[kUPlane]); | 120 glBindTexture(GL_TEXTURE_2D, textures_[kUPlane]); |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 vertices[3] = -2.0f * (object.bottom() / height) + 1.0f; | 323 vertices[3] = -2.0f * (object.bottom() / height) + 1.0f; |
324 | 324 |
325 // Top right. | 325 // Top right. |
326 vertices[4] = 2.0f * (object.right() / width) - 1.0f; | 326 vertices[4] = 2.0f * (object.right() / width) - 1.0f; |
327 vertices[5] = -2.0f * (object.y() / height) + 1.0f; | 327 vertices[5] = -2.0f * (object.y() / height) + 1.0f; |
328 | 328 |
329 // Bottom right. | 329 // Bottom right. |
330 vertices[6] = 2.0f * (object.right() / width) - 1.0f; | 330 vertices[6] = 2.0f * (object.right() / width) - 1.0f; |
331 vertices[7] = -2.0f * (object.bottom() / height) + 1.0f; | 331 vertices[7] = -2.0f * (object.bottom() / height) + 1.0f; |
332 } | 332 } |
OLD | NEW |