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

Side by Side Diff: gpu/command_buffer/service/indexed_buffer_binding_host_unittest.cc

Issue 1949303003: Improve indexed gl state related GL commands. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tex
Patch Set: fix a DCHECK failure Created 4 years, 7 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 | « gpu/command_buffer/service/indexed_buffer_binding_host.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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 "gpu/command_buffer/service/buffer_manager.h" 5 #include "gpu/command_buffer/service/buffer_manager.h"
6 #include "gpu/command_buffer/service/gpu_service_test.h" 6 #include "gpu/command_buffer/service/gpu_service_test.h"
7 #include "gpu/command_buffer/service/indexed_buffer_binding_host.h" 7 #include "gpu/command_buffer/service/indexed_buffer_binding_host.h"
8 #include "ui/gl/gl_mock.h" 8 #include "ui/gl/gl_mock.h"
9 9
10 namespace gpu { 10 namespace gpu {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // Now adjust buffer size to be big enough. 106 // Now adjust buffer size to be big enough.
107 EXPECT_CALL(*gl_, BindBufferRange(kTarget, kIndex, kBufferServiceId, kOffset, 107 EXPECT_CALL(*gl_, BindBufferRange(kTarget, kIndex, kBufferServiceId, kOffset,
108 kSize)) 108 kSize))
109 .Times(1) 109 .Times(1)
110 .RetiresOnSaturation(); 110 .RetiresOnSaturation();
111 111
112 SetBufferSize(kTarget, kOffset + kSize); 112 SetBufferSize(kTarget, kOffset + kSize);
113 host_->OnBufferData(kTarget, buffer_.get()); 113 host_->OnBufferData(kTarget, buffer_.get());
114 } 114 }
115 115
116 TEST_F(IndexedBufferBindingHostTest, RestoreBindings) {
117 const GLenum kTarget = GL_UNIFORM_BUFFER;
118 const GLuint kIndex = 2;
119 const GLuint kOtherIndex = 10;
120 const GLintptr kOffset = 4;
121 const GLsizeiptr kSize = 8;
122 const GLsizeiptr kBufferSize = kOffset + kSize - 2;
123
124 GLsizeiptr clamped_size = ((kBufferSize - kOffset) >> 2) << 2;
125
126 SetBufferSize(kTarget, kBufferSize);
127 // Set up host
128 EXPECT_CALL(*gl_, BindBufferBase(kTarget, kIndex, kBufferServiceId))
129 .Times(1)
130 .RetiresOnSaturation();
131 host_->DoBindBufferBase(kTarget, kIndex, buffer_.get());
132 // Set up the second host
133 scoped_refptr<IndexedBufferBindingHost> other =
134 new IndexedBufferBindingHost(kMaxBindings, true);
135 EXPECT_CALL(*gl_, BindBufferRange(kTarget, kOtherIndex, kBufferServiceId,
136 kOffset, clamped_size))
137 .Times(1)
138 .RetiresOnSaturation();
139 other->DoBindBufferRange(kTarget, kOtherIndex, buffer_.get(), kOffset, kSize);
140
141 {
142 // Switching from |other| to |host_|.
143 EXPECT_CALL(*gl_, BindBufferBase(kTarget, kIndex, kBufferServiceId))
144 .Times(1)
145 .RetiresOnSaturation();
146 EXPECT_CALL(*gl_, BindBufferBase(kTarget, kOtherIndex, 0))
147 .Times(1)
148 .RetiresOnSaturation();
149 host_->RestoreBindings(other.get());
150 }
151
152 {
153 // Switching from |host_| to |other|.
154 EXPECT_CALL(*gl_, BindBufferBase(kTarget, kIndex, 0))
155 .Times(1)
156 .RetiresOnSaturation();
157 EXPECT_CALL(*gl_, BindBufferRange(kTarget, kOtherIndex, kBufferServiceId,
158 kOffset, clamped_size))
159 .Times(1)
160 .RetiresOnSaturation();
161 other->RestoreBindings(host_.get());
162 }
163 }
164
116 } // namespace gles2 165 } // namespace gles2
117 } // namespace gpu 166 } // namespace gpu
118 167
119 168
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/indexed_buffer_binding_host.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698