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

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

Issue 7553018: Resolve to temporary texture when doing readpixels (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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 | « no previous file | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <list> 10 #include <list>
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 ScopedFrameBufferBinder(GLES2DecoderImpl* decoder, GLuint id); 212 ScopedFrameBufferBinder(GLES2DecoderImpl* decoder, GLuint id);
213 ~ScopedFrameBufferBinder(); 213 ~ScopedFrameBufferBinder();
214 214
215 private: 215 private:
216 GLES2DecoderImpl* decoder_; 216 GLES2DecoderImpl* decoder_;
217 DISALLOW_COPY_AND_ASSIGN(ScopedFrameBufferBinder); 217 DISALLOW_COPY_AND_ASSIGN(ScopedFrameBufferBinder);
218 }; 218 };
219 219
220 // Temporarily changes a decoder's bound frame buffer to a resolved version of 220 // Temporarily changes a decoder's bound frame buffer to a resolved version of
221 // the multisampled offscreen render buffer if that buffer is multisampled, and, 221 // the multisampled offscreen render buffer if that buffer is multisampled, and,
222 // if it is bound or enforce_internal_framebuffer is true. 222 // if it is bound or enforce_internal_framebuffer is true. If internal is
223 // true, the resolved framebuffer is not visible to the parent.
223 class ScopedResolvedFrameBufferBinder { 224 class ScopedResolvedFrameBufferBinder {
224 public: 225 public:
225 ScopedResolvedFrameBufferBinder(GLES2DecoderImpl* decoder, 226 ScopedResolvedFrameBufferBinder(GLES2DecoderImpl* decoder,
226 bool enforce_internal_framebuffer); 227 bool enforce_internal_framebuffer,
228 bool internal);
227 ~ScopedResolvedFrameBufferBinder(); 229 ~ScopedResolvedFrameBufferBinder();
228 230
229 private: 231 private:
230 GLES2DecoderImpl* decoder_; 232 GLES2DecoderImpl* decoder_;
231 bool resolve_and_bind_; 233 bool resolve_and_bind_;
232 DISALLOW_COPY_AND_ASSIGN(ScopedResolvedFrameBufferBinder); 234 DISALLOW_COPY_AND_ASSIGN(ScopedResolvedFrameBufferBinder);
233 }; 235 };
234 236
235 // Encapsulates an OpenGL texture. 237 // Encapsulates an OpenGL texture.
236 class Texture { 238 class Texture {
(...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 scoped_ptr<RenderBuffer> offscreen_target_color_render_buffer_; 1280 scoped_ptr<RenderBuffer> offscreen_target_color_render_buffer_;
1279 scoped_ptr<RenderBuffer> offscreen_target_depth_render_buffer_; 1281 scoped_ptr<RenderBuffer> offscreen_target_depth_render_buffer_;
1280 scoped_ptr<RenderBuffer> offscreen_target_stencil_render_buffer_; 1282 scoped_ptr<RenderBuffer> offscreen_target_stencil_render_buffer_;
1281 GLenum offscreen_target_color_format_; 1283 GLenum offscreen_target_color_format_;
1282 GLenum offscreen_target_depth_format_; 1284 GLenum offscreen_target_depth_format_;
1283 GLenum offscreen_target_stencil_format_; 1285 GLenum offscreen_target_stencil_format_;
1284 GLsizei offscreen_target_samples_; 1286 GLsizei offscreen_target_samples_;
1285 1287
1286 GLuint copy_texture_to_parent_texture_fb_; 1288 GLuint copy_texture_to_parent_texture_fb_;
1287 1289
1288 // The copy that is saved when SwapBuffers is called. It is also 1290 // The copy that is saved when SwapBuffers is called.
1289 // used as the destination for multi-sample resolves.
1290 scoped_ptr<FrameBuffer> offscreen_saved_frame_buffer_; 1291 scoped_ptr<FrameBuffer> offscreen_saved_frame_buffer_;
1291 scoped_ptr<Texture> offscreen_saved_color_texture_; 1292 scoped_ptr<Texture> offscreen_saved_color_texture_;
1293
1294 // The copy that is used as the destination for multi-sample resolves.
1295 scoped_ptr<FrameBuffer> offscreen_resolved_frame_buffer_;
1296 scoped_ptr<Texture> offscreen_resolved_color_texture_;
1292 GLenum offscreen_saved_color_format_; 1297 GLenum offscreen_saved_color_format_;
1293 1298
1294 scoped_ptr<Callback1<gfx::Size>::Type> resize_callback_; 1299 scoped_ptr<Callback1<gfx::Size>::Type> resize_callback_;
1295 scoped_ptr<Callback0::Type> swap_buffers_callback_; 1300 scoped_ptr<Callback0::Type> swap_buffers_callback_;
1296 1301
1297 // The format of the back buffer_ 1302 // The format of the back buffer_
1298 GLenum back_buffer_color_format_; 1303 GLenum back_buffer_color_format_;
1299 bool back_buffer_has_depth_; 1304 bool back_buffer_has_depth_;
1300 bool back_buffer_has_stencil_; 1305 bool back_buffer_has_stencil_;
1301 1306
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 ScopedGLErrorSuppressor suppressor(decoder_); 1378 ScopedGLErrorSuppressor suppressor(decoder_);
1374 glBindFramebufferEXT(GL_FRAMEBUFFER, id); 1379 glBindFramebufferEXT(GL_FRAMEBUFFER, id);
1375 } 1380 }
1376 1381
1377 ScopedFrameBufferBinder::~ScopedFrameBufferBinder() { 1382 ScopedFrameBufferBinder::~ScopedFrameBufferBinder() {
1378 ScopedGLErrorSuppressor suppressor(decoder_); 1383 ScopedGLErrorSuppressor suppressor(decoder_);
1379 decoder_->RestoreCurrentFramebufferBindings(); 1384 decoder_->RestoreCurrentFramebufferBindings();
1380 } 1385 }
1381 1386
1382 ScopedResolvedFrameBufferBinder::ScopedResolvedFrameBufferBinder( 1387 ScopedResolvedFrameBufferBinder::ScopedResolvedFrameBufferBinder(
1383 GLES2DecoderImpl* decoder, bool enforce_internal_framebuffer) 1388 GLES2DecoderImpl* decoder, bool enforce_internal_framebuffer, bool internal)
1384 : decoder_(decoder) { 1389 : decoder_(decoder) {
1385 resolve_and_bind_ = (decoder_->offscreen_target_frame_buffer_.get() && 1390 resolve_and_bind_ = (decoder_->offscreen_target_frame_buffer_.get() &&
1386 decoder_->IsOffscreenBufferMultisampled() && 1391 decoder_->IsOffscreenBufferMultisampled() &&
1387 (!decoder_->bound_read_framebuffer_.get() || 1392 (!decoder_->bound_read_framebuffer_.get() ||
1388 enforce_internal_framebuffer)); 1393 enforce_internal_framebuffer));
1389 if (!resolve_and_bind_) 1394 if (!resolve_and_bind_)
1390 return; 1395 return;
1391 1396
1392 ScopedGLErrorSuppressor suppressor(decoder_); 1397 ScopedGLErrorSuppressor suppressor(decoder_);
1393 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 1398 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT,
1394 decoder_->offscreen_target_frame_buffer_->id()); 1399 decoder_->offscreen_target_frame_buffer_->id());
1395 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 1400 GLuint targetid;
1396 decoder_->offscreen_saved_frame_buffer_->id()); 1401 if (internal) {
1402 if (!decoder_->offscreen_resolved_frame_buffer_.get()) {
1403 decoder_->offscreen_resolved_frame_buffer_.reset(
1404 new FrameBuffer(decoder_));
1405 decoder_->offscreen_resolved_frame_buffer_->Create();
1406 decoder_->offscreen_resolved_color_texture_.reset(new Texture(decoder_));
1407 decoder_->offscreen_resolved_color_texture_->Create();
1408
1409 DCHECK(decoder_->offscreen_saved_color_format_);
1410 decoder_->offscreen_resolved_color_texture_->AllocateStorage(
1411 decoder_->offscreen_size_, decoder_->offscreen_saved_color_format_);
1412
1413 decoder_->offscreen_resolved_frame_buffer_->AttachRenderTexture(
1414 decoder_->offscreen_resolved_color_texture_.get());
1415 if (decoder_->offscreen_resolved_frame_buffer_->CheckStatus() !=
1416 GL_FRAMEBUFFER_COMPLETE) {
1417 LOG(ERROR) << "ScopedResolvedFrameBufferBinder failed "
1418 << "because offscreen resolved FBO was incomplete.";
1419 return;
1420 }
1421 }
1422 targetid = decoder_->offscreen_resolved_frame_buffer_->id();
1423 } else {
1424 targetid = decoder_->offscreen_saved_frame_buffer_->id();
1425 }
1426 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, targetid);
1397 const int width = decoder_->offscreen_size_.width(); 1427 const int width = decoder_->offscreen_size_.width();
1398 const int height = decoder_->offscreen_size_.height(); 1428 const int height = decoder_->offscreen_size_.height();
1399 glDisable(GL_SCISSOR_TEST); 1429 glDisable(GL_SCISSOR_TEST);
1400 if (IsAngle()) { 1430 if (IsAngle()) {
1401 glBlitFramebufferANGLE(0, 0, width, height, 0, 0, width, height, 1431 glBlitFramebufferANGLE(0, 0, width, height, 0, 0, width, height,
1402 GL_COLOR_BUFFER_BIT, GL_NEAREST); 1432 GL_COLOR_BUFFER_BIT, GL_NEAREST);
1403 } else { 1433 } else {
1404 glBlitFramebufferEXT(0, 0, width, height, 0, 0, width, height, 1434 glBlitFramebufferEXT(0, 0, width, height, 0, 0, width, height,
1405 GL_COLOR_BUFFER_BIT, GL_NEAREST); 1435 GL_COLOR_BUFFER_BIT, GL_NEAREST);
1406 } 1436 }
1407 glBindFramebufferEXT(GL_FRAMEBUFFER, 1437 glBindFramebufferEXT(GL_FRAMEBUFFER, targetid);
1408 decoder_->offscreen_saved_frame_buffer_->id());
1409 } 1438 }
1410 1439
1411 ScopedResolvedFrameBufferBinder::~ScopedResolvedFrameBufferBinder() { 1440 ScopedResolvedFrameBufferBinder::~ScopedResolvedFrameBufferBinder() {
1412 if (!resolve_and_bind_) 1441 if (!resolve_and_bind_)
1413 return; 1442 return;
1414 1443
1415 ScopedGLErrorSuppressor suppressor(decoder_); 1444 ScopedGLErrorSuppressor suppressor(decoder_);
1416 decoder_->RestoreCurrentFramebufferBindings(); 1445 decoder_->RestoreCurrentFramebufferBindings();
1417 if (decoder_->enable_scissor_test_) { 1446 if (decoder_->enable_scissor_test_) {
1418 glEnable(GL_SCISSOR_TEST); 1447 glEnable(GL_SCISSOR_TEST);
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after
2308 2337
2309 offscreen_saved_frame_buffer_->AttachRenderTexture( 2338 offscreen_saved_frame_buffer_->AttachRenderTexture(
2310 offscreen_saved_color_texture_.get()); 2339 offscreen_saved_color_texture_.get());
2311 if (offscreen_saved_frame_buffer_->CheckStatus() != 2340 if (offscreen_saved_frame_buffer_->CheckStatus() !=
2312 GL_FRAMEBUFFER_COMPLETE) { 2341 GL_FRAMEBUFFER_COMPLETE) {
2313 LOG(ERROR) << "GLES2DecoderImpl::UpdateOffscreenFrameBufferSize failed " 2342 LOG(ERROR) << "GLES2DecoderImpl::UpdateOffscreenFrameBufferSize failed "
2314 << "because offscreen saved FBO was incomplete."; 2343 << "because offscreen saved FBO was incomplete.";
2315 return false; 2344 return false;
2316 } 2345 }
2317 2346
2347 // Destroy the offscreen resolved framebuffers.
2348 if (offscreen_resolved_frame_buffer_.get())
2349 offscreen_resolved_frame_buffer_->Destroy();
2350 if (offscreen_resolved_color_texture_.get())
2351 offscreen_resolved_color_texture_->Destroy();
2352 offscreen_resolved_color_texture_.reset();
2353 offscreen_resolved_frame_buffer_.reset();
2354
2318 // Clear the offscreen color texture. 2355 // Clear the offscreen color texture.
2319 { 2356 {
2320 ScopedFrameBufferBinder binder(this, offscreen_saved_frame_buffer_->id()); 2357 ScopedFrameBufferBinder binder(this, offscreen_saved_frame_buffer_->id());
2321 glClearColor(0, 0, 0, 0); 2358 glClearColor(0, 0, 0, 0);
2322 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 2359 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
2323 glDisable(GL_SCISSOR_TEST); 2360 glDisable(GL_SCISSOR_TEST);
2324 glClear(GL_COLOR_BUFFER_BIT); 2361 glClear(GL_COLOR_BUFFER_BIT);
2325 RestoreClearState(); 2362 RestoreClearState();
2326 } 2363 }
2327 2364
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
2427 if (offscreen_target_color_render_buffer_.get()) 2464 if (offscreen_target_color_render_buffer_.get())
2428 offscreen_target_color_render_buffer_->Destroy(); 2465 offscreen_target_color_render_buffer_->Destroy();
2429 if (offscreen_target_depth_render_buffer_.get()) 2466 if (offscreen_target_depth_render_buffer_.get())
2430 offscreen_target_depth_render_buffer_->Destroy(); 2467 offscreen_target_depth_render_buffer_->Destroy();
2431 if (offscreen_target_stencil_render_buffer_.get()) 2468 if (offscreen_target_stencil_render_buffer_.get())
2432 offscreen_target_stencil_render_buffer_->Destroy(); 2469 offscreen_target_stencil_render_buffer_->Destroy();
2433 if (offscreen_saved_frame_buffer_.get()) 2470 if (offscreen_saved_frame_buffer_.get())
2434 offscreen_saved_frame_buffer_->Destroy(); 2471 offscreen_saved_frame_buffer_->Destroy();
2435 if (offscreen_saved_color_texture_.get()) 2472 if (offscreen_saved_color_texture_.get())
2436 offscreen_saved_color_texture_->Destroy(); 2473 offscreen_saved_color_texture_->Destroy();
2474 if (offscreen_resolved_frame_buffer_.get())
2475 offscreen_resolved_frame_buffer_->Destroy();
2476 if (offscreen_resolved_color_texture_.get())
2477 offscreen_resolved_color_texture_->Destroy();
2437 2478
2438 // must release the ContextGroup before destroying the context as its 2479 // must release the ContextGroup before destroying the context as its
2439 // destructor uses GL. 2480 // destructor uses GL.
2440 group_ = NULL; 2481 group_ = NULL;
2441 } else { 2482 } else {
2442 if (offscreen_target_frame_buffer_.get()) 2483 if (offscreen_target_frame_buffer_.get())
2443 offscreen_target_frame_buffer_->Invalidate(); 2484 offscreen_target_frame_buffer_->Invalidate();
2444 if (offscreen_target_color_texture_.get()) 2485 if (offscreen_target_color_texture_.get())
2445 offscreen_target_color_texture_->Invalidate(); 2486 offscreen_target_color_texture_->Invalidate();
2446 if (offscreen_target_color_render_buffer_.get()) 2487 if (offscreen_target_color_render_buffer_.get())
2447 offscreen_target_color_render_buffer_->Invalidate(); 2488 offscreen_target_color_render_buffer_->Invalidate();
2448 if (offscreen_target_depth_render_buffer_.get()) 2489 if (offscreen_target_depth_render_buffer_.get())
2449 offscreen_target_depth_render_buffer_->Invalidate(); 2490 offscreen_target_depth_render_buffer_->Invalidate();
2450 if (offscreen_target_stencil_render_buffer_.get()) 2491 if (offscreen_target_stencil_render_buffer_.get())
2451 offscreen_target_stencil_render_buffer_->Invalidate(); 2492 offscreen_target_stencil_render_buffer_->Invalidate();
2452 if (offscreen_saved_frame_buffer_.get()) 2493 if (offscreen_saved_frame_buffer_.get())
2453 offscreen_saved_frame_buffer_->Invalidate(); 2494 offscreen_saved_frame_buffer_->Invalidate();
2454 if (offscreen_saved_color_texture_.get()) 2495 if (offscreen_saved_color_texture_.get())
2455 offscreen_saved_color_texture_->Invalidate(); 2496 offscreen_saved_color_texture_->Invalidate();
2497 if (offscreen_resolved_frame_buffer_.get())
2498 offscreen_resolved_frame_buffer_->Invalidate();
2499 if (offscreen_resolved_color_texture_.get())
2500 offscreen_resolved_color_texture_->Invalidate();
2456 } 2501 }
2457 2502
2458 if (context_.get()) { 2503 if (context_.get()) {
2459 context_->ReleaseCurrent(NULL); 2504 context_->ReleaseCurrent(NULL);
2460 context_->Destroy(); 2505 context_->Destroy();
2461 } 2506 }
2462 context_ = NULL; 2507 context_ = NULL;
2463 2508
2464 offscreen_target_frame_buffer_.reset(); 2509 offscreen_target_frame_buffer_.reset();
2465 offscreen_target_color_texture_.reset(); 2510 offscreen_target_color_texture_.reset();
2466 offscreen_target_color_render_buffer_.reset(); 2511 offscreen_target_color_render_buffer_.reset();
2467 offscreen_target_depth_render_buffer_.reset(); 2512 offscreen_target_depth_render_buffer_.reset();
2468 offscreen_target_stencil_render_buffer_.reset(); 2513 offscreen_target_stencil_render_buffer_.reset();
2469 offscreen_saved_frame_buffer_.reset(); 2514 offscreen_saved_frame_buffer_.reset();
2470 offscreen_saved_color_texture_.reset(); 2515 offscreen_saved_color_texture_.reset();
2516 offscreen_resolved_frame_buffer_.reset();
2517 offscreen_resolved_color_texture_.reset();
2471 } 2518 }
2472 2519
2473 bool GLES2DecoderImpl::SetParent(GLES2Decoder* new_parent, 2520 bool GLES2DecoderImpl::SetParent(GLES2Decoder* new_parent,
2474 uint32 new_parent_texture_id) { 2521 uint32 new_parent_texture_id) {
2475 if (!offscreen_saved_color_texture_.get()) 2522 if (!offscreen_saved_color_texture_.get())
2476 return false; 2523 return false;
2477 2524
2478 // Remove the saved frame buffer mapping from the parent decoder. The 2525 // Remove the saved frame buffer mapping from the parent decoder. The
2479 // parent pointer is a weak pointer so it will be null if the parent has 2526 // parent pointer is a weak pointer so it will be null if the parent has
2480 // already been destroyed. 2527 // already been destroyed.
(...skipping 2627 matching lines...) Expand 10 before | Expand all | Expand 10 after
5108 if (!validators_->pixel_type.IsValid(type)) { 5155 if (!validators_->pixel_type.IsValid(type)) {
5109 SetGLError(GL_INVALID_ENUM, "glReadPixels: type GL_INVALID_ENUM"); 5156 SetGLError(GL_INVALID_ENUM, "glReadPixels: type GL_INVALID_ENUM");
5110 return error::kNoError; 5157 return error::kNoError;
5111 } 5158 }
5112 if (width == 0 || height == 0) { 5159 if (width == 0 || height == 0) {
5113 return error::kNoError; 5160 return error::kNoError;
5114 } 5161 }
5115 5162
5116 CopyRealGLErrorsToWrapper(); 5163 CopyRealGLErrorsToWrapper();
5117 5164
5118 ScopedResolvedFrameBufferBinder binder(this, false); 5165 ScopedResolvedFrameBufferBinder binder(this, false, true);
5119 5166
5120 // Get the size of the current fbo or backbuffer. 5167 // Get the size of the current fbo or backbuffer.
5121 gfx::Size max_size = GetBoundReadFrameBufferSize(); 5168 gfx::Size max_size = GetBoundReadFrameBufferSize();
5122 5169
5123 GLint max_x; 5170 GLint max_x;
5124 GLint max_y; 5171 GLint max_y;
5125 if (!SafeAdd(x, width, &max_x) || !SafeAdd(y, height, &max_y)) { 5172 if (!SafeAdd(x, width, &max_x) || !SafeAdd(y, height, &max_y)) {
5126 SetGLError(GL_INVALID_VALUE, "glReadPixels: dimensions out of range"); 5173 SetGLError(GL_INVALID_VALUE, "glReadPixels: dimensions out of range");
5127 return error::kNoError; 5174 return error::kNoError;
5128 } 5175 }
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
5895 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); 5942 GLenum read_format = GetBoundReadFrameBufferInternalFormat();
5896 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format); 5943 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format);
5897 uint32 channels_needed = GLES2Util::GetChannelsForFormat(internal_format); 5944 uint32 channels_needed = GLES2Util::GetChannelsForFormat(internal_format);
5898 5945
5899 if ((channels_needed & channels_exist) != channels_needed) { 5946 if ((channels_needed & channels_exist) != channels_needed) {
5900 SetGLError(GL_INVALID_OPERATION, "glCopyTexImage2D: incompatible format"); 5947 SetGLError(GL_INVALID_OPERATION, "glCopyTexImage2D: incompatible format");
5901 return; 5948 return;
5902 } 5949 }
5903 5950
5904 CopyRealGLErrorsToWrapper(); 5951 CopyRealGLErrorsToWrapper();
5905 ScopedResolvedFrameBufferBinder binder(this, false); 5952 ScopedResolvedFrameBufferBinder binder(this, false, true);
5906 gfx::Size size = GetBoundReadFrameBufferSize(); 5953 gfx::Size size = GetBoundReadFrameBufferSize();
5907 5954
5908 if (info->IsAttachedToFramebuffer()) { 5955 if (info->IsAttachedToFramebuffer()) {
5909 state_dirty_ = true; 5956 state_dirty_ = true;
5910 } 5957 }
5911 5958
5912 // Clip to size to source dimensions 5959 // Clip to size to source dimensions
5913 GLint copyX = 0; 5960 GLint copyX = 0;
5914 GLint copyY = 0; 5961 GLint copyY = 0;
5915 GLint copyWidth = 0; 5962 GLint copyWidth = 0;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
5983 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); 6030 GLenum read_format = GetBoundReadFrameBufferInternalFormat();
5984 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format); 6031 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format);
5985 uint32 channels_needed = GLES2Util::GetChannelsForFormat(format); 6032 uint32 channels_needed = GLES2Util::GetChannelsForFormat(format);
5986 6033
5987 if ((channels_needed & channels_exist) != channels_needed) { 6034 if ((channels_needed & channels_exist) != channels_needed) {
5988 SetGLError( 6035 SetGLError(
5989 GL_INVALID_OPERATION, "glCopyTexSubImage2D: incompatible format"); 6036 GL_INVALID_OPERATION, "glCopyTexSubImage2D: incompatible format");
5990 return; 6037 return;
5991 } 6038 }
5992 6039
5993 ScopedResolvedFrameBufferBinder binder(this, false); 6040 ScopedResolvedFrameBufferBinder binder(this, false, true);
5994 gfx::Size size = GetBoundReadFrameBufferSize(); 6041 gfx::Size size = GetBoundReadFrameBufferSize();
5995 GLint copyX = 0; 6042 GLint copyX = 0;
5996 GLint copyY = 0; 6043 GLint copyY = 0;
5997 GLint copyWidth = 0; 6044 GLint copyWidth = 0;
5998 GLint copyHeight = 0; 6045 GLint copyHeight = 0;
5999 Clip(x, width, size.width(), &copyX, &copyWidth); 6046 Clip(x, width, size.width(), &copyX, &copyWidth);
6000 Clip(y, height, size.height(), &copyY, &copyHeight); 6047 Clip(y, height, size.height(), &copyY, &copyHeight);
6001 if (copyX != x || 6048 if (copyX != x ||
6002 copyY != y || 6049 copyY != y ||
6003 copyWidth != width || 6050 copyWidth != width ||
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
6526 // pending. 6573 // pending.
6527 if (!UpdateOffscreenFrameBufferSize()) { 6574 if (!UpdateOffscreenFrameBufferSize()) {
6528 LOG(ERROR) << "Context lost because reallocation of offscreen FBO " 6575 LOG(ERROR) << "Context lost because reallocation of offscreen FBO "
6529 << "failed."; 6576 << "failed.";
6530 return error::kLostContext; 6577 return error::kLostContext;
6531 } 6578 }
6532 6579
6533 if (IsOffscreenBufferMultisampled()) { 6580 if (IsOffscreenBufferMultisampled()) {
6534 // For multisampled buffers, bind the resolved frame buffer so that 6581 // For multisampled buffers, bind the resolved frame buffer so that
6535 // callbacks can call ReadPixels or CopyTexImage2D. 6582 // callbacks can call ReadPixels or CopyTexImage2D.
6536 ScopedResolvedFrameBufferBinder binder(this, true); 6583 ScopedResolvedFrameBufferBinder binder(this, true, false);
6537 if (swap_buffers_callback_.get()) { 6584 if (swap_buffers_callback_.get()) {
6538 swap_buffers_callback_->Run(); 6585 swap_buffers_callback_->Run();
6539 } 6586 }
6540 return error::kNoError; 6587 return error::kNoError;
6541 } else { 6588 } else {
6542 ScopedFrameBufferBinder binder(this, 6589 ScopedFrameBufferBinder binder(this,
6543 offscreen_target_frame_buffer_->id()); 6590 offscreen_target_frame_buffer_->id());
6544 6591
6545 if (surface_->IsOffscreen()) { 6592 if (surface_->IsOffscreen()) {
6546 // Copy the target frame buffer to the saved offscreen texture. 6593 // Copy the target frame buffer to the saved offscreen texture.
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
6792 return false; 6839 return false;
6793 } 6840 }
6794 6841
6795 // Include the auto-generated part of this file. We split this because it means 6842 // Include the auto-generated part of this file. We split this because it means
6796 // we can easily edit the non-auto generated parts right here in this file 6843 // we can easily edit the non-auto generated parts right here in this file
6797 // instead of having to edit some template or the code generator. 6844 // instead of having to edit some template or the code generator.
6798 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 6845 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
6799 6846
6800 } // namespace gles2 6847 } // namespace gles2
6801 } // namespace gpu 6848 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698