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

Side by Side Diff: core/cross/command_buffer/renderer_cb.cc

Issue 212018: Change command buffer client code to use structures.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: '' Created 11 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 | Annotate | Revision Log
« no previous file with comments | « core/cross/command_buffer/render_surface_cb.cc ('k') | core/cross/command_buffer/sampler_cb.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2009, Google Inc. 2 * Copyright 2009, Google Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 // Adds the CLEAR command to the command buffer. 180 // Adds the CLEAR command to the command buffer.
181 void RendererCB::PlatformSpecificClear(const Float4 &color, 181 void RendererCB::PlatformSpecificClear(const Float4 &color,
182 bool color_flag, 182 bool color_flag,
183 float depth, 183 float depth,
184 bool depth_flag, 184 bool depth_flag,
185 int stencil, 185 int stencil,
186 bool stencil_flag) { 186 bool stencil_flag) {
187 uint32 buffers = (color_flag ? GAPIInterface::COLOR : 0) | 187 uint32 buffers = (color_flag ? GAPIInterface::COLOR : 0) |
188 (depth_flag ? GAPIInterface::DEPTH : 0) | 188 (depth_flag ? GAPIInterface::DEPTH : 0) |
189 (stencil_flag ? GAPIInterface::STENCIL : 0); 189 (stencil_flag ? GAPIInterface::STENCIL : 0);
190 command_buffer::CommandBufferEntry args[7]; 190 helper_->Clear(buffers, color[0], color[1], color[2], color[3],
191 args[0].value_uint32 = buffers; 191 depth, stencil);
192 args[1].value_float = color[0];
193 args[2].value_float = color[1];
194 args[3].value_float = color[2];
195 args[4].value_float = color[3];
196 args[5].value_float = depth;
197 args[6].value_uint32 = stencil;
198 helper_->AddCommand(command_buffer::CLEAR, 7, args);
199 } 192 }
200 193
201 void RendererCB::PlatformSpecificEndDraw() { 194 void RendererCB::PlatformSpecificEndDraw() {
202 } 195 }
203 196
204 // Adds the BEGIN_FRAME command to the command buffer. 197 // Adds the BeginFrame command to the command buffer.
205 bool RendererCB::PlatformSpecificStartRendering() { 198 bool RendererCB::PlatformSpecificStartRendering() {
206 // Any device issues are handled in the command buffer backend 199 // Any device issues are handled in the command buffer backend
207 DCHECK(helper_); 200 DCHECK(helper_);
208 helper_->AddCommand(command_buffer::BEGIN_FRAME, 0 , NULL); 201 helper_->BeginFrame();
209 return true; 202 return true;
210 } 203 }
211 204
212 // Adds the END_FRAME command to the command buffer, and flushes the commands. 205 // Adds the EndFrame command to the command buffer, and flushes the commands.
213 void RendererCB::PlatformSpecificFinishRendering() { 206 void RendererCB::PlatformSpecificFinishRendering() {
214 // Any device issues are handled in the command buffer backend 207 // Any device issues are handled in the command buffer backend
215 helper_->AddCommand(command_buffer::END_FRAME, 0 , NULL); 208 helper_->EndFrame();
216 helper_->WaitForToken(frame_token_); 209 helper_->WaitForToken(frame_token_);
217 frame_token_ = helper_->InsertToken(); 210 frame_token_ = helper_->InsertToken();
218 } 211 }
219 212
220 void RendererCB::PlatformSpecificPresent() { 213 void RendererCB::PlatformSpecificPresent() {
221 // TODO(gman): The END_FRAME command needs to be split into END_FRAME 214 // TODO(gman): The EndFrame command needs to be split into EndFrame
222 // and PRESENT. 215 // and PRESENT.
223 } 216 }
224 217
225 // Assign the surface arguments to the renderer, and update the stack 218 // Assign the surface arguments to the renderer, and update the stack
226 // of pushed surfaces. 219 // of pushed surfaces.
227 void RendererCB::SetRenderSurfacesPlatformSpecific( 220 void RendererCB::SetRenderSurfacesPlatformSpecific(
228 const RenderSurface* surface, 221 const RenderSurface* surface,
229 const RenderDepthStencilSurface* surface_depth) { 222 const RenderDepthStencilSurface* surface_depth) {
230 const RenderSurfaceCB* surface_cb = 223 const RenderSurfaceCB* surface_cb =
231 down_cast<const RenderSurfaceCB*>(surface); 224 down_cast<const RenderSurfaceCB*>(surface);
232 const RenderDepthStencilSurfaceCB* surface_depth_cb = 225 const RenderDepthStencilSurfaceCB* surface_depth_cb =
233 down_cast<const RenderDepthStencilSurfaceCB*>(surface_depth); 226 down_cast<const RenderDepthStencilSurfaceCB*>(surface_depth);
234 command_buffer::CommandBufferEntry args[2]; 227 helper_->SetRenderSurface(
235 args[0].value_uint32 = surface_cb->resource_id(); 228 surface_cb->resource_id(),
236 args[1].value_uint32 = surface_depth_cb->resource_id(); 229 surface_depth_cb->resource_id());
237 helper_->AddCommand(command_buffer::SET_RENDER_SURFACE, 2, args);
238 } 230 }
239 231
240 void RendererCB::SetBackBufferPlatformSpecific() { 232 void RendererCB::SetBackBufferPlatformSpecific() {
241 helper_->AddCommand(command_buffer::SET_BACK_SURFACES, 0, NULL); 233 helper_->SetBackSurfaces();
242 } 234 }
243 235
244 // Creates a StreamBank, returning a platform specific implementation class. 236 // Creates a StreamBank, returning a platform specific implementation class.
245 StreamBank::Ref RendererCB::CreateStreamBank() { 237 StreamBank::Ref RendererCB::CreateStreamBank() {
246 return StreamBank::Ref(new StreamBankCB(service_locator(), this)); 238 return StreamBank::Ref(new StreamBankCB(service_locator(), this));
247 } 239 }
248 240
249 // Creates a Primitive, returning a platform specific implementation class. 241 // Creates a Primitive, returning a platform specific implementation class.
250 Primitive::Ref RendererCB::CreatePrimitive() { 242 Primitive::Ref RendererCB::CreatePrimitive() {
251 return Primitive::Ref(new PrimitiveCB(service_locator(), this)); 243 return Primitive::Ref(new PrimitiveCB(service_locator(), this));
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 ParamCache* RendererCB::CreatePlatformSpecificParamCache() { 299 ParamCache* RendererCB::CreatePlatformSpecificParamCache() {
308 return new ParamCacheCB(); 300 return new ParamCacheCB();
309 } 301 }
310 302
311 void RendererCB::SetViewportInPixels(int left, 303 void RendererCB::SetViewportInPixels(int left,
312 int top, 304 int top,
313 int width, 305 int width,
314 int height, 306 int height,
315 float min_z, 307 float min_z,
316 float max_z) { 308 float max_z) {
317 command_buffer::CommandBufferEntry args[6]; 309 helper_->SetViewport(left, top, width, height, min_z, max_z);
318 args[0].value_uint32 = left;
319 args[1].value_uint32 = top;
320 args[2].value_uint32 = width;
321 args[3].value_uint32 = height;
322 args[4].value_float = min_z;
323 args[5].value_float = max_z;
324 helper_->AddCommand(command_buffer::SET_VIEWPORT, 6, args);
325 } 310 }
326 311
327 const int* RendererCB::GetRGBAUByteNSwizzleTable() { 312 const int* RendererCB::GetRGBAUByteNSwizzleTable() {
328 static int swizzle_table[] = { 0, 1, 2, 3, }; 313 static int swizzle_table[] = { 0, 1, 2, 3, };
329 return swizzle_table; 314 return swizzle_table;
330 } 315 }
331 316
332 // This is a factory function for creating Renderer objects. Since 317 // This is a factory function for creating Renderer objects. Since
333 // we're implementing command buffers, we only ever return a CB renderer. 318 // we're implementing command buffers, we only ever return a CB renderer.
334 Renderer* Renderer::CreateDefaultRenderer(ServiceLocator* service_locator) { 319 Renderer* Renderer::CreateDefaultRenderer(ServiceLocator* service_locator) {
335 return RendererCB::CreateDefault(service_locator); 320 return RendererCB::CreateDefault(service_locator);
336 } 321 }
337 322
338 // Creates and returns a platform specific RenderDepthStencilSurface object. 323 // Creates and returns a platform specific RenderDepthStencilSurface object.
339 RenderDepthStencilSurface::Ref RendererCB::CreateDepthStencilSurface( 324 RenderDepthStencilSurface::Ref RendererCB::CreateDepthStencilSurface(
340 int width, 325 int width,
341 int height) { 326 int height) {
342 return RenderDepthStencilSurface::Ref( 327 return RenderDepthStencilSurface::Ref(
343 new RenderDepthStencilSurfaceCB(service_locator(), 328 new RenderDepthStencilSurfaceCB(service_locator(),
344 width, 329 width,
345 height, 330 height,
346 this)); 331 this));
347 } 332 }
348 } // namespace o3d 333 } // namespace o3d
OLDNEW
« no previous file with comments | « core/cross/command_buffer/render_surface_cb.cc ('k') | core/cross/command_buffer/sampler_cb.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698