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

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

Issue 205843002: GPU: Only restore one texture unit in ScopedTextureBinder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Mock. Created 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/context_state.h" 5 #include "gpu/command_buffer/service/context_state.h"
6 6
7 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 7 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
8 #include "gpu/command_buffer/service/buffer_manager.h" 8 #include "gpu/command_buffer/service/buffer_manager.h"
9 #include "gpu/command_buffer/service/error_state.h" 9 #include "gpu/command_buffer/service/error_state.h"
10 #include "gpu/command_buffer/service/framebuffer_manager.h" 10 #include "gpu/command_buffer/service/framebuffer_manager.h"
(...skipping 28 matching lines...) Expand all
39 GLuint GetOesServiceId(const TextureUnit& unit) { 39 GLuint GetOesServiceId(const TextureUnit& unit) {
40 return unit.bound_texture_external_oes.get() 40 return unit.bound_texture_external_oes.get()
41 ? unit.bound_texture_external_oes->service_id() : 0; 41 ? unit.bound_texture_external_oes->service_id() : 0;
42 } 42 }
43 43
44 GLuint GetArbServiceId(const TextureUnit& unit) { 44 GLuint GetArbServiceId(const TextureUnit& unit) {
45 return unit.bound_texture_rectangle_arb.get() 45 return unit.bound_texture_rectangle_arb.get()
46 ? unit.bound_texture_rectangle_arb->service_id() : 0; 46 ? unit.bound_texture_rectangle_arb->service_id() : 0;
47 } 47 }
48 48
49 GLuint GetServiceId(const TextureUnit& unit, GLuint target) {
50 switch (target) {
51 case GL_TEXTURE_2D:
52 return Get2dServiceId(unit);
53 case GL_TEXTURE_CUBE_MAP:
54 return GetCubeServiceId(unit);
55 case GL_TEXTURE_RECTANGLE_ARB:
56 return GetArbServiceId(unit);
57 case GL_TEXTURE_EXTERNAL_OES:
58 return GetOesServiceId(unit);
59 default:
60 NOTREACHED();
61 return 0;
62 }
63 }
64
65 bool TargetIsSupported(const FeatureInfo* feature_info, GLuint target) {
66 switch (target) {
67 case GL_TEXTURE_2D:
68 return true;
69 case GL_TEXTURE_CUBE_MAP:
70 return true;
71 case GL_TEXTURE_RECTANGLE_ARB:
72 return feature_info->feature_flags().arb_texture_rectangle;
73 case GL_TEXTURE_EXTERNAL_OES:
74 return feature_info->feature_flags().oes_egl_image_external;
75 default:
76 NOTREACHED();
77 return false;
78 }
79 }
80
49 } // anonymous namespace. 81 } // anonymous namespace.
50 82
51 TextureUnit::TextureUnit() 83 TextureUnit::TextureUnit()
52 : bind_target(GL_TEXTURE_2D) { 84 : bind_target(GL_TEXTURE_2D) {
53 } 85 }
54 86
55 TextureUnit::~TextureUnit() { 87 TextureUnit::~TextureUnit() {
56 } 88 }
57 89
58 ContextState::ContextState(FeatureInfo* feature_info, Logger* logger) 90 ContextState::ContextState(FeatureInfo* feature_info, Logger* logger)
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 172
141 void ContextState::RestoreAllTextureUnitBindings( 173 void ContextState::RestoreAllTextureUnitBindings(
142 const ContextState* prev_state) const { 174 const ContextState* prev_state) const {
143 // Restore Texture state. 175 // Restore Texture state.
144 for (size_t ii = 0; ii < texture_units.size(); ++ii) { 176 for (size_t ii = 0; ii < texture_units.size(); ++ii) {
145 RestoreTextureUnitBindings(ii, prev_state); 177 RestoreTextureUnitBindings(ii, prev_state);
146 } 178 }
147 RestoreActiveTexture(); 179 RestoreActiveTexture();
148 } 180 }
149 181
182 void ContextState::RestoreActiveTextureUnitBinding(unsigned int target) const {
183 DCHECK_LT(active_texture_unit, texture_units.size());
184 const TextureUnit& texture_unit = texture_units[active_texture_unit];
185 if (TargetIsSupported(feature_info_, target))
186 glBindTexture(target, GetServiceId(texture_unit, target));
187 }
188
150 void ContextState::RestoreAttribute(GLuint attrib_index) const { 189 void ContextState::RestoreAttribute(GLuint attrib_index) const {
151 const VertexAttrib* attrib = 190 const VertexAttrib* attrib =
152 vertex_attrib_manager->GetVertexAttrib(attrib_index); 191 vertex_attrib_manager->GetVertexAttrib(attrib_index);
153 const void* ptr = reinterpret_cast<const void*>(attrib->offset()); 192 const void* ptr = reinterpret_cast<const void*>(attrib->offset());
154 Buffer* buffer = attrib->buffer(); 193 Buffer* buffer = attrib->buffer();
155 glBindBuffer(GL_ARRAY_BUFFER, buffer ? buffer->service_id() : 0); 194 glBindBuffer(GL_ARRAY_BUFFER, buffer ? buffer->service_id() : 0);
156 glVertexAttribPointer( 195 glVertexAttribPointer(
157 attrib_index, attrib->size(), attrib->type(), attrib->normalized(), 196 attrib_index, attrib->size(), attrib->type(), attrib->normalized(),
158 attrib->gl_stride(), ptr); 197 attrib->gl_stride(), ptr);
159 if (attrib->divisor()) 198 if (attrib->divisor())
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 242
204 // Include the auto-generated part of this file. We split this because it means 243 // Include the auto-generated part of this file. We split this because it means
205 // we can easily edit the non-auto generated parts right here in this file 244 // we can easily edit the non-auto generated parts right here in this file
206 // instead of having to edit some template or the code generator. 245 // instead of having to edit some template or the code generator.
207 #include "gpu/command_buffer/service/context_state_impl_autogen.h" 246 #include "gpu/command_buffer/service/context_state_impl_autogen.h"
208 247
209 } // namespace gles2 248 } // namespace gles2
210 } // namespace gpu 249 } // namespace gpu
211 250
212 251
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/context_state.h ('k') | gpu/command_buffer/service/gl_state_restorer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698