| OLD | NEW |
| 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 // A class to emulate GLES2 over command buffers. | 5 // A class to emulate GLES2 over command buffers. |
| 6 | 6 |
| 7 #include "gpu/command_buffer/client/gles2_implementation.h" | 7 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 8 | 8 |
| 9 #include <GLES2/gl2.h> | 9 #include <GLES2/gl2.h> |
| 10 #include <GLES2/gl2ext.h> | 10 #include <GLES2/gl2ext.h> |
| (...skipping 2405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2416 params.image_height = unpack_image_height_; | 2416 params.image_height = unpack_image_height_; |
| 2417 params.skip_images = unpack_skip_images_; | 2417 params.skip_images = unpack_skip_images_; |
| 2418 } | 2418 } |
| 2419 return params; | 2419 return params; |
| 2420 } | 2420 } |
| 2421 | 2421 |
| 2422 void GLES2Implementation::TexImage2D( | 2422 void GLES2Implementation::TexImage2D( |
| 2423 GLenum target, GLint level, GLint internalformat, GLsizei width, | 2423 GLenum target, GLint level, GLint internalformat, GLsizei width, |
| 2424 GLsizei height, GLint border, GLenum format, GLenum type, | 2424 GLsizei height, GLint border, GLenum format, GLenum type, |
| 2425 const void* pixels) { | 2425 const void* pixels) { |
| 2426 const char* func_name = "glTexImage2D"; |
| 2426 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 2427 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 2427 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glTexImage2D(" | 2428 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glTexImage2D(" |
| 2428 << GLES2Util::GetStringTextureTarget(target) << ", " | 2429 << GLES2Util::GetStringTextureTarget(target) << ", " |
| 2429 << level << ", " | 2430 << level << ", " |
| 2430 << GLES2Util::GetStringTextureInternalFormat(internalformat) << ", " | 2431 << GLES2Util::GetStringTextureInternalFormat(internalformat) << ", " |
| 2431 << width << ", " << height << ", " << border << ", " | 2432 << width << ", " << height << ", " << border << ", " |
| 2432 << GLES2Util::GetStringTextureFormat(format) << ", " | 2433 << GLES2Util::GetStringTextureFormat(format) << ", " |
| 2433 << GLES2Util::GetStringPixelType(type) << ", " | 2434 << GLES2Util::GetStringPixelType(type) << ", " |
| 2434 << static_cast<const void*>(pixels) << ")"); | 2435 << static_cast<const void*>(pixels) << ")"); |
| 2435 if (level < 0 || height < 0 || width < 0) { | 2436 if (level < 0 || height < 0 || width < 0) { |
| 2436 SetGLError(GL_INVALID_VALUE, "glTexImage2D", "dimension < 0"); | 2437 SetGLError(GL_INVALID_VALUE, func_name, "dimension < 0"); |
| 2437 return; | 2438 return; |
| 2438 } | 2439 } |
| 2439 if (border != 0) { | 2440 if (border != 0) { |
| 2440 SetGLError(GL_INVALID_VALUE, "glTexImage2D", "border != 0"); | 2441 SetGLError(GL_INVALID_VALUE, func_name, "border != 0"); |
| 2441 return; | 2442 return; |
| 2442 } | 2443 } |
| 2444 if ((bound_pixel_unpack_buffer_ || pixels) && |
| 2445 (unpack_skip_pixels_ + width > |
| 2446 (unpack_row_length_ ? unpack_row_length_ : width))) { |
| 2447 // This is WebGL 2 specific constraints, but we do it for all ES3 contexts. |
| 2448 SetGLError(GL_INVALID_OPERATION, func_name, |
| 2449 "invalid unpack params combination"); |
| 2450 return; |
| 2451 } |
| 2452 |
| 2443 uint32_t size; | 2453 uint32_t size; |
| 2444 uint32_t unpadded_row_size; | 2454 uint32_t unpadded_row_size; |
| 2445 uint32_t padded_row_size; | 2455 uint32_t padded_row_size; |
| 2446 uint32_t skip_size; | 2456 uint32_t skip_size; |
| 2447 PixelStoreParams params = GetUnpackParameters(k2D); | 2457 PixelStoreParams params = GetUnpackParameters(k2D); |
| 2448 if (!GLES2Util::ComputeImageDataSizesES3(width, height, 1, | 2458 if (!GLES2Util::ComputeImageDataSizesES3(width, height, 1, |
| 2449 format, type, | 2459 format, type, |
| 2450 params, | 2460 params, |
| 2451 &size, | 2461 &size, |
| 2452 &unpadded_row_size, | 2462 &unpadded_row_size, |
| 2453 &padded_row_size, | 2463 &padded_row_size, |
| 2454 &skip_size, | 2464 &skip_size, |
| 2455 nullptr)) { | 2465 nullptr)) { |
| 2456 SetGLError(GL_INVALID_VALUE, "glTexImage2D", "image size too large"); | 2466 SetGLError(GL_INVALID_VALUE, func_name, "image size too large"); |
| 2457 return; | 2467 return; |
| 2458 } | 2468 } |
| 2459 | 2469 |
| 2460 if (bound_pixel_unpack_buffer_) { | 2470 if (bound_pixel_unpack_buffer_) { |
| 2461 base::CheckedNumeric<uint32_t> offset = ToGLuint(pixels); | 2471 base::CheckedNumeric<uint32_t> offset = ToGLuint(pixels); |
| 2462 offset += skip_size; | 2472 offset += skip_size; |
| 2463 if (!offset.IsValid()) { | 2473 if (!offset.IsValid()) { |
| 2464 SetGLError(GL_INVALID_VALUE, "glTexImage2D", "skip size too large"); | 2474 SetGLError(GL_INVALID_VALUE, func_name, "skip size too large"); |
| 2465 return; | 2475 return; |
| 2466 } | 2476 } |
| 2467 helper_->TexImage2D( | 2477 helper_->TexImage2D( |
| 2468 target, level, internalformat, width, height, format, type, | 2478 target, level, internalformat, width, height, format, type, |
| 2469 0, offset.ValueOrDefault(0)); | 2479 0, offset.ValueOrDefault(0)); |
| 2470 CheckGLError(); | 2480 CheckGLError(); |
| 2471 return; | 2481 return; |
| 2472 } | 2482 } |
| 2473 | 2483 |
| 2474 // If there's a pixel unpack buffer bound use it when issuing TexImage2D. | 2484 // If there's a pixel unpack buffer bound use it when issuing TexImage2D. |
| 2475 if (bound_pixel_unpack_transfer_buffer_id_) { | 2485 if (bound_pixel_unpack_transfer_buffer_id_) { |
| 2476 if (unpack_row_length_ > 0 || unpack_image_height_ > 0 || | 2486 if (unpack_row_length_ > 0 || unpack_image_height_ > 0 || |
| 2477 unpack_skip_pixels_ > 0 || unpack_skip_rows_ > 0 || | 2487 unpack_skip_pixels_ > 0 || unpack_skip_rows_ > 0 || |
| 2478 unpack_skip_images_ > 0) { | 2488 unpack_skip_images_ > 0) { |
| 2479 SetGLError(GL_INVALID_OPERATION, "glTexImage2D", | 2489 SetGLError(GL_INVALID_OPERATION, func_name, |
| 2480 "No ES3 pack parameters with pixel unpack transfer buffer."); | 2490 "No ES3 pack parameters with pixel unpack transfer buffer."); |
| 2481 return; | 2491 return; |
| 2482 } | 2492 } |
| 2483 DCHECK_EQ(0u, skip_size); | 2493 DCHECK_EQ(0u, skip_size); |
| 2484 GLuint offset = ToGLuint(pixels); | 2494 GLuint offset = ToGLuint(pixels); |
| 2485 BufferTracker::Buffer* buffer = GetBoundPixelTransferBufferIfValid( | 2495 BufferTracker::Buffer* buffer = GetBoundPixelTransferBufferIfValid( |
| 2486 bound_pixel_unpack_transfer_buffer_id_, "glTexImage2D", offset, size); | 2496 bound_pixel_unpack_transfer_buffer_id_, func_name, offset, size); |
| 2487 if (buffer && buffer->shm_id() != -1) { | 2497 if (buffer && buffer->shm_id() != -1) { |
| 2488 helper_->TexImage2D( | 2498 helper_->TexImage2D( |
| 2489 target, level, internalformat, width, height, format, type, | 2499 target, level, internalformat, width, height, format, type, |
| 2490 buffer->shm_id(), buffer->shm_offset() + offset); | 2500 buffer->shm_id(), buffer->shm_offset() + offset); |
| 2491 buffer->set_last_usage_token(helper_->InsertToken()); | 2501 buffer->set_last_usage_token(helper_->InsertToken()); |
| 2492 CheckGLError(); | 2502 CheckGLError(); |
| 2493 } | 2503 } |
| 2494 return; | 2504 return; |
| 2495 } | 2505 } |
| 2496 | 2506 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2511 PixelStoreParams service_params; | 2521 PixelStoreParams service_params; |
| 2512 service_params.alignment = unpack_alignment_; | 2522 service_params.alignment = unpack_alignment_; |
| 2513 if (!GLES2Util::ComputeImageDataSizesES3(width, height, 1, | 2523 if (!GLES2Util::ComputeImageDataSizesES3(width, height, 1, |
| 2514 format, type, | 2524 format, type, |
| 2515 service_params, | 2525 service_params, |
| 2516 &size, | 2526 &size, |
| 2517 nullptr, | 2527 nullptr, |
| 2518 &service_padded_row_size, | 2528 &service_padded_row_size, |
| 2519 nullptr, | 2529 nullptr, |
| 2520 nullptr)) { | 2530 nullptr)) { |
| 2521 SetGLError(GL_INVALID_VALUE, "glTexImage2D", "image size too large"); | 2531 SetGLError(GL_INVALID_VALUE, func_name, "image size too large"); |
| 2522 return; | 2532 return; |
| 2523 } | 2533 } |
| 2524 } else { | 2534 } else { |
| 2525 service_padded_row_size = padded_row_size; | 2535 service_padded_row_size = padded_row_size; |
| 2526 } | 2536 } |
| 2527 | 2537 |
| 2528 // advance pixels pointer past the skip rows and skip pixels | 2538 // advance pixels pointer past the skip rows and skip pixels |
| 2529 pixels = reinterpret_cast<const int8_t*>(pixels) + skip_size; | 2539 pixels = reinterpret_cast<const int8_t*>(pixels) + skip_size; |
| 2530 | 2540 |
| 2531 // Check if we can send it all at once. | 2541 // Check if we can send it all at once. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2571 target, level, 0, 0, width, height, format, type, unpadded_row_size, | 2581 target, level, 0, 0, width, height, format, type, unpadded_row_size, |
| 2572 pixels, padded_row_size, GL_TRUE, &transfer_alloc, | 2582 pixels, padded_row_size, GL_TRUE, &transfer_alloc, |
| 2573 service_padded_row_size); | 2583 service_padded_row_size); |
| 2574 CheckGLError(); | 2584 CheckGLError(); |
| 2575 } | 2585 } |
| 2576 | 2586 |
| 2577 void GLES2Implementation::TexImage3D( | 2587 void GLES2Implementation::TexImage3D( |
| 2578 GLenum target, GLint level, GLint internalformat, GLsizei width, | 2588 GLenum target, GLint level, GLint internalformat, GLsizei width, |
| 2579 GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, | 2589 GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, |
| 2580 const void* pixels) { | 2590 const void* pixels) { |
| 2591 const char* func_name = "glTexImage3D"; |
| 2581 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 2592 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 2582 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glTexImage3D(" | 2593 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glTexImage3D(" |
| 2583 << GLES2Util::GetStringTextureTarget(target) << ", " | 2594 << GLES2Util::GetStringTextureTarget(target) << ", " |
| 2584 << level << ", " | 2595 << level << ", " |
| 2585 << GLES2Util::GetStringTextureInternalFormat(internalformat) << ", " | 2596 << GLES2Util::GetStringTextureInternalFormat(internalformat) << ", " |
| 2586 << width << ", " << height << ", " << depth << ", " << border << ", " | 2597 << width << ", " << height << ", " << depth << ", " << border << ", " |
| 2587 << GLES2Util::GetStringTextureFormat(format) << ", " | 2598 << GLES2Util::GetStringTextureFormat(format) << ", " |
| 2588 << GLES2Util::GetStringPixelType(type) << ", " | 2599 << GLES2Util::GetStringPixelType(type) << ", " |
| 2589 << static_cast<const void*>(pixels) << ")"); | 2600 << static_cast<const void*>(pixels) << ")"); |
| 2590 if (level < 0 || height < 0 || width < 0 || depth < 0) { | 2601 if (level < 0 || height < 0 || width < 0 || depth < 0) { |
| 2591 SetGLError(GL_INVALID_VALUE, "glTexImage3D", "dimension < 0"); | 2602 SetGLError(GL_INVALID_VALUE, func_name, "dimension < 0"); |
| 2592 return; | 2603 return; |
| 2593 } | 2604 } |
| 2594 if (border != 0) { | 2605 if (border != 0) { |
| 2595 SetGLError(GL_INVALID_VALUE, "glTexImage3D", "border != 0"); | 2606 SetGLError(GL_INVALID_VALUE, func_name, "border != 0"); |
| 2607 return; |
| 2608 } |
| 2609 if ((bound_pixel_unpack_buffer_ || pixels) && |
| 2610 ((unpack_skip_pixels_ + width > |
| 2611 (unpack_row_length_ ? unpack_row_length_ : width)) || |
| 2612 (unpack_skip_rows_ + height > |
| 2613 (unpack_image_height_ ? unpack_image_height_ : height)))) { |
| 2614 // This is WebGL 2 specific constraints, but we do it for all ES3 contexts. |
| 2615 SetGLError(GL_INVALID_OPERATION, func_name, |
| 2616 "invalid unpack params combination"); |
| 2596 return; | 2617 return; |
| 2597 } | 2618 } |
| 2598 | 2619 |
| 2599 uint32_t size; | 2620 uint32_t size; |
| 2600 uint32_t unpadded_row_size; | 2621 uint32_t unpadded_row_size; |
| 2601 uint32_t padded_row_size; | 2622 uint32_t padded_row_size; |
| 2602 uint32_t skip_size; | 2623 uint32_t skip_size; |
| 2603 PixelStoreParams params = GetUnpackParameters(k3D); | 2624 PixelStoreParams params = GetUnpackParameters(k3D); |
| 2604 if (!GLES2Util::ComputeImageDataSizesES3(width, height, depth, | 2625 if (!GLES2Util::ComputeImageDataSizesES3(width, height, depth, |
| 2605 format, type, | 2626 format, type, |
| 2606 params, | 2627 params, |
| 2607 &size, | 2628 &size, |
| 2608 &unpadded_row_size, | 2629 &unpadded_row_size, |
| 2609 &padded_row_size, | 2630 &padded_row_size, |
| 2610 &skip_size, | 2631 &skip_size, |
| 2611 nullptr)) { | 2632 nullptr)) { |
| 2612 SetGLError(GL_INVALID_VALUE, "glTexImage3D", "image size too large"); | 2633 SetGLError(GL_INVALID_VALUE, func_name, "image size too large"); |
| 2613 return; | 2634 return; |
| 2614 } | 2635 } |
| 2615 | 2636 |
| 2616 if (bound_pixel_unpack_buffer_) { | 2637 if (bound_pixel_unpack_buffer_) { |
| 2617 base::CheckedNumeric<uint32_t> offset = ToGLuint(pixels); | 2638 base::CheckedNumeric<uint32_t> offset = ToGLuint(pixels); |
| 2618 offset += skip_size; | 2639 offset += skip_size; |
| 2619 if (!offset.IsValid()) { | 2640 if (!offset.IsValid()) { |
| 2620 SetGLError(GL_INVALID_VALUE, "glTexImage3D", "skip size too large"); | 2641 SetGLError(GL_INVALID_VALUE, func_name, "skip size too large"); |
| 2621 return; | 2642 return; |
| 2622 } | 2643 } |
| 2623 helper_->TexImage3D( | 2644 helper_->TexImage3D( |
| 2624 target, level, internalformat, width, height, depth, format, type, | 2645 target, level, internalformat, width, height, depth, format, type, |
| 2625 0, offset.ValueOrDefault(0)); | 2646 0, offset.ValueOrDefault(0)); |
| 2626 CheckGLError(); | 2647 CheckGLError(); |
| 2627 return; | 2648 return; |
| 2628 } | 2649 } |
| 2629 | 2650 |
| 2630 // If there's a pixel unpack buffer bound use it when issuing TexImage3D. | 2651 // If there's a pixel unpack buffer bound use it when issuing TexImage3D. |
| 2631 if (bound_pixel_unpack_transfer_buffer_id_) { | 2652 if (bound_pixel_unpack_transfer_buffer_id_) { |
| 2632 if (unpack_row_length_ > 0 || unpack_image_height_ > 0 || | 2653 if (unpack_row_length_ > 0 || unpack_image_height_ > 0 || |
| 2633 unpack_skip_pixels_ > 0 || unpack_skip_rows_ > 0 || | 2654 unpack_skip_pixels_ > 0 || unpack_skip_rows_ > 0 || |
| 2634 unpack_skip_images_ > 0) { | 2655 unpack_skip_images_ > 0) { |
| 2635 SetGLError(GL_INVALID_OPERATION, "glTexImage3D", | 2656 SetGLError(GL_INVALID_OPERATION, func_name, |
| 2636 "No ES3 pack parameters with pixel unpack transfer buffer."); | 2657 "No ES3 pack parameters with pixel unpack transfer buffer."); |
| 2637 return; | 2658 return; |
| 2638 } | 2659 } |
| 2639 DCHECK_EQ(0u, skip_size); | 2660 DCHECK_EQ(0u, skip_size); |
| 2640 GLuint offset = ToGLuint(pixels); | 2661 GLuint offset = ToGLuint(pixels); |
| 2641 BufferTracker::Buffer* buffer = GetBoundPixelTransferBufferIfValid( | 2662 BufferTracker::Buffer* buffer = GetBoundPixelTransferBufferIfValid( |
| 2642 bound_pixel_unpack_transfer_buffer_id_, "glTexImage3D", offset, size); | 2663 bound_pixel_unpack_transfer_buffer_id_, func_name, offset, size); |
| 2643 if (buffer && buffer->shm_id() != -1) { | 2664 if (buffer && buffer->shm_id() != -1) { |
| 2644 helper_->TexImage3D( | 2665 helper_->TexImage3D( |
| 2645 target, level, internalformat, width, height, depth, format, type, | 2666 target, level, internalformat, width, height, depth, format, type, |
| 2646 buffer->shm_id(), buffer->shm_offset() + offset); | 2667 buffer->shm_id(), buffer->shm_offset() + offset); |
| 2647 buffer->set_last_usage_token(helper_->InsertToken()); | 2668 buffer->set_last_usage_token(helper_->InsertToken()); |
| 2648 CheckGLError(); | 2669 CheckGLError(); |
| 2649 } | 2670 } |
| 2650 return; | 2671 return; |
| 2651 } | 2672 } |
| 2652 | 2673 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2669 PixelStoreParams service_params; | 2690 PixelStoreParams service_params; |
| 2670 service_params.alignment = unpack_alignment_; | 2691 service_params.alignment = unpack_alignment_; |
| 2671 if (!GLES2Util::ComputeImageDataSizesES3(width, height, depth, | 2692 if (!GLES2Util::ComputeImageDataSizesES3(width, height, depth, |
| 2672 format, type, | 2693 format, type, |
| 2673 service_params, | 2694 service_params, |
| 2674 &size, | 2695 &size, |
| 2675 nullptr, | 2696 nullptr, |
| 2676 &service_padded_row_size, | 2697 &service_padded_row_size, |
| 2677 nullptr, | 2698 nullptr, |
| 2678 nullptr)) { | 2699 nullptr)) { |
| 2679 SetGLError(GL_INVALID_VALUE, "glTexImage3D", "image size too large"); | 2700 SetGLError(GL_INVALID_VALUE, func_name, "image size too large"); |
| 2680 return; | 2701 return; |
| 2681 } | 2702 } |
| 2682 } else { | 2703 } else { |
| 2683 service_padded_row_size = padded_row_size; | 2704 service_padded_row_size = padded_row_size; |
| 2684 } | 2705 } |
| 2685 uint32_t src_height = | 2706 uint32_t src_height = |
| 2686 unpack_image_height_ > 0 ? unpack_image_height_ : height; | 2707 unpack_image_height_ > 0 ? unpack_image_height_ : height; |
| 2687 | 2708 |
| 2688 // advance pixels pointer past the skip images/rows/pixels | 2709 // advance pixels pointer past the skip images/rows/pixels |
| 2689 pixels = reinterpret_cast<const int8_t*>(pixels) + skip_size; | 2710 pixels = reinterpret_cast<const int8_t*>(pixels) + skip_size; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2736 TexSubImage3DImpl( | 2757 TexSubImage3DImpl( |
| 2737 target, level, 0, 0, 0, width, height, depth, format, type, | 2758 target, level, 0, 0, 0, width, height, depth, format, type, |
| 2738 unpadded_row_size, pixels, padded_row_size, GL_TRUE, &transfer_alloc, | 2759 unpadded_row_size, pixels, padded_row_size, GL_TRUE, &transfer_alloc, |
| 2739 service_padded_row_size); | 2760 service_padded_row_size); |
| 2740 CheckGLError(); | 2761 CheckGLError(); |
| 2741 } | 2762 } |
| 2742 | 2763 |
| 2743 void GLES2Implementation::TexSubImage2D( | 2764 void GLES2Implementation::TexSubImage2D( |
| 2744 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, | 2765 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, |
| 2745 GLsizei height, GLenum format, GLenum type, const void* pixels) { | 2766 GLsizei height, GLenum format, GLenum type, const void* pixels) { |
| 2767 const char* func_name = "glTexSubImage2D"; |
| 2746 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 2768 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 2747 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glTexSubImage2D(" | 2769 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glTexSubImage2D(" |
| 2748 << GLES2Util::GetStringTextureTarget(target) << ", " | 2770 << GLES2Util::GetStringTextureTarget(target) << ", " |
| 2749 << level << ", " | 2771 << level << ", " |
| 2750 << xoffset << ", " << yoffset << ", " | 2772 << xoffset << ", " << yoffset << ", " |
| 2751 << width << ", " << height << ", " | 2773 << width << ", " << height << ", " |
| 2752 << GLES2Util::GetStringTextureFormat(format) << ", " | 2774 << GLES2Util::GetStringTextureFormat(format) << ", " |
| 2753 << GLES2Util::GetStringPixelType(type) << ", " | 2775 << GLES2Util::GetStringPixelType(type) << ", " |
| 2754 << static_cast<const void*>(pixels) << ")"); | 2776 << static_cast<const void*>(pixels) << ")"); |
| 2755 | 2777 |
| 2756 if (level < 0 || height < 0 || width < 0 || xoffset < 0 || yoffset < 0) { | 2778 if (level < 0 || height < 0 || width < 0 || xoffset < 0 || yoffset < 0) { |
| 2757 SetGLError(GL_INVALID_VALUE, "glTexSubImage2D", "dimension < 0"); | 2779 SetGLError(GL_INVALID_VALUE, func_name, "dimension < 0"); |
| 2780 return; |
| 2781 } |
| 2782 if (unpack_skip_pixels_ + width > |
| 2783 (unpack_row_length_ ? unpack_row_length_ : width)) { |
| 2784 // This is WebGL 2 specific constraints, but we do it for all ES3 contexts. |
| 2785 SetGLError(GL_INVALID_OPERATION, func_name, |
| 2786 "invalid unpack params combination"); |
| 2758 return; | 2787 return; |
| 2759 } | 2788 } |
| 2760 | 2789 |
| 2761 uint32_t size; | 2790 uint32_t size; |
| 2762 uint32_t unpadded_row_size; | 2791 uint32_t unpadded_row_size; |
| 2763 uint32_t padded_row_size; | 2792 uint32_t padded_row_size; |
| 2764 uint32_t skip_size; | 2793 uint32_t skip_size; |
| 2765 PixelStoreParams params = GetUnpackParameters(k2D); | 2794 PixelStoreParams params = GetUnpackParameters(k2D); |
| 2766 if (!GLES2Util::ComputeImageDataSizesES3(width, height, 1, | 2795 if (!GLES2Util::ComputeImageDataSizesES3(width, height, 1, |
| 2767 format, type, | 2796 format, type, |
| 2768 params, | 2797 params, |
| 2769 &size, | 2798 &size, |
| 2770 &unpadded_row_size, | 2799 &unpadded_row_size, |
| 2771 &padded_row_size, | 2800 &padded_row_size, |
| 2772 &skip_size, | 2801 &skip_size, |
| 2773 nullptr)) { | 2802 nullptr)) { |
| 2774 SetGLError(GL_INVALID_VALUE, "glTexSubImage2D", "image size to large"); | 2803 SetGLError(GL_INVALID_VALUE, func_name, "image size to large"); |
| 2775 return; | 2804 return; |
| 2776 } | 2805 } |
| 2777 | 2806 |
| 2778 if (bound_pixel_unpack_buffer_) { | 2807 if (bound_pixel_unpack_buffer_) { |
| 2779 base::CheckedNumeric<uint32_t> offset = ToGLuint(pixels); | 2808 base::CheckedNumeric<uint32_t> offset = ToGLuint(pixels); |
| 2780 offset += skip_size; | 2809 offset += skip_size; |
| 2781 if (!offset.IsValid()) { | 2810 if (!offset.IsValid()) { |
| 2782 SetGLError(GL_INVALID_VALUE, "glTexSubImage2D", "skip size too large"); | 2811 SetGLError(GL_INVALID_VALUE, func_name, "skip size too large"); |
| 2783 return; | 2812 return; |
| 2784 } | 2813 } |
| 2785 helper_->TexSubImage2D(target, level, xoffset, yoffset, width, height, | 2814 helper_->TexSubImage2D(target, level, xoffset, yoffset, width, height, |
| 2786 format, type, 0, offset.ValueOrDefault(0), false); | 2815 format, type, 0, offset.ValueOrDefault(0), false); |
| 2787 CheckGLError(); | 2816 CheckGLError(); |
| 2788 return; | 2817 return; |
| 2789 } | 2818 } |
| 2790 | 2819 |
| 2791 // If there's a pixel unpack buffer bound use it when issuing TexSubImage2D. | 2820 // If there's a pixel unpack buffer bound use it when issuing TexSubImage2D. |
| 2792 if (bound_pixel_unpack_transfer_buffer_id_) { | 2821 if (bound_pixel_unpack_transfer_buffer_id_) { |
| 2793 if (unpack_row_length_ > 0 || unpack_image_height_ > 0 || | 2822 if (unpack_row_length_ > 0 || unpack_image_height_ > 0 || |
| 2794 unpack_skip_pixels_ > 0 || unpack_skip_rows_ > 0 || | 2823 unpack_skip_pixels_ > 0 || unpack_skip_rows_ > 0 || |
| 2795 unpack_skip_images_ > 0) { | 2824 unpack_skip_images_ > 0) { |
| 2796 SetGLError(GL_INVALID_OPERATION, "glTexSubImage2D", | 2825 SetGLError(GL_INVALID_OPERATION, func_name, |
| 2797 "No ES3 pack parameters with pixel unpack transfer buffer."); | 2826 "No ES3 pack parameters with pixel unpack transfer buffer."); |
| 2798 return; | 2827 return; |
| 2799 } | 2828 } |
| 2800 DCHECK_EQ(0u, skip_size); | 2829 DCHECK_EQ(0u, skip_size); |
| 2801 GLuint offset = ToGLuint(pixels); | 2830 GLuint offset = ToGLuint(pixels); |
| 2802 BufferTracker::Buffer* buffer = GetBoundPixelTransferBufferIfValid( | 2831 BufferTracker::Buffer* buffer = GetBoundPixelTransferBufferIfValid( |
| 2803 bound_pixel_unpack_transfer_buffer_id_, | 2832 bound_pixel_unpack_transfer_buffer_id_, func_name, offset, size); |
| 2804 "glTexSubImage2D", offset, size); | |
| 2805 if (buffer && buffer->shm_id() != -1) { | 2833 if (buffer && buffer->shm_id() != -1) { |
| 2806 helper_->TexSubImage2D( | 2834 helper_->TexSubImage2D( |
| 2807 target, level, xoffset, yoffset, width, height, format, type, | 2835 target, level, xoffset, yoffset, width, height, format, type, |
| 2808 buffer->shm_id(), buffer->shm_offset() + offset, false); | 2836 buffer->shm_id(), buffer->shm_offset() + offset, false); |
| 2809 buffer->set_last_usage_token(helper_->InsertToken()); | 2837 buffer->set_last_usage_token(helper_->InsertToken()); |
| 2810 CheckGLError(); | 2838 CheckGLError(); |
| 2811 } | 2839 } |
| 2812 return; | 2840 return; |
| 2813 } | 2841 } |
| 2814 | 2842 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2829 PixelStoreParams service_params; | 2857 PixelStoreParams service_params; |
| 2830 service_params.alignment = unpack_alignment_; | 2858 service_params.alignment = unpack_alignment_; |
| 2831 if (!GLES2Util::ComputeImageDataSizesES3(width, height, 1, | 2859 if (!GLES2Util::ComputeImageDataSizesES3(width, height, 1, |
| 2832 format, type, | 2860 format, type, |
| 2833 service_params, | 2861 service_params, |
| 2834 &size, | 2862 &size, |
| 2835 nullptr, | 2863 nullptr, |
| 2836 &service_padded_row_size, | 2864 &service_padded_row_size, |
| 2837 nullptr, | 2865 nullptr, |
| 2838 nullptr)) { | 2866 nullptr)) { |
| 2839 SetGLError(GL_INVALID_VALUE, "glTexSubImage2D", "image size too large"); | 2867 SetGLError(GL_INVALID_VALUE, func_name, "image size too large"); |
| 2840 return; | 2868 return; |
| 2841 } | 2869 } |
| 2842 } else { | 2870 } else { |
| 2843 service_padded_row_size = padded_row_size; | 2871 service_padded_row_size = padded_row_size; |
| 2844 } | 2872 } |
| 2845 | 2873 |
| 2846 // advance pixels pointer past the skip rows and skip pixels | 2874 // advance pixels pointer past the skip rows and skip pixels |
| 2847 pixels = reinterpret_cast<const int8_t*>(pixels) + skip_size; | 2875 pixels = reinterpret_cast<const int8_t*>(pixels) + skip_size; |
| 2848 | 2876 |
| 2849 ScopedTransferBufferPtr buffer(size, helper_, transfer_buffer_); | 2877 ScopedTransferBufferPtr buffer(size, helper_, transfer_buffer_); |
| 2850 TexSubImage2DImpl( | 2878 TexSubImage2DImpl( |
| 2851 target, level, xoffset, yoffset, width, height, format, type, | 2879 target, level, xoffset, yoffset, width, height, format, type, |
| 2852 unpadded_row_size, pixels, padded_row_size, GL_FALSE, &buffer, | 2880 unpadded_row_size, pixels, padded_row_size, GL_FALSE, &buffer, |
| 2853 service_padded_row_size); | 2881 service_padded_row_size); |
| 2854 CheckGLError(); | 2882 CheckGLError(); |
| 2855 } | 2883 } |
| 2856 | 2884 |
| 2857 void GLES2Implementation::TexSubImage3D( | 2885 void GLES2Implementation::TexSubImage3D( |
| 2858 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, | 2886 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, |
| 2859 GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, | 2887 GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, |
| 2860 const void* pixels) { | 2888 const void* pixels) { |
| 2889 const char* func_name = "glTexSubImage3D"; |
| 2861 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 2890 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 2862 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glTexSubImage3D(" | 2891 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glTexSubImage3D(" |
| 2863 << GLES2Util::GetStringTextureTarget(target) << ", " | 2892 << GLES2Util::GetStringTextureTarget(target) << ", " |
| 2864 << level << ", " | 2893 << level << ", " |
| 2865 << xoffset << ", " << yoffset << ", " << zoffset << ", " | 2894 << xoffset << ", " << yoffset << ", " << zoffset << ", " |
| 2866 << width << ", " << height << ", " << depth << ", " | 2895 << width << ", " << height << ", " << depth << ", " |
| 2867 << GLES2Util::GetStringTextureFormat(format) << ", " | 2896 << GLES2Util::GetStringTextureFormat(format) << ", " |
| 2868 << GLES2Util::GetStringPixelType(type) << ", " | 2897 << GLES2Util::GetStringPixelType(type) << ", " |
| 2869 << static_cast<const void*>(pixels) << ")"); | 2898 << static_cast<const void*>(pixels) << ")"); |
| 2870 | 2899 |
| 2871 if (level < 0 || height < 0 || width < 0 || depth < 0 || | 2900 if (level < 0 || height < 0 || width < 0 || depth < 0 || |
| 2872 xoffset < 0 || yoffset < 0 || zoffset < 0) { | 2901 xoffset < 0 || yoffset < 0 || zoffset < 0) { |
| 2873 SetGLError(GL_INVALID_VALUE, "glTexSubImage3D", "dimension < 0"); | 2902 SetGLError(GL_INVALID_VALUE, func_name, "dimension < 0"); |
| 2903 return; |
| 2904 } |
| 2905 if ((unpack_skip_pixels_ + width > |
| 2906 (unpack_row_length_ ? unpack_row_length_ : width)) || |
| 2907 (unpack_skip_rows_ + height > |
| 2908 (unpack_image_height_ ? unpack_image_height_ : height))) { |
| 2909 // This is WebGL 2 specific constraints, but we do it for all ES3 contexts. |
| 2910 SetGLError(GL_INVALID_OPERATION, func_name, |
| 2911 "invalid unpack params combination"); |
| 2874 return; | 2912 return; |
| 2875 } | 2913 } |
| 2876 | 2914 |
| 2877 uint32_t size; | 2915 uint32_t size; |
| 2878 uint32_t unpadded_row_size; | 2916 uint32_t unpadded_row_size; |
| 2879 uint32_t padded_row_size; | 2917 uint32_t padded_row_size; |
| 2880 uint32_t skip_size; | 2918 uint32_t skip_size; |
| 2881 PixelStoreParams params = GetUnpackParameters(k3D); | 2919 PixelStoreParams params = GetUnpackParameters(k3D); |
| 2882 if (!GLES2Util::ComputeImageDataSizesES3(width, height, depth, | 2920 if (!GLES2Util::ComputeImageDataSizesES3(width, height, depth, |
| 2883 format, type, | 2921 format, type, |
| 2884 params, | 2922 params, |
| 2885 &size, | 2923 &size, |
| 2886 &unpadded_row_size, | 2924 &unpadded_row_size, |
| 2887 &padded_row_size, | 2925 &padded_row_size, |
| 2888 &skip_size, | 2926 &skip_size, |
| 2889 nullptr)) { | 2927 nullptr)) { |
| 2890 SetGLError(GL_INVALID_VALUE, "glTexSubImage3D", "image size to large"); | 2928 SetGLError(GL_INVALID_VALUE, func_name, "image size to large"); |
| 2891 return; | 2929 return; |
| 2892 } | 2930 } |
| 2893 | 2931 |
| 2894 if (bound_pixel_unpack_buffer_) { | 2932 if (bound_pixel_unpack_buffer_) { |
| 2895 base::CheckedNumeric<uint32_t> offset = ToGLuint(pixels); | 2933 base::CheckedNumeric<uint32_t> offset = ToGLuint(pixels); |
| 2896 offset += skip_size; | 2934 offset += skip_size; |
| 2897 if (!offset.IsValid()) { | 2935 if (!offset.IsValid()) { |
| 2898 SetGLError(GL_INVALID_VALUE, "glTexSubImage3D", "skip size too large"); | 2936 SetGLError(GL_INVALID_VALUE, func_name, "skip size too large"); |
| 2899 return; | 2937 return; |
| 2900 } | 2938 } |
| 2901 helper_->TexSubImage3D( | 2939 helper_->TexSubImage3D( |
| 2902 target, level, xoffset, yoffset, zoffset, width, height, depth, | 2940 target, level, xoffset, yoffset, zoffset, width, height, depth, |
| 2903 format, type, 0, offset.ValueOrDefault(0), false); | 2941 format, type, 0, offset.ValueOrDefault(0), false); |
| 2904 CheckGLError(); | 2942 CheckGLError(); |
| 2905 return; | 2943 return; |
| 2906 } | 2944 } |
| 2907 | 2945 |
| 2908 // If there's a pixel unpack buffer bound use it when issuing TexSubImage2D. | 2946 // If there's a pixel unpack buffer bound use it when issuing TexSubImage2D. |
| 2909 if (bound_pixel_unpack_transfer_buffer_id_) { | 2947 if (bound_pixel_unpack_transfer_buffer_id_) { |
| 2910 if (unpack_row_length_ > 0 || unpack_image_height_ > 0 || | 2948 if (unpack_row_length_ > 0 || unpack_image_height_ > 0 || |
| 2911 unpack_skip_pixels_ > 0 || unpack_skip_rows_ > 0 || | 2949 unpack_skip_pixels_ > 0 || unpack_skip_rows_ > 0 || |
| 2912 unpack_skip_images_ > 0) { | 2950 unpack_skip_images_ > 0) { |
| 2913 SetGLError(GL_INVALID_OPERATION, "glTexSubImage2D", | 2951 SetGLError(GL_INVALID_OPERATION, func_name, |
| 2914 "No ES3 pack parameters with pixel unpack transfer buffer."); | 2952 "No ES3 pack parameters with pixel unpack transfer buffer."); |
| 2915 return; | 2953 return; |
| 2916 } | 2954 } |
| 2917 DCHECK_EQ(0u, skip_size); | 2955 DCHECK_EQ(0u, skip_size); |
| 2918 GLuint offset = ToGLuint(pixels); | 2956 GLuint offset = ToGLuint(pixels); |
| 2919 BufferTracker::Buffer* buffer = GetBoundPixelTransferBufferIfValid( | 2957 BufferTracker::Buffer* buffer = GetBoundPixelTransferBufferIfValid( |
| 2920 bound_pixel_unpack_transfer_buffer_id_, | 2958 bound_pixel_unpack_transfer_buffer_id_, func_name, offset, size); |
| 2921 "glTexSubImage3D", offset, size); | |
| 2922 if (buffer && buffer->shm_id() != -1) { | 2959 if (buffer && buffer->shm_id() != -1) { |
| 2923 helper_->TexSubImage3D( | 2960 helper_->TexSubImage3D( |
| 2924 target, level, xoffset, yoffset, zoffset, width, height, depth, | 2961 target, level, xoffset, yoffset, zoffset, width, height, depth, |
| 2925 format, type, buffer->shm_id(), buffer->shm_offset() + offset, false); | 2962 format, type, buffer->shm_id(), buffer->shm_offset() + offset, false); |
| 2926 buffer->set_last_usage_token(helper_->InsertToken()); | 2963 buffer->set_last_usage_token(helper_->InsertToken()); |
| 2927 CheckGLError(); | 2964 CheckGLError(); |
| 2928 } | 2965 } |
| 2929 return; | 2966 return; |
| 2930 } | 2967 } |
| 2931 | 2968 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2945 PixelStoreParams service_params; | 2982 PixelStoreParams service_params; |
| 2946 service_params.alignment = unpack_alignment_; | 2983 service_params.alignment = unpack_alignment_; |
| 2947 if (!GLES2Util::ComputeImageDataSizesES3(width, height, depth, | 2984 if (!GLES2Util::ComputeImageDataSizesES3(width, height, depth, |
| 2948 format, type, | 2985 format, type, |
| 2949 service_params, | 2986 service_params, |
| 2950 &size, | 2987 &size, |
| 2951 nullptr, | 2988 nullptr, |
| 2952 &service_padded_row_size, | 2989 &service_padded_row_size, |
| 2953 nullptr, | 2990 nullptr, |
| 2954 nullptr)) { | 2991 nullptr)) { |
| 2955 SetGLError(GL_INVALID_VALUE, "glTexSubImage3D", "image size too large"); | 2992 SetGLError(GL_INVALID_VALUE, func_name, "image size too large"); |
| 2956 return; | 2993 return; |
| 2957 } | 2994 } |
| 2958 } else { | 2995 } else { |
| 2959 service_padded_row_size = padded_row_size; | 2996 service_padded_row_size = padded_row_size; |
| 2960 } | 2997 } |
| 2961 | 2998 |
| 2962 // advance pixels pointer past the skip images/rows/pixels | 2999 // advance pixels pointer past the skip images/rows/pixels |
| 2963 pixels = reinterpret_cast<const int8_t*>(pixels) + skip_size; | 3000 pixels = reinterpret_cast<const int8_t*>(pixels) + skip_size; |
| 2964 | 3001 |
| 2965 ScopedTransferBufferPtr buffer(size, helper_, transfer_buffer_); | 3002 ScopedTransferBufferPtr buffer(size, helper_, transfer_buffer_); |
| (...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3771 for (int32_t i = 0; i < result->GetNumResults(); ++i) { | 3808 for (int32_t i = 0; i < result->GetNumResults(); ++i) { |
| 3772 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]); | 3809 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]); |
| 3773 } | 3810 } |
| 3774 }); | 3811 }); |
| 3775 CheckGLError(); | 3812 CheckGLError(); |
| 3776 } | 3813 } |
| 3777 | 3814 |
| 3778 void GLES2Implementation::ReadPixels( | 3815 void GLES2Implementation::ReadPixels( |
| 3779 GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, | 3816 GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, |
| 3780 GLenum type, void* pixels) { | 3817 GLenum type, void* pixels) { |
| 3818 const char* func_name = "glReadPixels"; |
| 3781 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 3819 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 3782 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glReadPixels(" | 3820 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glReadPixels(" |
| 3783 << xoffset << ", " << yoffset << ", " | 3821 << xoffset << ", " << yoffset << ", " |
| 3784 << width << ", " << height << ", " | 3822 << width << ", " << height << ", " |
| 3785 << GLES2Util::GetStringReadPixelFormat(format) << ", " | 3823 << GLES2Util::GetStringReadPixelFormat(format) << ", " |
| 3786 << GLES2Util::GetStringPixelType(type) << ", " | 3824 << GLES2Util::GetStringPixelType(type) << ", " |
| 3787 << static_cast<const void*>(pixels) << ")"); | 3825 << static_cast<const void*>(pixels) << ")"); |
| 3788 if (width < 0 || height < 0) { | 3826 if (width < 0 || height < 0) { |
| 3789 SetGLError(GL_INVALID_VALUE, "glReadPixels", "dimensions < 0"); | 3827 SetGLError(GL_INVALID_VALUE, func_name, "dimensions < 0"); |
| 3790 return; | 3828 return; |
| 3791 } | 3829 } |
| 3792 | 3830 |
| 3831 if (pack_skip_pixels_ + width > |
| 3832 (pack_row_length_ ? pack_row_length_ : width)) { |
| 3833 // This is WebGL 2 specific constraints, but we do it for all ES3 contexts. |
| 3834 SetGLError(GL_INVALID_OPERATION, func_name, |
| 3835 "invalid pack params combination"); |
| 3836 return; |
| 3837 } |
| 3838 |
| 3793 // glReadPixel pads the size of each row of pixels by an amount specified by | 3839 // glReadPixel pads the size of each row of pixels by an amount specified by |
| 3794 // glPixelStorei. So, we have to take that into account both in the fact that | 3840 // glPixelStorei. So, we have to take that into account both in the fact that |
| 3795 // the pixels returned from the ReadPixel command will include that padding | 3841 // the pixels returned from the ReadPixel command will include that padding |
| 3796 // and that when we copy the results to the user's buffer we need to not | 3842 // and that when we copy the results to the user's buffer we need to not |
| 3797 // write those padding bytes but leave them as they are. | 3843 // write those padding bytes but leave them as they are. |
| 3798 | 3844 |
| 3799 TRACE_EVENT0("gpu", "GLES2::ReadPixels"); | 3845 TRACE_EVENT0("gpu", "GLES2::ReadPixels"); |
| 3800 typedef cmds::ReadPixels::Result Result; | 3846 typedef cmds::ReadPixels::Result Result; |
| 3801 | 3847 |
| 3802 uint32_t size; | 3848 uint32_t size; |
| 3803 uint32_t unpadded_row_size; | 3849 uint32_t unpadded_row_size; |
| 3804 uint32_t padded_row_size; | 3850 uint32_t padded_row_size; |
| 3805 uint32_t skip_size; | 3851 uint32_t skip_size; |
| 3806 PixelStoreParams params; | 3852 PixelStoreParams params; |
| 3807 params.alignment = pack_alignment_; | 3853 params.alignment = pack_alignment_; |
| 3808 params.row_length = pack_row_length_; | 3854 params.row_length = pack_row_length_; |
| 3809 params.skip_pixels = pack_skip_pixels_; | 3855 params.skip_pixels = pack_skip_pixels_; |
| 3810 params.skip_rows = pack_skip_rows_; | 3856 params.skip_rows = pack_skip_rows_; |
| 3811 if (!GLES2Util::ComputeImageDataSizesES3(width, height, 1, | 3857 if (!GLES2Util::ComputeImageDataSizesES3(width, height, 1, |
| 3812 format, type, | 3858 format, type, |
| 3813 params, | 3859 params, |
| 3814 &size, | 3860 &size, |
| 3815 &unpadded_row_size, | 3861 &unpadded_row_size, |
| 3816 &padded_row_size, | 3862 &padded_row_size, |
| 3817 &skip_size, | 3863 &skip_size, |
| 3818 nullptr)) { | 3864 nullptr)) { |
| 3819 SetGLError(GL_INVALID_VALUE, "glReadPixels", "size too large."); | 3865 SetGLError(GL_INVALID_VALUE, func_name, "size too large."); |
| 3820 return; | 3866 return; |
| 3821 } | 3867 } |
| 3822 | 3868 |
| 3823 if (bound_pixel_pack_buffer_) { | 3869 if (bound_pixel_pack_buffer_) { |
| 3824 base::CheckedNumeric<GLuint> offset = ToGLuint(pixels); | 3870 base::CheckedNumeric<GLuint> offset = ToGLuint(pixels); |
| 3825 offset += skip_size; | 3871 offset += skip_size; |
| 3826 if (!offset.IsValid()) { | 3872 if (!offset.IsValid()) { |
| 3827 SetGLError(GL_INVALID_VALUE, "glReadPixels", "skip size too large."); | 3873 SetGLError(GL_INVALID_VALUE, func_name, "skip size too large."); |
| 3828 return; | 3874 return; |
| 3829 } | 3875 } |
| 3830 helper_->ReadPixels(xoffset, yoffset, width, height, format, type, 0, | 3876 helper_->ReadPixels(xoffset, yoffset, width, height, format, type, 0, |
| 3831 offset.ValueOrDefault(0), 0, 0, false); | 3877 offset.ValueOrDefault(0), 0, 0, false); |
| 3832 CheckGLError(); | 3878 CheckGLError(); |
| 3833 return; | 3879 return; |
| 3834 } | 3880 } |
| 3835 | 3881 |
| 3836 uint32_t service_padded_row_size = 0; | 3882 uint32_t service_padded_row_size = 0; |
| 3837 if (pack_row_length_ > 0 && pack_row_length_ != width) { | 3883 if (pack_row_length_ > 0 && pack_row_length_ != width) { |
| 3838 if (!GLES2Util::ComputeImagePaddedRowSize(width, | 3884 if (!GLES2Util::ComputeImagePaddedRowSize(width, |
| 3839 format, type, | 3885 format, type, |
| 3840 pack_alignment_, | 3886 pack_alignment_, |
| 3841 &service_padded_row_size)) { | 3887 &service_padded_row_size)) { |
| 3842 SetGLError(GL_INVALID_VALUE, "glReadPixels", "size too large."); | 3888 SetGLError(GL_INVALID_VALUE, func_name, "size too large."); |
| 3843 return; | 3889 return; |
| 3844 } | 3890 } |
| 3845 } else { | 3891 } else { |
| 3846 service_padded_row_size = padded_row_size; | 3892 service_padded_row_size = padded_row_size; |
| 3847 } | 3893 } |
| 3848 | 3894 |
| 3849 if (bound_pixel_pack_transfer_buffer_id_) { | 3895 if (bound_pixel_pack_transfer_buffer_id_) { |
| 3850 if (pack_row_length_ > 0 || pack_skip_pixels_ > 0 || pack_skip_rows_ > 0) { | 3896 if (pack_row_length_ > 0 || pack_skip_pixels_ > 0 || pack_skip_rows_ > 0) { |
| 3851 SetGLError(GL_INVALID_OPERATION, "glReadPixels", | 3897 SetGLError(GL_INVALID_OPERATION, func_name, |
| 3852 "No ES3 pack parameters with pixel pack transfer buffer."); | 3898 "No ES3 pack parameters with pixel pack transfer buffer."); |
| 3853 return; | 3899 return; |
| 3854 } | 3900 } |
| 3855 DCHECK_EQ(0u, skip_size); | 3901 DCHECK_EQ(0u, skip_size); |
| 3856 GLuint offset = ToGLuint(pixels); | 3902 GLuint offset = ToGLuint(pixels); |
| 3857 BufferTracker::Buffer* buffer = GetBoundPixelTransferBufferIfValid( | 3903 BufferTracker::Buffer* buffer = GetBoundPixelTransferBufferIfValid( |
| 3858 bound_pixel_pack_transfer_buffer_id_, "glReadPixels", offset, size); | 3904 bound_pixel_pack_transfer_buffer_id_, func_name, offset, size); |
| 3859 if (buffer && buffer->shm_id() != -1) { | 3905 if (buffer && buffer->shm_id() != -1) { |
| 3860 helper_->ReadPixels(xoffset, yoffset, width, height, format, type, | 3906 helper_->ReadPixels(xoffset, yoffset, width, height, format, type, |
| 3861 buffer->shm_id(), buffer->shm_offset() + offset, | 3907 buffer->shm_id(), buffer->shm_offset() + offset, |
| 3862 0, 0, true); | 3908 0, 0, true); |
| 3863 CheckGLError(); | 3909 CheckGLError(); |
| 3864 } | 3910 } |
| 3865 return; | 3911 return; |
| 3866 } | 3912 } |
| 3867 | 3913 |
| 3868 if (!pixels) { | 3914 if (!pixels) { |
| 3869 SetGLError(GL_INVALID_OPERATION, "glReadPixels", "pixels = NULL"); | 3915 SetGLError(GL_INVALID_OPERATION, func_name, "pixels = NULL"); |
| 3870 return; | 3916 return; |
| 3871 } | 3917 } |
| 3872 | 3918 |
| 3873 int8_t* dest = reinterpret_cast<int8_t*>(pixels); | 3919 int8_t* dest = reinterpret_cast<int8_t*>(pixels); |
| 3874 // Advance pixels pointer past the skip rows and skip pixels | 3920 // Advance pixels pointer past the skip rows and skip pixels |
| 3875 dest += skip_size; | 3921 dest += skip_size; |
| 3876 | 3922 |
| 3877 // Transfer by rows. | 3923 // Transfer by rows. |
| 3878 // The max rows we can transfer. | 3924 // The max rows we can transfer. |
| 3879 GLsizei remaining_rows = height; | 3925 GLsizei remaining_rows = height; |
| (...skipping 2948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6828 cached_extensions_.clear(); | 6874 cached_extensions_.clear(); |
| 6829 } | 6875 } |
| 6830 | 6876 |
| 6831 // Include the auto-generated part of this file. We split this because it means | 6877 // Include the auto-generated part of this file. We split this because it means |
| 6832 // we can easily edit the non-auto generated parts right here in this file | 6878 // we can easily edit the non-auto generated parts right here in this file |
| 6833 // instead of having to edit some template or the code generator. | 6879 // instead of having to edit some template or the code generator. |
| 6834 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" | 6880 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" |
| 6835 | 6881 |
| 6836 } // namespace gles2 | 6882 } // namespace gles2 |
| 6837 } // namespace gpu | 6883 } // namespace gpu |
| OLD | NEW |