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

Side by Side Diff: cc/output/geometry_binding.h

Issue 595593002: Splitting of layers for correct intersections (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 #ifndef CC_OUTPUT_GEOMETRY_BINDING_H_ 5 #ifndef CC_OUTPUT_GEOMETRY_BINDING_H_
6 #define CC_OUTPUT_GEOMETRY_BINDING_H_ 6 #define CC_OUTPUT_GEOMETRY_BINDING_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "cc/output/gl_renderer.h" // For the GLC() macro.
10 #include "gpu/command_buffer/client/gles2_interface.h"
9 #include "third_party/khronos/GLES2/gl2.h" 11 #include "third_party/khronos/GLES2/gl2.h"
12 #include "third_party/khronos/GLES2/gl2ext.h"
13 #include "ui/gfx/rect_f.h"
10 14
11 namespace gfx { 15 namespace gfx {
12 class RectF; 16 class QuadF;
17 class PointF;
13 } 18 }
14 namespace gpu { 19 using gpu::gles2::GLES2Interface;
15 namespace gles2 {
16 class GLES2Interface;
17 }
18 }
19 20
20 namespace cc { 21 namespace cc {
21 22
23 class DrawQuad;
24 class DrawPolygon;
25
22 class GeometryBinding { 26 class GeometryBinding {
23 public: 27 public:
24 GeometryBinding(gpu::gles2::GLES2Interface* gl, 28 GeometryBinding(gpu::gles2::GLES2Interface* gl,
25 const gfx::RectF& quad_vertex_rect); 29 const gfx::RectF& quad_vertex_rect,
30 size_t buffer_size);
26 ~GeometryBinding(); 31 ~GeometryBinding();
27 32
28 void PrepareForDraw(); 33 void PrepareForDraw();
34 void InitializeBaseQuads(size_t buffer_size);
29 35
30 // All layer shaders share the same attribute locations for the vertex 36 // All layer shaders share the same attribute locations for the vertex
31 // positions and texture coordinates. This allows switching shaders without 37 // positions and texture coordinates. This allows switching shaders without
32 // rebinding attribute arrays. 38 // rebinding attribute arrays.
33 static int PositionAttribLocation() { return 0; } 39 static int PositionAttribLocation() { return 0; }
34 static int TexCoordAttribLocation() { return 1; } 40 static int TexCoordAttribLocation() { return 1; }
35 static int TriangleIndexAttribLocation() { return 2; } 41 static int TriangleIndexAttribLocation() { return 2; }
36 42
37 private: 43 protected:
44 struct Vertex {
45 float a_position[3];
46 float a_texCoord[2];
47 // Index of the vertex, divide by 4 to have the matrix for this quad.
48 float a_index;
49 };
50 struct Quad {
51 Vertex v0, v1, v2, v3;
52 };
53
54 struct QuadIndex {
55 uint16 data[6];
56 };
57
38 gpu::gles2::GLES2Interface* gl_; 58 gpu::gles2::GLES2Interface* gl_;
39 59
40 GLuint quad_vertices_vbo_; 60 GLuint quad_vertices_vbo_;
41 GLuint quad_elements_vbo_; 61 GLuint quad_elements_vbo_;
62 gfx::RectF quad_vertex_rect_;
63
64 bool initialized_;
65
66 template <typename S, typename T>
67 void SetBuffers(S* verts,
68 T* indices,
69 int vert_offset,
70 int elem_offset,
71 int vert_size,
72 int elem_size) {
73 // GLC(context_, context_->bindBuffer(GL_ARRAY_BUFFER, quad_vertices_vbo_));
74 GLC(gl_,
75 gl_->BufferSubData(GL_ARRAY_BUFFER,
76 sizeof(S) * vert_offset,
77 sizeof(S) * vert_size,
78 verts));
79
80 /* GLC(context_,
81 context_->bindBuffer(GL_ELEMENT_ARRAY_BUFFER, quad_elements_vbo_)); */
82 GLC(gl_,
83 gl_->BufferSubData(GL_ELEMENT_ARRAY_BUFFER,
84 sizeof(T) * elem_offset,
85 sizeof(T) * elem_size,
86 indices));
87 }
42 88
43 DISALLOW_COPY_AND_ASSIGN(GeometryBinding); 89 DISALLOW_COPY_AND_ASSIGN(GeometryBinding);
44 }; 90 };
45 91
92 class GeometryBindingQuad : public GeometryBinding {
93 public:
94 GeometryBindingQuad(gpu::gles2::GLES2Interface* gl,
95 const gfx::RectF& quad_vertex_rect);
96 void InitializeCustomQuad(const gfx::QuadF& quad);
97 void InitializeCustomQuadWithUVs(const gfx::QuadF& quad, float uv[8]);
98 };
99
46 } // namespace cc 100 } // namespace cc
47 101
48 #endif // CC_OUTPUT_GEOMETRY_BINDING_H_ 102 #endif // CC_OUTPUT_GEOMETRY_BINDING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698