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

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

Issue 1533773002: Delete CC. (Closed) Base URL: git@github.com:domokit/mojo.git@cl-2e
Patch Set: rebase 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 | « cc/output/dynamic_geometry_binding.h ('k') | cc/output/filter_operation.h » ('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 "cc/output/dynamic_geometry_binding.h"
6
7 #include "cc/output/gl_renderer.h" // For the GLC() macro.
8 #include "gpu/command_buffer/client/gles2_interface.h"
9 #include "ui/gfx/geometry/rect_f.h"
10
11 namespace cc {
12
13 DynamicGeometryBinding::DynamicGeometryBinding(gpu::gles2::GLES2Interface* gl)
14 : gl_(gl), quad_vertices_vbo_(0), quad_elements_vbo_(0) {
15 GeometryBindingQuad quads[1];
16 GeometryBindingQuadIndex quad_indices[1];
17
18 static_assert(sizeof(GeometryBindingQuad) == 24 * sizeof(float),
19 "struct Quad should be densely packed");
20 static_assert(sizeof(GeometryBindingQuadIndex) == 6 * sizeof(uint16_t),
21 "struct QuadIndex should be densely packed");
22
23 GLC(gl_, gl_->GenBuffers(1, &quad_vertices_vbo_));
24 GLC(gl_, gl_->GenBuffers(1, &quad_elements_vbo_));
25
26 GLC(gl_, gl_->BindBuffer(GL_ARRAY_BUFFER, quad_vertices_vbo_));
27 GLC(gl_, gl_->BufferData(GL_ARRAY_BUFFER, sizeof(GeometryBindingQuad) * 1,
28 quads, GL_DYNAMIC_DRAW));
29
30 GLC(gl_, gl_->BindBuffer(GL_ELEMENT_ARRAY_BUFFER, quad_elements_vbo_));
31 GLC(gl_, gl_->BufferData(GL_ELEMENT_ARRAY_BUFFER,
32 sizeof(GeometryBindingQuadIndex) * 1, &quad_indices,
33 GL_DYNAMIC_DRAW));
34 }
35
36 void DynamicGeometryBinding::InitializeCustomQuad(const gfx::QuadF& quad) {
37 float uv[] = {0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f};
38 InitializeCustomQuadWithUVs(quad, uv);
39 }
40
41 void DynamicGeometryBinding::InitializeCustomQuadWithUVs(const gfx::QuadF& quad,
42 const float uv[8]) {
43 GeometryBindingVertex v0 = {
44 {quad.p1().x(), quad.p1().y(), 0.0f}, {uv[0], uv[1]}, 0.0f};
45 GeometryBindingVertex v1 = {
46 {quad.p2().x(), quad.p2().y(), 0.0f}, {uv[2], uv[3]}, 1.0f};
47 GeometryBindingVertex v2 = {
48 {quad.p3().x(), quad.p3().y(), 0.0f}, {uv[4], uv[5]}, 2.0f};
49 GeometryBindingVertex v3 = {
50 {quad.p4().x(), quad.p4().y(), 0.0f}, {uv[6], uv[7]}, 3.0f};
51
52 GeometryBindingQuad local_quad = {v0, v1, v2, v3};
53 GeometryBindingQuadIndex quad_index(
54 static_cast<uint16>(0), static_cast<uint16>(1), static_cast<uint16>(2),
55 static_cast<uint16>(3), static_cast<uint16>(0), static_cast<uint16>(2));
56
57 GLC(gl_, gl_->BufferSubData(GL_ARRAY_BUFFER, 0, sizeof(GeometryBindingQuad),
58 &local_quad));
59 GLC(gl_, gl_->BufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0,
60 sizeof(GeometryBindingQuadIndex), &quad_index));
61 }
62
63 void DynamicGeometryBinding::PrepareForDraw() {
64 SetupGLContext(gl_, quad_elements_vbo_, quad_vertices_vbo_);
65 }
66
67 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/dynamic_geometry_binding.h ('k') | cc/output/filter_operation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698