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

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

Issue 2859723002: Copy NV12 picture buffers on demand on the main thread. (Closed)
Patch Set: change comment Created 3 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 | « no previous file | gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.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 // 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/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 1901 matching lines...) Expand 10 before | Expand all | Expand 10 after
1912 // Returns true if successful, simulated will be true if attrib0 was 1912 // Returns true if successful, simulated will be true if attrib0 was
1913 // simulated. 1913 // simulated.
1914 bool SimulateAttrib0( 1914 bool SimulateAttrib0(
1915 const char* function_name, GLuint max_vertex_accessed, bool* simulated); 1915 const char* function_name, GLuint max_vertex_accessed, bool* simulated);
1916 void RestoreStateForAttrib(GLuint attrib, bool restore_array_binding); 1916 void RestoreStateForAttrib(GLuint attrib, bool restore_array_binding);
1917 1917
1918 // Copies the image to the texture currently bound to |textarget|. The image 1918 // Copies the image to the texture currently bound to |textarget|. The image
1919 // state of |texture| is updated to reflect the new state. 1919 // state of |texture| is updated to reflect the new state.
1920 void DoCopyTexImage(Texture* texture, GLenum textarget, gl::GLImage* image); 1920 void DoCopyTexImage(Texture* texture, GLenum textarget, gl::GLImage* image);
1921 1921
1922 // This will call DoCopyTexImage if texture has an image but that image is 1922 // If the texture has an image but that image is not bound or copied to the
1923 // not bound or copied to the texture. 1923 // texture, this will first attempt to bind it, and if that fails
1924 void DoCopyTexImageIfNeeded(Texture* texture, GLenum textarget); 1924 // DoCopyTexImage on it. texture_unit is the texture unit it should be bound
1925 // to, or 0 if it doesn't matter - setting it to 0 will cause the previous
1926 // binding to be restored after the operation. This returns true if a copy
1927 // or bind happened and the caller needs to restore the previous texture
1928 // binding.
1929 bool DoBindOrCopyTexImageIfNeeded(Texture* texture,
1930 GLenum textarget,
1931 GLuint texture_unit);
1925 1932
1926 // Returns false if textures were replaced. 1933 // Returns false if textures were replaced.
1927 bool PrepareTexturesForRender(); 1934 bool PrepareTexturesForRender();
1928 void RestoreStateForTextures(); 1935 void RestoreStateForTextures();
1929 1936
1930 // Returns true if GL_FIXED attribs were simulated. 1937 // Returns true if GL_FIXED attribs were simulated.
1931 bool SimulateFixedAttribs( 1938 bool SimulateFixedAttribs(
1932 const char* function_name, 1939 const char* function_name,
1933 GLuint max_vertex_accessed, bool* simulated, GLsizei primcount); 1940 GLuint max_vertex_accessed, bool* simulated, GLsizei primcount);
1934 void RestoreStateForSimulatedFixedAttribs(); 1941 void RestoreStateForSimulatedFixedAttribs();
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
2517 const char* function_name, ErrorState* error_state) 2524 const char* function_name, ErrorState* error_state)
2518 : function_name_(function_name), 2525 : function_name_(function_name),
2519 error_state_(error_state) { 2526 error_state_(error_state) {
2520 ERRORSTATE_COPY_REAL_GL_ERRORS_TO_WRAPPER(error_state_, function_name_); 2527 ERRORSTATE_COPY_REAL_GL_ERRORS_TO_WRAPPER(error_state_, function_name_);
2521 } 2528 }
2522 2529
2523 ScopedGLErrorSuppressor::~ScopedGLErrorSuppressor() { 2530 ScopedGLErrorSuppressor::~ScopedGLErrorSuppressor() {
2524 ERRORSTATE_CLEAR_REAL_GL_ERRORS(error_state_, function_name_); 2531 ERRORSTATE_CLEAR_REAL_GL_ERRORS(error_state_, function_name_);
2525 } 2532 }
2526 2533
2527 static void RestoreCurrentTextureBindings(ContextState* state, GLenum target) { 2534 static void RestoreCurrentTextureBindings(ContextState* state,
2535 GLenum target,
2536 GLuint texture_unit) {
2528 DCHECK(!state->texture_units.empty()); 2537 DCHECK(!state->texture_units.empty());
2529 TextureUnit& info = state->texture_units[0]; 2538 DCHECK_LT(texture_unit, state->texture_units.size());
2539 TextureUnit& info = state->texture_units[texture_unit];
2530 GLuint last_id; 2540 GLuint last_id;
2531 TextureRef* texture_ref = info.GetInfoForTarget(target); 2541 TextureRef* texture_ref = info.GetInfoForTarget(target);
2532 if (texture_ref) { 2542 if (texture_ref) {
2533 last_id = texture_ref->service_id(); 2543 last_id = texture_ref->service_id();
2534 } else { 2544 } else {
2535 last_id = 0; 2545 last_id = 0;
2536 } 2546 }
2537 2547
2538 glBindTexture(target, last_id); 2548 glBindTexture(target, last_id);
2539 glActiveTexture(GL_TEXTURE0 + state->active_texture_unit);
2540 } 2549 }
2541 2550
2542 ScopedTextureBinder::ScopedTextureBinder(ContextState* state, 2551 ScopedTextureBinder::ScopedTextureBinder(ContextState* state,
2543 GLuint id, 2552 GLuint id,
2544 GLenum target) 2553 GLenum target)
2545 : state_(state), 2554 : state_(state),
2546 target_(target) { 2555 target_(target) {
2547 ScopedGLErrorSuppressor suppressor( 2556 ScopedGLErrorSuppressor suppressor(
2548 "ScopedTextureBinder::ctor", state_->GetErrorState()); 2557 "ScopedTextureBinder::ctor", state_->GetErrorState());
2549 2558
2550 // TODO(apatrick): Check if there are any other states that need to be reset 2559 // TODO(apatrick): Check if there are any other states that need to be reset
2551 // before binding a new texture. 2560 // before binding a new texture.
2552 glActiveTexture(GL_TEXTURE0); 2561 glActiveTexture(GL_TEXTURE0);
2553 glBindTexture(target, id); 2562 glBindTexture(target, id);
2554 } 2563 }
2555 2564
2556 ScopedTextureBinder::~ScopedTextureBinder() { 2565 ScopedTextureBinder::~ScopedTextureBinder() {
2557 ScopedGLErrorSuppressor suppressor( 2566 ScopedGLErrorSuppressor suppressor(
2558 "ScopedTextureBinder::dtor", state_->GetErrorState()); 2567 "ScopedTextureBinder::dtor", state_->GetErrorState());
2559 RestoreCurrentTextureBindings(state_, target_); 2568 RestoreCurrentTextureBindings(state_, target_, 0);
2569 state_->RestoreActiveTexture();
2560 } 2570 }
2561 2571
2562 ScopedRenderBufferBinder::ScopedRenderBufferBinder(ContextState* state, 2572 ScopedRenderBufferBinder::ScopedRenderBufferBinder(ContextState* state,
2563 GLuint id) 2573 GLuint id)
2564 : state_(state) { 2574 : state_(state) {
2565 ScopedGLErrorSuppressor suppressor( 2575 ScopedGLErrorSuppressor suppressor(
2566 "ScopedRenderBufferBinder::ctor", state_->GetErrorState()); 2576 "ScopedRenderBufferBinder::ctor", state_->GetErrorState());
2567 glBindRenderbufferEXT(GL_RENDERBUFFER, id); 2577 glBindRenderbufferEXT(GL_RENDERBUFFER, id);
2568 } 2578 }
2569 2579
(...skipping 5203 matching lines...) Expand 10 before | Expand all | Expand 10 after
7773 7783
7774 if ((level > 0 && !feature_info_->IsWebGL2OrES3Context()) || 7784 if ((level > 0 && !feature_info_->IsWebGL2OrES3Context()) ||
7775 !texture_manager()->ValidForTarget(textarget, level, 0, 0, 1)) { 7785 !texture_manager()->ValidForTarget(textarget, level, 0, 0, 1)) {
7776 LOCAL_SET_GL_ERROR( 7786 LOCAL_SET_GL_ERROR(
7777 GL_INVALID_VALUE, 7787 GL_INVALID_VALUE,
7778 name, "level out of range"); 7788 name, "level out of range");
7779 return; 7789 return;
7780 } 7790 }
7781 7791
7782 if (texture_ref) 7792 if (texture_ref)
7783 DoCopyTexImageIfNeeded(texture_ref->texture(), textarget); 7793 DoBindOrCopyTexImageIfNeeded(texture_ref->texture(), textarget, 0);
7784 7794
7785 std::vector<GLenum> attachments; 7795 std::vector<GLenum> attachments;
7786 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { 7796 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
7787 attachments.push_back(GL_DEPTH_ATTACHMENT); 7797 attachments.push_back(GL_DEPTH_ATTACHMENT);
7788 attachments.push_back(GL_STENCIL_ATTACHMENT); 7798 attachments.push_back(GL_STENCIL_ATTACHMENT);
7789 } else { 7799 } else {
7790 attachments.push_back(attachment); 7800 attachments.push_back(attachment);
7791 } 7801 }
7792 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(name); 7802 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(name);
7793 for (size_t ii = 0; ii < attachments.size(); ++ii) { 7803 for (size_t ii = 0; ii < attachments.size(); ++ii) {
(...skipping 1857 matching lines...) Expand 10 before | Expand all | Expand 10 after
9651 gl::GLImage* image) { 9661 gl::GLImage* image) {
9652 // Note: We update the state to COPIED prior to calling CopyTexImage() 9662 // Note: We update the state to COPIED prior to calling CopyTexImage()
9653 // as that allows the GLImage implemenatation to set it back to UNBOUND 9663 // as that allows the GLImage implemenatation to set it back to UNBOUND
9654 // and ensure that CopyTexImage() is called each time the texture is 9664 // and ensure that CopyTexImage() is called each time the texture is
9655 // used. 9665 // used.
9656 texture->SetLevelImageState(textarget, 0, Texture::COPIED); 9666 texture->SetLevelImageState(textarget, 0, Texture::COPIED);
9657 bool rv = image->CopyTexImage(textarget); 9667 bool rv = image->CopyTexImage(textarget);
9658 DCHECK(rv) << "CopyTexImage() failed"; 9668 DCHECK(rv) << "CopyTexImage() failed";
9659 } 9669 }
9660 9670
9661 void GLES2DecoderImpl::DoCopyTexImageIfNeeded(Texture* texture, 9671 bool GLES2DecoderImpl::DoBindOrCopyTexImageIfNeeded(Texture* texture,
9662 GLenum textarget) { 9672 GLenum textarget,
9673 GLuint texture_unit) {
9663 // Image is already in use if texture is attached to a framebuffer. 9674 // Image is already in use if texture is attached to a framebuffer.
9664 if (texture && !texture->IsAttachedToFramebuffer()) { 9675 if (texture && !texture->IsAttachedToFramebuffer()) {
9665 Texture::ImageState image_state; 9676 Texture::ImageState image_state;
9666 gl::GLImage* image = texture->GetLevelImage(textarget, 0, &image_state); 9677 gl::GLImage* image = texture->GetLevelImage(textarget, 0, &image_state);
9667 if (image && image_state == Texture::UNBOUND) { 9678 if (image && image_state == Texture::UNBOUND) {
9668 ScopedGLErrorSuppressor suppressor( 9679 ScopedGLErrorSuppressor suppressor(
9669 "GLES2DecoderImpl::DoCopyTexImageIfNeeded", GetErrorState()); 9680 "GLES2DecoderImpl::DoBindOrCopyTexImageIfNeeded", GetErrorState());
9681 if (texture_unit)
9682 glActiveTexture(texture_unit);
9670 glBindTexture(textarget, texture->service_id()); 9683 glBindTexture(textarget, texture->service_id());
9671 DoCopyTexImage(texture, textarget, image); 9684 if (image->BindTexImage(textarget)) {
9672 RestoreCurrentTextureBindings(&state_, textarget); 9685 image_state = Texture::BOUND;
9686 } else {
9687 DoCopyTexImage(texture, textarget, image);
9688 }
9689 if (!texture_unit) {
9690 RestoreCurrentTextureBindings(&state_, textarget,
9691 state_.active_texture_unit);
9692 return false;
9693 }
9694 return true;
9673 } 9695 }
9674 } 9696 }
9697 return false;
9675 } 9698 }
9676 9699
9677 void GLES2DecoderImpl::DoCopyBufferSubData(GLenum readtarget, 9700 void GLES2DecoderImpl::DoCopyBufferSubData(GLenum readtarget,
9678 GLenum writetarget, 9701 GLenum writetarget,
9679 GLintptr readoffset, 9702 GLintptr readoffset,
9680 GLintptr writeoffset, 9703 GLintptr writeoffset,
9681 GLsizeiptr size) { 9704 GLsizeiptr size) {
9682 // Just delegate it. Some validation is actually done before this. 9705 // Just delegate it. Some validation is actually done before this.
9683 buffer_manager()->ValidateAndDoCopyBufferSubData( 9706 buffer_manager()->ValidateAndDoCopyBufferSubData(
9684 &state_, readtarget, writetarget, readoffset, writeoffset, size); 9707 &state_, readtarget, writetarget, readoffset, writeoffset, size);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
9719 std::string("texture bound to texture unit ") + 9742 std::string("texture bound to texture unit ") +
9720 base::UintToString(texture_unit_index) + 9743 base::UintToString(texture_unit_index) +
9721 " is not renderable. It maybe non-power-of-2 and have" 9744 " is not renderable. It maybe non-power-of-2 and have"
9722 " incompatible texture filtering."); 9745 " incompatible texture filtering.");
9723 } 9746 }
9724 continue; 9747 continue;
9725 } 9748 }
9726 9749
9727 if (textarget != GL_TEXTURE_CUBE_MAP) { 9750 if (textarget != GL_TEXTURE_CUBE_MAP) {
9728 Texture* texture = texture_ref->texture(); 9751 Texture* texture = texture_ref->texture();
9729 Texture::ImageState image_state; 9752 if (DoBindOrCopyTexImageIfNeeded(texture, textarget,
9730 gl::GLImage* image = 9753 GL_TEXTURE0 + texture_unit_index)) {
9731 texture->GetLevelImage(textarget, 0, &image_state);
9732 if (image && image_state == Texture::UNBOUND &&
9733 !texture->IsAttachedToFramebuffer()) {
9734 ScopedGLErrorSuppressor suppressor(
9735 "GLES2DecoderImpl::PrepareTexturesForRender", GetErrorState());
9736 textures_set = true; 9754 textures_set = true;
9737 glActiveTexture(GL_TEXTURE0 + texture_unit_index);
9738 DoCopyTexImage(texture, textarget, image);
9739 continue; 9755 continue;
9740 } 9756 }
9741 } 9757 }
9742 } 9758 }
9743 // else: should this be an error? 9759 // else: should this be an error?
9744 } 9760 }
9745 } 9761 }
9746 return !textures_set; 9762 return !textures_set;
9747 } 9763 }
9748 9764
(...skipping 7166 matching lines...) Expand 10 before | Expand all | Expand 10 after
16915 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(kFunctionName); 16931 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(kFunctionName);
16916 glBindTexture(dest_binding_target, dest_texture->service_id()); 16932 glBindTexture(dest_binding_target, dest_texture->service_id());
16917 glTexImage2D(dest_target, dest_level, 16933 glTexImage2D(dest_target, dest_level,
16918 TextureManager::AdjustTexInternalFormat(feature_info_.get(), 16934 TextureManager::AdjustTexInternalFormat(feature_info_.get(),
16919 internal_format), 16935 internal_format),
16920 source_width, source_height, 0, 16936 source_width, source_height, 0,
16921 TextureManager::AdjustTexFormat(feature_info_.get(), format), 16937 TextureManager::AdjustTexFormat(feature_info_.get(), format),
16922 dest_type, nullptr); 16938 dest_type, nullptr);
16923 GLenum error = LOCAL_PEEK_GL_ERROR(kFunctionName); 16939 GLenum error = LOCAL_PEEK_GL_ERROR(kFunctionName);
16924 if (error != GL_NO_ERROR) { 16940 if (error != GL_NO_ERROR) {
16925 RestoreCurrentTextureBindings(&state_, dest_binding_target); 16941 RestoreCurrentTextureBindings(&state_, dest_binding_target,
16942 state_.active_texture_unit);
16926 return; 16943 return;
16927 } 16944 }
16928 16945
16929 texture_manager()->SetLevelInfo(dest_texture_ref, dest_target, dest_level, 16946 texture_manager()->SetLevelInfo(dest_texture_ref, dest_target, dest_level,
16930 internal_format, source_width, 16947 internal_format, source_width,
16931 source_height, 1, 0, format, dest_type, 16948 source_height, 1, 0, format, dest_type,
16932 gfx::Rect(source_width, source_height)); 16949 gfx::Rect(source_width, source_height));
16933 dest_texture->ApplyFormatWorkarounds(feature_info_.get()); 16950 dest_texture->ApplyFormatWorkarounds(feature_info_.get());
16934 } else { 16951 } else {
16935 texture_manager()->SetLevelCleared(dest_texture_ref, dest_target, 16952 texture_manager()->SetLevelCleared(dest_texture_ref, dest_target,
16936 dest_level, true); 16953 dest_level, true);
16937 } 16954 }
16938 16955
16939 // Try using GLImage::CopyTexImage when possible. 16956 // Try using GLImage::CopyTexImage when possible.
16940 bool unpack_premultiply_alpha_change = 16957 bool unpack_premultiply_alpha_change =
16941 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; 16958 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0;
16942 // TODO(qiankun.miao@intel.com): Support level > 0 for CopyTexImage. 16959 // TODO(qiankun.miao@intel.com): Support level > 0 for CopyTexImage.
16943 if (image && dest_level == 0 && !unpack_flip_y && 16960 if (image && dest_level == 0 && !unpack_flip_y &&
16944 !unpack_premultiply_alpha_change) { 16961 !unpack_premultiply_alpha_change) {
16945 glBindTexture(dest_binding_target, dest_texture->service_id()); 16962 glBindTexture(dest_binding_target, dest_texture->service_id());
16946 if (image->CopyTexImage(dest_target)) 16963 if (image->CopyTexImage(dest_target))
16947 return; 16964 return;
16948 } 16965 }
16949 16966
16950 DoCopyTexImageIfNeeded(source_texture, source_target); 16967 DoBindOrCopyTexImageIfNeeded(source_texture, source_target, 0);
16951 16968
16952 // GL_TEXTURE_EXTERNAL_OES texture requires that we apply a transform matrix 16969 // GL_TEXTURE_EXTERNAL_OES texture requires that we apply a transform matrix
16953 // before presenting. 16970 // before presenting.
16954 if (source_target == GL_TEXTURE_EXTERNAL_OES) { 16971 if (source_target == GL_TEXTURE_EXTERNAL_OES) {
16955 if (GLStreamTextureImage* image = 16972 if (GLStreamTextureImage* image =
16956 source_texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES, 16973 source_texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES,
16957 source_level)) { 16974 source_level)) {
16958 GLfloat transform_matrix[16]; 16975 GLfloat transform_matrix[16];
16959 image->GetTextureMatrix(transform_matrix); 16976 image->GetTextureMatrix(transform_matrix);
16960 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( 16977 copy_texture_CHROMIUM_->DoCopyTextureWithTransform(
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
17152 if (image && dest_level == 0 && !unpack_flip_y && 17169 if (image && dest_level == 0 && !unpack_flip_y &&
17153 !unpack_premultiply_alpha_change) { 17170 !unpack_premultiply_alpha_change) {
17154 ScopedTextureBinder binder(&state_, dest_texture->service_id(), 17171 ScopedTextureBinder binder(&state_, dest_texture->service_id(),
17155 dest_binding_target); 17172 dest_binding_target);
17156 if (image->CopyTexSubImage(dest_target, gfx::Point(xoffset, yoffset), 17173 if (image->CopyTexSubImage(dest_target, gfx::Point(xoffset, yoffset),
17157 gfx::Rect(x, y, width, height))) { 17174 gfx::Rect(x, y, width, height))) {
17158 return; 17175 return;
17159 } 17176 }
17160 } 17177 }
17161 17178
17162 DoCopyTexImageIfNeeded(source_texture, source_target); 17179 DoBindOrCopyTexImageIfNeeded(source_texture, source_target, 0);
17163 17180
17164 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix 17181 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix
17165 // before presenting. 17182 // before presenting.
17166 if (source_target == GL_TEXTURE_EXTERNAL_OES) { 17183 if (source_target == GL_TEXTURE_EXTERNAL_OES) {
17167 if (GLStreamTextureImage* image = 17184 if (GLStreamTextureImage* image =
17168 source_texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES, 17185 source_texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES,
17169 source_level)) { 17186 source_level)) {
17170 GLfloat transform_matrix[16]; 17187 GLfloat transform_matrix[16];
17171 image->GetTextureMatrix(transform_matrix); 17188 image->GetTextureMatrix(transform_matrix);
17172 copy_texture_CHROMIUM_->DoCopySubTextureWithTransform( 17189 copy_texture_CHROMIUM_->DoCopySubTextureWithTransform(
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
17329 &source_size); 17346 &source_size);
17330 DCHECK(did_get_size); 17347 DCHECK(did_get_size);
17331 17348
17332 // Ensure that the glCompressedTexImage2D succeeds. 17349 // Ensure that the glCompressedTexImage2D succeeds.
17333 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(kFunctionName); 17350 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(kFunctionName);
17334 glCompressedTexImage2D(GL_TEXTURE_2D, 0, source_internal_format, 17351 glCompressedTexImage2D(GL_TEXTURE_2D, 0, source_internal_format,
17335 source_width, source_height, 0, source_size, 17352 source_width, source_height, 0, source_size,
17336 NULL); 17353 NULL);
17337 GLenum error = LOCAL_PEEK_GL_ERROR(kFunctionName); 17354 GLenum error = LOCAL_PEEK_GL_ERROR(kFunctionName);
17338 if (error != GL_NO_ERROR) { 17355 if (error != GL_NO_ERROR) {
17339 RestoreCurrentTextureBindings(&state_, dest_texture->target()); 17356 RestoreCurrentTextureBindings(&state_, dest_texture->target(),
17357 state_.active_texture_unit);
17340 return; 17358 return;
17341 } 17359 }
17342 17360
17343 texture_manager()->SetLevelInfo( 17361 texture_manager()->SetLevelInfo(
17344 dest_texture_ref, dest_texture->target(), 0, source_internal_format, 17362 dest_texture_ref, dest_texture->target(), 0, source_internal_format,
17345 source_width, source_height, 1, 0, source_internal_format, 17363 source_width, source_height, 1, 0, source_internal_format,
17346 source_type, gfx::Rect(source_width, source_height)); 17364 source_type, gfx::Rect(source_width, source_height));
17347 } else { 17365 } else {
17348 texture_manager()->SetLevelCleared( 17366 texture_manager()->SetLevelCleared(
17349 dest_texture_ref, dest_texture->target(), 0, true); 17367 dest_texture_ref, dest_texture->target(), 0, true);
17350 } 17368 }
17351 17369
17352 if (image->CopyTexImage(dest_texture->target())) 17370 if (image->CopyTexImage(dest_texture->target()))
17353 return; 17371 return;
17354 } 17372 }
17355 17373
17356 TRACE_EVENT0( 17374 TRACE_EVENT0(
17357 "gpu", 17375 "gpu",
17358 "GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM, fallback"); 17376 "GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM, fallback");
17359 17377
17360 DoCopyTexImageIfNeeded(source_texture, source_texture->target()); 17378 DoBindOrCopyTexImageIfNeeded(source_texture, source_texture->target(), 0);
17361 17379
17362 // As a fallback, copy into a non-compressed GL_RGBA texture. 17380 // As a fallback, copy into a non-compressed GL_RGBA texture.
17363 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(kFunctionName); 17381 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(kFunctionName);
17364 glTexImage2D(dest_texture->target(), 0, GL_RGBA, source_width, source_height, 17382 glTexImage2D(dest_texture->target(), 0, GL_RGBA, source_width, source_height,
17365 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); 17383 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
17366 GLenum error = LOCAL_PEEK_GL_ERROR(kFunctionName); 17384 GLenum error = LOCAL_PEEK_GL_ERROR(kFunctionName);
17367 if (error != GL_NO_ERROR) { 17385 if (error != GL_NO_ERROR) {
17368 RestoreCurrentTextureBindings(&state_, dest_texture->target()); 17386 RestoreCurrentTextureBindings(&state_, dest_texture->target(),
17387 state_.active_texture_unit);
17369 return; 17388 return;
17370 } 17389 }
17371 17390
17372 texture_manager()->SetLevelInfo( 17391 texture_manager()->SetLevelInfo(
17373 dest_texture_ref, dest_texture->target(), 0, GL_RGBA, source_width, 17392 dest_texture_ref, dest_texture->target(), 0, GL_RGBA, source_width,
17374 source_height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 17393 source_height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
17375 gfx::Rect(source_width, source_height)); 17394 gfx::Rect(source_width, source_height));
17376 17395
17377 copy_texture_CHROMIUM_->DoCopyTexture( 17396 copy_texture_CHROMIUM_->DoCopyTexture(
17378 this, source_texture->target(), source_texture->service_id(), 0, 17397 this, source_texture->target(), source_texture->service_id(), 0,
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
17676 GLenum target, 17695 GLenum target,
17677 GLuint client_id) { 17696 GLuint client_id) {
17678 TextureRef* texture_ref = GetTexture(client_id); 17697 TextureRef* texture_ref = GetTexture(client_id);
17679 if (!texture_ref) { 17698 if (!texture_ref) {
17680 GLuint service_id; 17699 GLuint service_id;
17681 glGenTextures(1, &service_id); 17700 glGenTextures(1, &service_id);
17682 DCHECK_NE(0u, service_id); 17701 DCHECK_NE(0u, service_id);
17683 texture_ref = CreateTexture(client_id, service_id); 17702 texture_ref = CreateTexture(client_id, service_id);
17684 texture_manager()->SetTarget(texture_ref, target); 17703 texture_manager()->SetTarget(texture_ref, target);
17685 glBindTexture(target, service_id); 17704 glBindTexture(target, service_id);
17686 RestoreCurrentTextureBindings(&state_, target); 17705 RestoreCurrentTextureBindings(&state_, target, state_.active_texture_unit);
17687 } 17706 }
17688 } 17707 }
17689 17708
17690 void GLES2DecoderImpl::DoCreateAndConsumeTextureINTERNAL( 17709 void GLES2DecoderImpl::DoCreateAndConsumeTextureINTERNAL(
17691 GLenum target, 17710 GLenum target,
17692 GLuint client_id, 17711 GLuint client_id,
17693 const volatile GLbyte* data) { 17712 const volatile GLbyte* data) {
17694 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoCreateAndConsumeTextureINTERNAL", 17713 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoCreateAndConsumeTextureINTERNAL",
17695 "context", logger_.GetLogPrefix(), 17714 "context", logger_.GetLogPrefix(),
17696 "mailbox[0]", static_cast<unsigned char>(data[0])); 17715 "mailbox[0]", static_cast<unsigned char>(data[0]));
(...skipping 2028 matching lines...) Expand 10 before | Expand all | Expand 10 after
19725 } 19744 }
19726 19745
19727 // Include the auto-generated part of this file. We split this because it means 19746 // Include the auto-generated part of this file. We split this because it means
19728 // we can easily edit the non-auto generated parts right here in this file 19747 // we can easily edit the non-auto generated parts right here in this file
19729 // instead of having to edit some template or the code generator. 19748 // instead of having to edit some template or the code generator.
19730 #include "base/macros.h" 19749 #include "base/macros.h"
19731 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 19750 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
19732 19751
19733 } // namespace gles2 19752 } // namespace gles2
19734 } // namespace gpu 19753 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698