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

Side by Side Diff: cc/output/dynamic_geometry_binding.cc

Issue 959403002: Initialize our quads to zero before we gl_->BufferData() with them. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 | « no previous file | cc/output/geometry_binding.h » ('j') | cc/output/geometry_binding.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 "cc/output/dynamic_geometry_binding.h" 5 #include "cc/output/dynamic_geometry_binding.h"
6 6
7 #include "cc/output/gl_renderer.h" // For the GLC() macro. 7 #include "cc/output/gl_renderer.h" // For the GLC() macro.
8 #include "gpu/command_buffer/client/gles2_interface.h" 8 #include "gpu/command_buffer/client/gles2_interface.h"
9 #include "ui/gfx/geometry/rect_f.h" 9 #include "ui/gfx/geometry/rect_f.h"
10 10
11 namespace cc { 11 namespace cc {
12 12
13 DynamicGeometryBinding::DynamicGeometryBinding(gpu::gles2::GLES2Interface* gl) 13 DynamicGeometryBinding::DynamicGeometryBinding(gpu::gles2::GLES2Interface* gl)
14 : gl_(gl), quad_vertices_vbo_(0), quad_elements_vbo_(0) { 14 : gl_(gl), quad_vertices_vbo_(0), quad_elements_vbo_(0) {
15 GeometryBindingQuad quads[8]; 15 GeometryBindingQuad quads[1];
16 GeometryBindingQuadIndex quad_indices[8]; 16 GeometryBindingQuadIndex quad_indices[1];
17 17
18 static_assert(sizeof(GeometryBindingQuad) == 24 * sizeof(float), 18 static_assert(sizeof(GeometryBindingQuad) == 24 * sizeof(float),
19 "struct Quad should be densely packed"); 19 "struct Quad should be densely packed");
20 static_assert(sizeof(GeometryBindingQuadIndex) == 6 * sizeof(uint16_t), 20 static_assert(sizeof(GeometryBindingQuadIndex) == 6 * sizeof(uint16_t),
21 "struct QuadIndex should be densely packed"); 21 "struct QuadIndex should be densely packed");
22 22
23 GLC(gl_, gl_->GenBuffers(1, &quad_vertices_vbo_)); 23 GLC(gl_, gl_->GenBuffers(1, &quad_vertices_vbo_));
24 GLC(gl_, gl_->GenBuffers(1, &quad_elements_vbo_)); 24 GLC(gl_, gl_->GenBuffers(1, &quad_elements_vbo_));
25 25
26 GLC(gl_, gl_->BindBuffer(GL_ARRAY_BUFFER, quad_vertices_vbo_)); 26 GLC(gl_, gl_->BindBuffer(GL_ARRAY_BUFFER, quad_vertices_vbo_));
(...skipping 16 matching lines...) Expand all
43 GeometryBindingVertex v0 = { 43 GeometryBindingVertex v0 = {
44 {quad.p1().x(), quad.p1().y(), 0.0f}, {uv[0], uv[1]}, 0.0f}; 44 {quad.p1().x(), quad.p1().y(), 0.0f}, {uv[0], uv[1]}, 0.0f};
45 GeometryBindingVertex v1 = { 45 GeometryBindingVertex v1 = {
46 {quad.p2().x(), quad.p2().y(), 0.0f}, {uv[2], uv[3]}, 1.0f}; 46 {quad.p2().x(), quad.p2().y(), 0.0f}, {uv[2], uv[3]}, 1.0f};
47 GeometryBindingVertex v2 = { 47 GeometryBindingVertex v2 = {
48 {quad.p3().x(), quad.p3().y(), 0.0f}, {uv[4], uv[5]}, 2.0f}; 48 {quad.p3().x(), quad.p3().y(), 0.0f}, {uv[4], uv[5]}, 2.0f};
49 GeometryBindingVertex v3 = { 49 GeometryBindingVertex v3 = {
50 {quad.p4().x(), quad.p4().y(), 0.0f}, {uv[6], uv[7]}, 3.0f}; 50 {quad.p4().x(), quad.p4().y(), 0.0f}, {uv[6], uv[7]}, 3.0f};
51 51
52 GeometryBindingQuad local_quad = {v0, v1, v2, v3}; 52 GeometryBindingQuad local_quad = {v0, v1, v2, v3};
53 GeometryBindingQuadIndex quad_index = {{static_cast<uint16>(0), 53 GeometryBindingQuadIndex quad_index = {static_cast<uint16>(0),
54 static_cast<uint16>(1), 54 static_cast<uint16>(1),
55 static_cast<uint16>(2), 55 static_cast<uint16>(2),
56 static_cast<uint16>(3), 56 static_cast<uint16>(3),
57 static_cast<uint16>(0), 57 static_cast<uint16>(0),
58 static_cast<uint16>(2)}}; 58 static_cast<uint16>(2)};
59 59
60 GLC(gl_, gl_->BufferSubData(GL_ARRAY_BUFFER, 0, sizeof(GeometryBindingQuad), 60 GLC(gl_, gl_->BufferSubData(GL_ARRAY_BUFFER, 0, sizeof(GeometryBindingQuad),
61 &local_quad)); 61 &local_quad));
62 GLC(gl_, gl_->BufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, 62 GLC(gl_, gl_->BufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0,
63 sizeof(GeometryBindingQuadIndex), &quad_index)); 63 sizeof(GeometryBindingQuadIndex), &quad_index));
64 } 64 }
65 65
66 void DynamicGeometryBinding::PrepareForDraw() { 66 void DynamicGeometryBinding::PrepareForDraw() {
67 SetupGLContext(gl_, quad_elements_vbo_, quad_vertices_vbo_); 67 SetupGLContext(gl_, quad_elements_vbo_, quad_vertices_vbo_);
68 } 68 }
69 69
70 } // namespace cc 70 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/output/geometry_binding.h » ('j') | cc/output/geometry_binding.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698