| 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 #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 2699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2710 size, buffer_format, format); | 2710 size, buffer_format, format); |
| 2711 if (!image || !image->BindTexImage(Target())) | 2711 if (!image || !image->BindTexImage(Target())) |
| 2712 return false; | 2712 return false; |
| 2713 | 2713 |
| 2714 image_ = image; | 2714 image_ = image; |
| 2715 decoder_->texture_manager()->SetLevelInfo( | 2715 decoder_->texture_manager()->SetLevelInfo( |
| 2716 texture_ref_.get(), Target(), 0, image_->GetInternalFormat(), | 2716 texture_ref_.get(), Target(), 0, image_->GetInternalFormat(), |
| 2717 size.width(), size.height(), 1, 0, image_->GetInternalFormat(), | 2717 size.width(), size.height(), 1, 0, image_->GetInternalFormat(), |
| 2718 GL_UNSIGNED_BYTE, gfx::Rect(size)); | 2718 GL_UNSIGNED_BYTE, gfx::Rect(size)); |
| 2719 decoder_->texture_manager()->SetLevelImage(texture_ref_.get(), Target(), 0, | 2719 decoder_->texture_manager()->SetLevelImage(texture_ref_.get(), Target(), 0, |
| 2720 image_.get(), Texture::BOUND); | 2720 0, image_.get(), Texture::BOUND); |
| 2721 | 2721 |
| 2722 // Ignore the zero flag if the alpha channel needs to be cleared for RGB | 2722 // Ignore the zero flag if the alpha channel needs to be cleared for RGB |
| 2723 // emulation. | 2723 // emulation. |
| 2724 bool needs_clear_for_rgb_emulation = | 2724 bool needs_clear_for_rgb_emulation = |
| 2725 !decoder_->offscreen_buffer_should_have_alpha_ && | 2725 !decoder_->offscreen_buffer_should_have_alpha_ && |
| 2726 decoder_->ChromiumImageNeedsRGBEmulation(); | 2726 decoder_->ChromiumImageNeedsRGBEmulation(); |
| 2727 if (zero || needs_clear_for_rgb_emulation) { | 2727 if (zero || needs_clear_for_rgb_emulation) { |
| 2728 GLuint fbo; | 2728 GLuint fbo; |
| 2729 glGenFramebuffersEXT(1, &fbo); | 2729 glGenFramebuffersEXT(1, &fbo); |
| 2730 { | 2730 { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2745 void BackTexture::DestroyNativeGpuMemoryBuffer(bool have_context) { | 2745 void BackTexture::DestroyNativeGpuMemoryBuffer(bool have_context) { |
| 2746 if (image_) { | 2746 if (image_) { |
| 2747 ScopedGLErrorSuppressor suppressor( | 2747 ScopedGLErrorSuppressor suppressor( |
| 2748 "BackTexture::DestroyNativeGpuMemoryBuffer", | 2748 "BackTexture::DestroyNativeGpuMemoryBuffer", |
| 2749 decoder_->state_.GetErrorState()); | 2749 decoder_->state_.GetErrorState()); |
| 2750 | 2750 |
| 2751 image_->ReleaseTexImage(Target()); | 2751 image_->ReleaseTexImage(Target()); |
| 2752 image_->Destroy(have_context); | 2752 image_->Destroy(have_context); |
| 2753 | 2753 |
| 2754 decoder_->texture_manager()->SetLevelImage(texture_ref_.get(), Target(), 0, | 2754 decoder_->texture_manager()->SetLevelImage(texture_ref_.get(), Target(), 0, |
| 2755 nullptr, Texture::UNBOUND); | 2755 0, nullptr, Texture::UNBOUND); |
| 2756 image_ = nullptr; | 2756 image_ = nullptr; |
| 2757 } | 2757 } |
| 2758 } | 2758 } |
| 2759 | 2759 |
| 2760 BackRenderbuffer::BackRenderbuffer(GLES2DecoderImpl* decoder) | 2760 BackRenderbuffer::BackRenderbuffer(GLES2DecoderImpl* decoder) |
| 2761 : decoder_(decoder), | 2761 : decoder_(decoder), |
| 2762 memory_tracker_(decoder->memory_tracker()), | 2762 memory_tracker_(decoder->memory_tracker()), |
| 2763 bytes_allocated_(0), | 2763 bytes_allocated_(0), |
| 2764 id_(0) {} | 2764 id_(0) {} |
| 2765 | 2765 |
| (...skipping 5788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8554 GLint fake_location, | 8554 GLint fake_location, |
| 8555 GLboolean transpose, | 8555 GLboolean transpose, |
| 8556 const GLfloat* transform) { | 8556 const GLfloat* transform) { |
| 8557 float gl_matrix[16]; | 8557 float gl_matrix[16]; |
| 8558 | 8558 |
| 8559 // This refers to the bound external texture on the active unit. | 8559 // This refers to the bound external texture on the active unit. |
| 8560 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; | 8560 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; |
| 8561 if (TextureRef* texture_ref = unit.bound_texture_external_oes.get()) { | 8561 if (TextureRef* texture_ref = unit.bound_texture_external_oes.get()) { |
| 8562 if (GLStreamTextureImage* image = | 8562 if (GLStreamTextureImage* image = |
| 8563 texture_ref->texture()->GetLevelStreamTextureImage( | 8563 texture_ref->texture()->GetLevelStreamTextureImage( |
| 8564 GL_TEXTURE_EXTERNAL_OES, 0)) { | 8564 GL_TEXTURE_EXTERNAL_OES, 0, 0)) { |
| 8565 gfx::Transform st_transform(gfx::Transform::kSkipInitialization); | 8565 gfx::Transform st_transform(gfx::Transform::kSkipInitialization); |
| 8566 gfx::Transform pre_transform(gfx::Transform::kSkipInitialization); | 8566 gfx::Transform pre_transform(gfx::Transform::kSkipInitialization); |
| 8567 image->GetTextureMatrix(gl_matrix); | 8567 image->GetTextureMatrix(gl_matrix); |
| 8568 st_transform.matrix().setColMajorf(gl_matrix); | 8568 st_transform.matrix().setColMajorf(gl_matrix); |
| 8569 pre_transform.matrix().setColMajorf(transform); | 8569 pre_transform.matrix().setColMajorf(transform); |
| 8570 gfx::Transform(pre_transform, st_transform) | 8570 gfx::Transform(pre_transform, st_transform) |
| 8571 .matrix() | 8571 .matrix() |
| 8572 .asColMajorf(gl_matrix); | 8572 .asColMajorf(gl_matrix); |
| 8573 } else { | 8573 } else { |
| 8574 // Missing stream texture. Treat matrix as identity. | 8574 // Missing stream texture. Treat matrix as identity. |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8740 std::string("PERFORMANCE WARNING: ") + msg); | 8740 std::string("PERFORMANCE WARNING: ") + msg); |
| 8741 } | 8741 } |
| 8742 | 8742 |
| 8743 void GLES2DecoderImpl::DoCopyTexImage(Texture* texture, | 8743 void GLES2DecoderImpl::DoCopyTexImage(Texture* texture, |
| 8744 GLenum textarget, | 8744 GLenum textarget, |
| 8745 gl::GLImage* image) { | 8745 gl::GLImage* image) { |
| 8746 // Note: We update the state to COPIED prior to calling CopyTexImage() | 8746 // Note: We update the state to COPIED prior to calling CopyTexImage() |
| 8747 // as that allows the GLImage implemenatation to set it back to UNBOUND | 8747 // as that allows the GLImage implemenatation to set it back to UNBOUND |
| 8748 // and ensure that CopyTexImage() is called each time the texture is | 8748 // and ensure that CopyTexImage() is called each time the texture is |
| 8749 // used. | 8749 // used. |
| 8750 texture->SetLevelImageState(textarget, 0, Texture::COPIED); | 8750 texture->SetLevelImageState(textarget, 0, 0, Texture::COPIED); |
| 8751 bool rv = image->CopyTexImage(textarget); | 8751 bool rv = image->CopyTexImage(textarget); |
| 8752 DCHECK(rv) << "CopyTexImage() failed"; | 8752 DCHECK(rv) << "CopyTexImage() failed"; |
| 8753 } | 8753 } |
| 8754 | 8754 |
| 8755 void GLES2DecoderImpl::DoCopyTexImageIfNeeded(Texture* texture, | 8755 void GLES2DecoderImpl::DoCopyTexImageIfNeeded(Texture* texture, |
| 8756 GLenum textarget) { | 8756 GLenum textarget) { |
| 8757 // Image is already in use if texture is attached to a framebuffer. | 8757 // Image is already in use if texture is attached to a framebuffer. |
| 8758 if (texture && !texture->IsAttachedToFramebuffer()) { | 8758 if (texture && !texture->IsAttachedToFramebuffer()) { |
| 8759 Texture::ImageState image_state; | 8759 Texture::ImageState image_state; |
| 8760 gl::GLImage* image = texture->GetLevelImage(textarget, 0, &image_state); | 8760 gl::GLImage* image = texture->GetLevelImage(textarget, 0, 0, &image_state); |
| 8761 if (image && image_state == Texture::UNBOUND) { | 8761 if (image && image_state == Texture::UNBOUND) { |
| 8762 ScopedGLErrorSuppressor suppressor( | 8762 ScopedGLErrorSuppressor suppressor( |
| 8763 "GLES2DecoderImpl::DoCopyTexImageIfNeeded", GetErrorState()); | 8763 "GLES2DecoderImpl::DoCopyTexImageIfNeeded", GetErrorState()); |
| 8764 glBindTexture(textarget, texture->service_id()); | 8764 glBindTexture(textarget, texture->service_id()); |
| 8765 DoCopyTexImage(texture, textarget, image); | 8765 DoCopyTexImage(texture, textarget, image); |
| 8766 RestoreCurrentTextureBindings(&state_, textarget); | 8766 RestoreCurrentTextureBindings(&state_, textarget); |
| 8767 } | 8767 } |
| 8768 } | 8768 } |
| 8769 } | 8769 } |
| 8770 | 8770 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8805 " is not renderable. It maybe non-power-of-2 and have" | 8805 " is not renderable. It maybe non-power-of-2 and have" |
| 8806 " incompatible texture filtering."); | 8806 " incompatible texture filtering."); |
| 8807 } | 8807 } |
| 8808 continue; | 8808 continue; |
| 8809 } | 8809 } |
| 8810 | 8810 |
| 8811 if (textarget != GL_TEXTURE_CUBE_MAP) { | 8811 if (textarget != GL_TEXTURE_CUBE_MAP) { |
| 8812 Texture* texture = texture_ref->texture(); | 8812 Texture* texture = texture_ref->texture(); |
| 8813 Texture::ImageState image_state; | 8813 Texture::ImageState image_state; |
| 8814 gl::GLImage* image = | 8814 gl::GLImage* image = |
| 8815 texture->GetLevelImage(textarget, 0, &image_state); | 8815 texture->GetLevelImage(textarget, 0, 0, &image_state); |
| 8816 if (image && image_state == Texture::UNBOUND && | 8816 if (image && image_state == Texture::UNBOUND && |
| 8817 !texture->IsAttachedToFramebuffer()) { | 8817 !texture->IsAttachedToFramebuffer()) { |
| 8818 ScopedGLErrorSuppressor suppressor( | 8818 ScopedGLErrorSuppressor suppressor( |
| 8819 "GLES2DecoderImpl::PrepareTexturesForRender", GetErrorState()); | 8819 "GLES2DecoderImpl::PrepareTexturesForRender", GetErrorState()); |
| 8820 textures_set = true; | 8820 textures_set = true; |
| 8821 glActiveTexture(GL_TEXTURE0 + texture_unit_index); | 8821 glActiveTexture(GL_TEXTURE0 + texture_unit_index); |
| 8822 DoCopyTexImage(texture, textarget, image); | 8822 DoCopyTexImage(texture, textarget, image); |
| 8823 continue; | 8823 continue; |
| 8824 } | 8824 } |
| 8825 } | 8825 } |
| (...skipping 2080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10906 *static_cast<const gles2::cmds::ScheduleOverlayPlaneCHROMIUM*>(cmd_data); | 10906 *static_cast<const gles2::cmds::ScheduleOverlayPlaneCHROMIUM*>(cmd_data); |
| 10907 TextureRef* ref = texture_manager()->GetTexture(c.overlay_texture_id); | 10907 TextureRef* ref = texture_manager()->GetTexture(c.overlay_texture_id); |
| 10908 if (!ref) { | 10908 if (!ref) { |
| 10909 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, | 10909 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, |
| 10910 "glScheduleOverlayPlaneCHROMIUM", | 10910 "glScheduleOverlayPlaneCHROMIUM", |
| 10911 "unknown texture"); | 10911 "unknown texture"); |
| 10912 return error::kNoError; | 10912 return error::kNoError; |
| 10913 } | 10913 } |
| 10914 Texture::ImageState image_state; | 10914 Texture::ImageState image_state; |
| 10915 gl::GLImage* image = | 10915 gl::GLImage* image = |
| 10916 ref->texture()->GetLevelImage(ref->texture()->target(), 0, &image_state); | 10916 ref->texture()->GetLevelImage(ref->texture()->target(), 0, 0, |
| 10917 &image_state); |
| 10917 if (!image) { | 10918 if (!image) { |
| 10918 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, | 10919 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, |
| 10919 "glScheduleOverlayPlaneCHROMIUM", | 10920 "glScheduleOverlayPlaneCHROMIUM", |
| 10920 "unsupported texture format"); | 10921 "unsupported texture format"); |
| 10921 return error::kNoError; | 10922 return error::kNoError; |
| 10922 } | 10923 } |
| 10923 gfx::OverlayTransform transform = GetGFXOverlayTransform(c.plane_transform); | 10924 gfx::OverlayTransform transform = GetGFXOverlayTransform(c.plane_transform); |
| 10924 if (transform == gfx::OVERLAY_TRANSFORM_INVALID) { | 10925 if (transform == gfx::OVERLAY_TRANSFORM_INVALID) { |
| 10925 LOCAL_SET_GL_ERROR(GL_INVALID_ENUM, | 10926 LOCAL_SET_GL_ERROR(GL_INVALID_ENUM, |
| 10926 "glScheduleOverlayPlaneCHROMIUM", | 10927 "glScheduleOverlayPlaneCHROMIUM", |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10989 GLuint contents_texture_id = c.contents_texture_id; | 10990 GLuint contents_texture_id = c.contents_texture_id; |
| 10990 if (contents_texture_id) { | 10991 if (contents_texture_id) { |
| 10991 TextureRef* ref = texture_manager()->GetTexture(contents_texture_id); | 10992 TextureRef* ref = texture_manager()->GetTexture(contents_texture_id); |
| 10992 if (!ref) { | 10993 if (!ref) { |
| 10993 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScheduleCALayerCHROMIUM", | 10994 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScheduleCALayerCHROMIUM", |
| 10994 "unknown texture"); | 10995 "unknown texture"); |
| 10995 return error::kNoError; | 10996 return error::kNoError; |
| 10996 } | 10997 } |
| 10997 Texture::ImageState image_state; | 10998 Texture::ImageState image_state; |
| 10998 image = ref->texture()->GetLevelImage(ref->texture()->target(), 0, | 10999 image = ref->texture()->GetLevelImage(ref->texture()->target(), 0, |
| 10999 &image_state); | 11000 0, &image_state); |
| 11000 if (!image) { | 11001 if (!image) { |
| 11001 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScheduleCALayerCHROMIUM", | 11002 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glScheduleCALayerCHROMIUM", |
| 11002 "unsupported texture format"); | 11003 "unsupported texture format"); |
| 11003 return error::kNoError; | 11004 return error::kNoError; |
| 11004 } | 11005 } |
| 11005 } | 11006 } |
| 11006 | 11007 |
| 11007 const GLfloat* mem = GetSharedMemoryAs<const GLfloat*>(c.shm_id, c.shm_offset, | 11008 const GLfloat* mem = GetSharedMemoryAs<const GLfloat*>(c.shm_id, c.shm_offset, |
| 11008 8 * sizeof(GLfloat)); | 11009 8 * sizeof(GLfloat)); |
| 11009 if (!mem) { | 11010 if (!mem) { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11074 if (texture_id) { | 11075 if (texture_id) { |
| 11075 TextureRef* ref = texture_manager()->GetTexture(texture_id); | 11076 TextureRef* ref = texture_manager()->GetTexture(texture_id); |
| 11076 if (!ref) { | 11077 if (!ref) { |
| 11077 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, | 11078 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, |
| 11078 "glScheduleCALayerInUseQueryCHROMIUM", | 11079 "glScheduleCALayerInUseQueryCHROMIUM", |
| 11079 "unknown texture"); | 11080 "unknown texture"); |
| 11080 return; | 11081 return; |
| 11081 } | 11082 } |
| 11082 Texture::ImageState image_state; | 11083 Texture::ImageState image_state; |
| 11083 image = ref->texture()->GetLevelImage(ref->texture()->target(), 0, | 11084 image = ref->texture()->GetLevelImage(ref->texture()->target(), 0, |
| 11084 &image_state); | 11085 0, &image_state); |
| 11085 } | 11086 } |
| 11086 gl::GLSurface::CALayerInUseQuery query; | 11087 gl::GLSurface::CALayerInUseQuery query; |
| 11087 query.image = image; | 11088 query.image = image; |
| 11088 query.texture = texture_id; | 11089 query.texture = texture_id; |
| 11089 queries.push_back(query); | 11090 queries.push_back(query); |
| 11090 } | 11091 } |
| 11091 | 11092 |
| 11092 surface_->ScheduleCALayerInUseQuery(std::move(queries)); | 11093 surface_->ScheduleCALayerInUseQuery(std::move(queries)); |
| 11093 } | 11094 } |
| 11094 | 11095 |
| (...skipping 1719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12814 } | 12815 } |
| 12815 | 12816 |
| 12816 if (!ValidateCompressedTexFuncData("glCompressedTexSubImage2D", width, height, | 12817 if (!ValidateCompressedTexFuncData("glCompressedTexSubImage2D", width, height, |
| 12817 1, format, image_size, data) || | 12818 1, format, image_size, data) || |
| 12818 !ValidateCompressedTexSubDimensions("glCompressedTexSubImage2D", target, | 12819 !ValidateCompressedTexSubDimensions("glCompressedTexSubImage2D", target, |
| 12819 level, xoffset, yoffset, 0, width, | 12820 level, xoffset, yoffset, 0, width, |
| 12820 height, 1, format, texture)) { | 12821 height, 1, format, texture)) { |
| 12821 return; | 12822 return; |
| 12822 } | 12823 } |
| 12823 | 12824 |
| 12824 if (!texture->IsLevelCleared(target, level)) { | 12825 if (!texture->IsLevelCleared(target, level, 0)) { |
| 12825 // This can only happen if the compressed texture was allocated | 12826 // This can only happen if the compressed texture was allocated |
| 12826 // using TexStorage2D. | 12827 // using TexStorage2D. |
| 12827 DCHECK(texture->IsImmutable()); | 12828 DCHECK(texture->IsImmutable()); |
| 12828 GLsizei level_width = 0, level_height = 0; | 12829 GLsizei level_width = 0, level_height = 0; |
| 12829 bool success = texture->GetLevelSize( | 12830 bool success = texture->GetLevelSize( |
| 12830 target, level, &level_width, &level_height, nullptr); | 12831 target, level, &level_width, &level_height, nullptr); |
| 12831 DCHECK(success); | 12832 DCHECK(success); |
| 12832 // We can skip the clear if we're uploading the entire level. | 12833 // We can skip the clear if we're uploading the entire level. |
| 12833 if (xoffset == 0 && yoffset == 0 && | 12834 if (xoffset == 0 && yoffset == 0 && |
| 12834 width == level_width && height == level_height) { | 12835 width == level_width && height == level_height) { |
| 12835 texture_manager()->SetLevelCleared(texture_ref, target, level, true); | 12836 texture_manager()->SetLevelCleared(texture_ref, target, level, 0, true); |
| 12836 } else { | 12837 } else { |
| 12837 texture_manager()->ClearTextureLevel(this, texture_ref, target, level); | 12838 texture_manager()->ClearTextureLevel(this, texture_ref, target, level); |
| 12838 } | 12839 } |
| 12839 DCHECK(texture->IsLevelCleared(target, level)); | 12840 DCHECK(texture->IsLevelCleared(target, level, 0)); |
| 12840 } | 12841 } |
| 12841 | 12842 |
| 12842 const CompressedFormatInfo* format_info = | 12843 const CompressedFormatInfo* format_info = |
| 12843 GetCompressedFormatInfo(internal_format); | 12844 GetCompressedFormatInfo(internal_format); |
| 12844 if (format_info != nullptr && !format_info->support_check(*feature_info_)) { | 12845 if (format_info != nullptr && !format_info->support_check(*feature_info_)) { |
| 12845 std::unique_ptr<uint8_t[]> decompressed_data = DecompressTextureData( | 12846 std::unique_ptr<uint8_t[]> decompressed_data = DecompressTextureData( |
| 12846 state_, *format_info, width, height, 1, image_size, data); | 12847 state_, *format_info, width, height, 1, image_size, data); |
| 12847 if (!decompressed_data) { | 12848 if (!decompressed_data) { |
| 12848 MarkContextLost(error::kGuilty); | 12849 MarkContextLost(error::kGuilty); |
| 12849 group_->LoseContexts(error::kInnocent); | 12850 group_->LoseContexts(error::kInnocent); |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13205 Clip(y, height, size.height(), ©Y, ©Height); | 13206 Clip(y, height, size.height(), ©Y, ©Height); |
| 13206 | 13207 |
| 13207 GLint dx = copyX - x; | 13208 GLint dx = copyX - x; |
| 13208 GLint dy = copyY - y; | 13209 GLint dy = copyY - y; |
| 13209 GLint destX = xoffset + dx; | 13210 GLint destX = xoffset + dx; |
| 13210 GLint destY = yoffset + dy; | 13211 GLint destY = yoffset + dy; |
| 13211 if (destX != 0 || destY != 0 || copyWidth != size.width() || | 13212 if (destX != 0 || destY != 0 || copyWidth != size.width() || |
| 13212 copyHeight != size.height()) { | 13213 copyHeight != size.height()) { |
| 13213 gfx::Rect cleared_rect; | 13214 gfx::Rect cleared_rect; |
| 13214 if (TextureManager::CombineAdjacentRects( | 13215 if (TextureManager::CombineAdjacentRects( |
| 13215 texture->GetLevelClearedRect(target, level), | 13216 texture->GetLevelClearedRect(target, level, 0), |
| 13216 gfx::Rect(destX, destY, copyWidth, copyHeight), &cleared_rect)) { | 13217 gfx::Rect(destX, destY, copyWidth, copyHeight), &cleared_rect)) { |
| 13217 DCHECK_GE(cleared_rect.size().GetArea(), | 13218 DCHECK_GE(cleared_rect.size().GetArea(), |
| 13218 texture->GetLevelClearedRect(target, level).size().GetArea()); | 13219 texture->GetLevelClearedRect(target, level, 0) |
| 13219 texture_manager()->SetLevelClearedRect(texture_ref, target, level, | 13220 .size().GetArea()); |
| 13221 texture_manager()->SetLevelClearedRect(texture_ref, target, level, 0, |
| 13220 cleared_rect); | 13222 cleared_rect); |
| 13221 } else { | 13223 } else { |
| 13222 // Otherwise clear part of texture level that is not already cleared. | 13224 // Otherwise clear part of texture level that is not already cleared. |
| 13223 if (!texture_manager()->ClearTextureLevel(this, texture_ref, target, | 13225 if (!texture_manager()->ClearTextureLevel(this, texture_ref, target, |
| 13224 level)) { | 13226 level)) { |
| 13225 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, func_name, "dimensions too big"); | 13227 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, func_name, "dimensions too big"); |
| 13226 return; | 13228 return; |
| 13227 } | 13229 } |
| 13228 } | 13230 } |
| 13229 } else { | 13231 } else { |
| 13230 // Write all pixels in below. | 13232 // Write all pixels in below. |
| 13231 texture_manager()->SetLevelCleared(texture_ref, target, level, true); | 13233 texture_manager()->SetLevelCleared(texture_ref, target, level, 0, true); |
| 13232 } | 13234 } |
| 13233 | 13235 |
| 13234 if (copyHeight > 0 && copyWidth > 0) { | 13236 if (copyHeight > 0 && copyWidth > 0) { |
| 13235 if (CopyTexImageResourceManager::CopyTexImageRequiresBlit( | 13237 if (CopyTexImageResourceManager::CopyTexImageRequiresBlit( |
| 13236 feature_info_.get(), internal_format)) { | 13238 feature_info_.get(), internal_format)) { |
| 13237 if (!InitializeCopyTexImageBlitter("glCopyTexSubImage2D")) { | 13239 if (!InitializeCopyTexImageBlitter("glCopyTexSubImage2D")) { |
| 13238 return; | 13240 return; |
| 13239 } | 13241 } |
| 13240 copy_tex_image_blit_->DoCopyTexSubImage2DToLUMAComatabilityTexture( | 13242 copy_tex_image_blit_->DoCopyTexSubImage2DToLUMAComatabilityTexture( |
| 13241 this, texture->service_id(), texture->target(), target, | 13243 this, texture->service_id(), texture->target(), target, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13295 return; | 13297 return; |
| 13296 } | 13298 } |
| 13297 | 13299 |
| 13298 if (FormsTextureCopyingFeedbackLoop(texture_ref, level, zoffset)) { | 13300 if (FormsTextureCopyingFeedbackLoop(texture_ref, level, zoffset)) { |
| 13299 LOCAL_SET_GL_ERROR( | 13301 LOCAL_SET_GL_ERROR( |
| 13300 GL_INVALID_OPERATION, | 13302 GL_INVALID_OPERATION, |
| 13301 func_name, "source and destination textures are the same"); | 13303 func_name, "source and destination textures are the same"); |
| 13302 return; | 13304 return; |
| 13303 } | 13305 } |
| 13304 | 13306 |
| 13307 ScopedResolvedFrameBufferBinder binder(this, false, true); |
| 13308 gfx::Size size = GetBoundReadFrameBufferSize(); |
| 13309 GLint copyX = 0; |
| 13310 GLint copyY = 0; |
| 13311 GLint copyWidth = 0; |
| 13312 GLint copyHeight = 0; |
| 13313 Clip(x, width, size.width(), ©X, ©Width); |
| 13314 Clip(y, height, size.height(), ©Y, ©Height); |
| 13315 |
| 13316 GLint dx = copyX - x; |
| 13317 GLint dy = copyY - y; |
| 13318 GLint destX = xoffset + dx; |
| 13319 GLint destY = yoffset + dy; |
| 13320 if (destX != 0 || destY != 0 || copyWidth != size.width() || |
| 13321 copyHeight != size.height()) { |
| 13322 gfx::Rect cleared_rect; |
| 13323 if (TextureManager::CombineAdjacentRects( |
| 13324 texture->GetLevelClearedRect(target, level, zoffset), |
| 13325 gfx::Rect(destX, destY, copyWidth, copyHeight), &cleared_rect)) { |
| 13326 DCHECK_GE(cleared_rect.size().GetArea(), |
| 13327 texture->GetLevelClearedRect(target, level, zoffset) |
| 13328 .size().GetArea()); |
| 13329 texture_manager()->SetLevelClearedRect(texture_ref, target, level, |
| 13330 zoffset, cleared_rect); |
| 13331 } else { |
| 13332 // Otherwise clear part of texture level that is not already cleared. |
| 13333 if (!texture_manager()->ClearTextureLevel(this, texture_ref, target, |
| 13334 level)) { |
| 13335 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, func_name, "dimensions too big"); |
| 13336 return; |
| 13337 } |
| 13338 } |
| 13339 } else { |
| 13340 // Write all pixels in below. |
| 13341 texture_manager()->SetLevelCleared(texture_ref, target, |
| 13342 level, zoffset, true); |
| 13343 } |
| 13344 |
| 13305 // TODO(yunchao): Follow-up CLs are necessary. For instance: | 13345 // TODO(yunchao): Follow-up CLs are necessary. For instance: |
| 13306 // 1. emulation of unsized formats in core profile | 13346 // 1. emulation of unsized formats in core profile |
| 13307 // 2. clear the 3d textures if it is uncleared. | 13347 // 2. out-of-bounds reading, etc. |
| 13308 // 3. out-of-bounds reading, etc. | |
| 13309 | 13348 |
| 13310 glCopyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y, width, | 13349 glCopyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y, width, |
| 13311 height); | 13350 height); |
| 13312 | 13351 |
| 13313 // This may be a slow command. Exit command processing to allow for | 13352 // This may be a slow command. Exit command processing to allow for |
| 13314 // context preemption and GPU watchdog checks. | 13353 // context preemption and GPU watchdog checks. |
| 13315 ExitCommandProcessingEarly(); | 13354 ExitCommandProcessingEarly(); |
| 13316 } | 13355 } |
| 13317 | 13356 |
| 13318 error::Error GLES2DecoderImpl::HandleTexSubImage2D(uint32_t immediate_data_size, | 13357 error::Error GLES2DecoderImpl::HandleTexSubImage2D(uint32_t immediate_data_size, |
| (...skipping 1823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15142 return; | 15181 return; |
| 15143 } | 15182 } |
| 15144 | 15183 |
| 15145 Texture* source_texture = source_texture_ref->texture(); | 15184 Texture* source_texture = source_texture_ref->texture(); |
| 15146 Texture* dest_texture = dest_texture_ref->texture(); | 15185 Texture* dest_texture = dest_texture_ref->texture(); |
| 15147 GLenum source_target = source_texture->target(); | 15186 GLenum source_target = source_texture->target(); |
| 15148 GLenum dest_target = dest_texture->target(); | 15187 GLenum dest_target = dest_texture->target(); |
| 15149 int source_width = 0; | 15188 int source_width = 0; |
| 15150 int source_height = 0; | 15189 int source_height = 0; |
| 15151 gl::GLImage* image = | 15190 gl::GLImage* image = |
| 15152 source_texture->GetLevelImage(source_target, 0); | 15191 source_texture->GetLevelImage(source_target, 0, 0); |
| 15153 if (image) { | 15192 if (image) { |
| 15154 gfx::Size size = image->GetSize(); | 15193 gfx::Size size = image->GetSize(); |
| 15155 source_width = size.width(); | 15194 source_width = size.width(); |
| 15156 source_height = size.height(); | 15195 source_height = size.height(); |
| 15157 if (source_width <= 0 || source_height <= 0) { | 15196 if (source_width <= 0 || source_height <= 0) { |
| 15158 LOCAL_SET_GL_ERROR( | 15197 LOCAL_SET_GL_ERROR( |
| 15159 GL_INVALID_VALUE, | 15198 GL_INVALID_VALUE, |
| 15160 "glCopyTextureChromium", "invalid image size"); | 15199 "glCopyTextureChromium", "invalid image size"); |
| 15161 return; | 15200 return; |
| 15162 } | 15201 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15229 RestoreCurrentTextureBindings(&state_, dest_target); | 15268 RestoreCurrentTextureBindings(&state_, dest_target); |
| 15230 return; | 15269 return; |
| 15231 } | 15270 } |
| 15232 | 15271 |
| 15233 texture_manager()->SetLevelInfo( | 15272 texture_manager()->SetLevelInfo( |
| 15234 dest_texture_ref, dest_target, 0, internal_format, source_width, | 15273 dest_texture_ref, dest_target, 0, internal_format, source_width, |
| 15235 source_height, 1, 0, internal_format, dest_type, | 15274 source_height, 1, 0, internal_format, dest_type, |
| 15236 gfx::Rect(source_width, source_height)); | 15275 gfx::Rect(source_width, source_height)); |
| 15237 dest_texture->ApplyFormatWorkarounds(feature_info_.get()); | 15276 dest_texture->ApplyFormatWorkarounds(feature_info_.get()); |
| 15238 } else { | 15277 } else { |
| 15239 texture_manager()->SetLevelCleared(dest_texture_ref, dest_target, 0, | 15278 texture_manager()->SetLevelCleared(dest_texture_ref, dest_target, |
| 15240 true); | 15279 0, 0, true); |
| 15241 } | 15280 } |
| 15242 | 15281 |
| 15243 // Try using GLImage::CopyTexImage when possible. | 15282 // Try using GLImage::CopyTexImage when possible. |
| 15244 bool unpack_premultiply_alpha_change = | 15283 bool unpack_premultiply_alpha_change = |
| 15245 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; | 15284 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; |
| 15246 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) { | 15285 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) { |
| 15247 glBindTexture(dest_target, dest_texture->service_id()); | 15286 glBindTexture(dest_target, dest_texture->service_id()); |
| 15248 if (image->CopyTexImage(dest_target)) | 15287 if (image->CopyTexImage(dest_target)) |
| 15249 return; | 15288 return; |
| 15250 } | 15289 } |
| 15251 | 15290 |
| 15252 DoCopyTexImageIfNeeded(source_texture, source_target); | 15291 DoCopyTexImageIfNeeded(source_texture, source_target); |
| 15253 | 15292 |
| 15254 // GL_TEXTURE_EXTERNAL_OES texture requires that we apply a transform matrix | 15293 // GL_TEXTURE_EXTERNAL_OES texture requires that we apply a transform matrix |
| 15255 // before presenting. | 15294 // before presenting. |
| 15256 if (source_target == GL_TEXTURE_EXTERNAL_OES) { | 15295 if (source_target == GL_TEXTURE_EXTERNAL_OES) { |
| 15257 if (GLStreamTextureImage* image = | 15296 if (GLStreamTextureImage* image = |
| 15258 source_texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES, | 15297 source_texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES, |
| 15259 0)) { | 15298 0, 0)) { |
| 15260 GLfloat transform_matrix[16]; | 15299 GLfloat transform_matrix[16]; |
| 15261 image->GetTextureMatrix(transform_matrix); | 15300 image->GetTextureMatrix(transform_matrix); |
| 15262 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( | 15301 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( |
| 15263 this, source_target, source_texture->service_id(), dest_target, | 15302 this, source_target, source_texture->service_id(), dest_target, |
| 15264 dest_texture->service_id(), source_width, source_height, | 15303 dest_texture->service_id(), source_width, source_height, |
| 15265 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, | 15304 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, |
| 15266 unpack_unmultiply_alpha == GL_TRUE, transform_matrix); | 15305 unpack_unmultiply_alpha == GL_TRUE, transform_matrix); |
| 15267 return; | 15306 return; |
| 15268 } | 15307 } |
| 15269 } | 15308 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 15297 return; | 15336 return; |
| 15298 } | 15337 } |
| 15299 | 15338 |
| 15300 Texture* source_texture = source_texture_ref->texture(); | 15339 Texture* source_texture = source_texture_ref->texture(); |
| 15301 Texture* dest_texture = dest_texture_ref->texture(); | 15340 Texture* dest_texture = dest_texture_ref->texture(); |
| 15302 GLenum source_target = source_texture->target(); | 15341 GLenum source_target = source_texture->target(); |
| 15303 GLenum dest_target = dest_texture->target(); | 15342 GLenum dest_target = dest_texture->target(); |
| 15304 int source_width = 0; | 15343 int source_width = 0; |
| 15305 int source_height = 0; | 15344 int source_height = 0; |
| 15306 gl::GLImage* image = | 15345 gl::GLImage* image = |
| 15307 source_texture->GetLevelImage(source_target, 0); | 15346 source_texture->GetLevelImage(source_target, 0, 0); |
| 15308 if (image) { | 15347 if (image) { |
| 15309 gfx::Size size = image->GetSize(); | 15348 gfx::Size size = image->GetSize(); |
| 15310 source_width = size.width(); | 15349 source_width = size.width(); |
| 15311 source_height = size.height(); | 15350 source_height = size.height(); |
| 15312 if (source_width <= 0 || source_height <= 0) { | 15351 if (source_width <= 0 || source_height <= 0) { |
| 15313 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "invalid image size"); | 15352 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "invalid image size"); |
| 15314 return; | 15353 return; |
| 15315 } | 15354 } |
| 15316 | 15355 |
| 15317 // Ideally we should not need to check that the sub-texture copy rectangle | 15356 // Ideally we should not need to check that the sub-texture copy rectangle |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15391 | 15430 |
| 15392 int dest_width = 0; | 15431 int dest_width = 0; |
| 15393 int dest_height = 0; | 15432 int dest_height = 0; |
| 15394 bool ok = dest_texture->GetLevelSize( | 15433 bool ok = dest_texture->GetLevelSize( |
| 15395 dest_target, 0, &dest_width, &dest_height, nullptr); | 15434 dest_target, 0, &dest_width, &dest_height, nullptr); |
| 15396 DCHECK(ok); | 15435 DCHECK(ok); |
| 15397 if (xoffset != 0 || yoffset != 0 || width != dest_width || | 15436 if (xoffset != 0 || yoffset != 0 || width != dest_width || |
| 15398 height != dest_height) { | 15437 height != dest_height) { |
| 15399 gfx::Rect cleared_rect; | 15438 gfx::Rect cleared_rect; |
| 15400 if (TextureManager::CombineAdjacentRects( | 15439 if (TextureManager::CombineAdjacentRects( |
| 15401 dest_texture->GetLevelClearedRect(dest_target, 0), | 15440 dest_texture->GetLevelClearedRect(dest_target, 0, 0), |
| 15402 gfx::Rect(xoffset, yoffset, width, height), &cleared_rect)) { | 15441 gfx::Rect(xoffset, yoffset, width, height), &cleared_rect)) { |
| 15403 DCHECK_GE( | 15442 DCHECK_GE( |
| 15404 cleared_rect.size().GetArea(), | 15443 cleared_rect.size().GetArea(), |
| 15405 dest_texture->GetLevelClearedRect(dest_target, 0).size().GetArea()); | 15444 dest_texture->GetLevelClearedRect(dest_target, 0, 0).size() |
| 15445 .GetArea()); |
| 15406 texture_manager()->SetLevelClearedRect(dest_texture_ref, dest_target, 0, | 15446 texture_manager()->SetLevelClearedRect(dest_texture_ref, dest_target, 0, |
| 15407 cleared_rect); | 15447 0, cleared_rect); |
| 15408 } else { | 15448 } else { |
| 15409 // Otherwise clear part of texture level that is not already cleared. | 15449 // Otherwise clear part of texture level that is not already cleared. |
| 15410 if (!texture_manager()->ClearTextureLevel(this, dest_texture_ref, | 15450 if (!texture_manager()->ClearTextureLevel(this, dest_texture_ref, |
| 15411 dest_target, 0)) { | 15451 dest_target, 0)) { |
| 15412 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, kFunctionName, | 15452 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, kFunctionName, |
| 15413 "destination texture dimensions too big"); | 15453 "destination texture dimensions too big"); |
| 15414 return; | 15454 return; |
| 15415 } | 15455 } |
| 15416 } | 15456 } |
| 15417 } else { | 15457 } else { |
| 15418 texture_manager()->SetLevelCleared(dest_texture_ref, dest_target, 0, | 15458 texture_manager()->SetLevelCleared(dest_texture_ref, dest_target, |
| 15419 true); | 15459 0, 0, true); |
| 15420 } | 15460 } |
| 15421 | 15461 |
| 15422 // Try using GLImage::CopyTexSubImage when possible. | 15462 // Try using GLImage::CopyTexSubImage when possible. |
| 15423 bool unpack_premultiply_alpha_change = | 15463 bool unpack_premultiply_alpha_change = |
| 15424 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; | 15464 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; |
| 15425 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) { | 15465 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) { |
| 15426 ScopedTextureBinder binder( | 15466 ScopedTextureBinder binder( |
| 15427 &state_, dest_texture->service_id(), dest_target); | 15467 &state_, dest_texture->service_id(), dest_target); |
| 15428 if (image->CopyTexSubImage(dest_target, gfx::Point(xoffset, yoffset), | 15468 if (image->CopyTexSubImage(dest_target, gfx::Point(xoffset, yoffset), |
| 15429 gfx::Rect(x, y, width, height))) { | 15469 gfx::Rect(x, y, width, height))) { |
| 15430 return; | 15470 return; |
| 15431 } | 15471 } |
| 15432 } | 15472 } |
| 15433 | 15473 |
| 15434 DoCopyTexImageIfNeeded(source_texture, source_target); | 15474 DoCopyTexImageIfNeeded(source_texture, source_target); |
| 15435 | 15475 |
| 15436 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix | 15476 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix |
| 15437 // before presenting. | 15477 // before presenting. |
| 15438 if (source_target == GL_TEXTURE_EXTERNAL_OES) { | 15478 if (source_target == GL_TEXTURE_EXTERNAL_OES) { |
| 15439 if (GLStreamTextureImage* image = | 15479 if (GLStreamTextureImage* image = |
| 15440 source_texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES, | 15480 source_texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES, |
| 15441 0)) { | 15481 0, 0)) { |
| 15442 GLfloat transform_matrix[16]; | 15482 GLfloat transform_matrix[16]; |
| 15443 image->GetTextureMatrix(transform_matrix); | 15483 image->GetTextureMatrix(transform_matrix); |
| 15444 copy_texture_CHROMIUM_->DoCopySubTextureWithTransform( | 15484 copy_texture_CHROMIUM_->DoCopySubTextureWithTransform( |
| 15445 this, source_target, source_texture->service_id(), | 15485 this, source_target, source_texture->service_id(), |
| 15446 source_internal_format, dest_target, dest_texture->service_id(), | 15486 source_internal_format, dest_target, dest_texture->service_id(), |
| 15447 dest_internal_format, xoffset, yoffset, x, y, width, height, | 15487 dest_internal_format, xoffset, yoffset, x, y, width, height, |
| 15448 dest_width, dest_height, source_width, source_height, | 15488 dest_width, dest_height, source_width, source_height, |
| 15449 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, | 15489 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, |
| 15450 unpack_unmultiply_alpha == GL_TRUE, transform_matrix); | 15490 unpack_unmultiply_alpha == GL_TRUE, transform_matrix); |
| 15451 return; | 15491 return; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15501 if (!ValidateCompressedCopyTextureCHROMIUM(kFunctionName, source_texture_ref, | 15541 if (!ValidateCompressedCopyTextureCHROMIUM(kFunctionName, source_texture_ref, |
| 15502 dest_texture_ref)) { | 15542 dest_texture_ref)) { |
| 15503 return; | 15543 return; |
| 15504 } | 15544 } |
| 15505 | 15545 |
| 15506 Texture* source_texture = source_texture_ref->texture(); | 15546 Texture* source_texture = source_texture_ref->texture(); |
| 15507 Texture* dest_texture = dest_texture_ref->texture(); | 15547 Texture* dest_texture = dest_texture_ref->texture(); |
| 15508 int source_width = 0; | 15548 int source_width = 0; |
| 15509 int source_height = 0; | 15549 int source_height = 0; |
| 15510 gl::GLImage* image = | 15550 gl::GLImage* image = |
| 15511 source_texture->GetLevelImage(source_texture->target(), 0); | 15551 source_texture->GetLevelImage(source_texture->target(), 0, 0); |
| 15512 if (image) { | 15552 if (image) { |
| 15513 gfx::Size size = image->GetSize(); | 15553 gfx::Size size = image->GetSize(); |
| 15514 source_width = size.width(); | 15554 source_width = size.width(); |
| 15515 source_height = size.height(); | 15555 source_height = size.height(); |
| 15516 if (source_width <= 0 || source_height <= 0) { | 15556 if (source_width <= 0 || source_height <= 0) { |
| 15517 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "invalid image size"); | 15557 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "invalid image size"); |
| 15518 return; | 15558 return; |
| 15519 } | 15559 } |
| 15520 } else { | 15560 } else { |
| 15521 if (!source_texture->GetLevelSize(source_texture->target(), 0, | 15561 if (!source_texture->GetLevelSize(source_texture->target(), 0, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15592 RestoreCurrentTextureBindings(&state_, dest_texture->target()); | 15632 RestoreCurrentTextureBindings(&state_, dest_texture->target()); |
| 15593 return; | 15633 return; |
| 15594 } | 15634 } |
| 15595 | 15635 |
| 15596 texture_manager()->SetLevelInfo( | 15636 texture_manager()->SetLevelInfo( |
| 15597 dest_texture_ref, dest_texture->target(), 0, source_internal_format, | 15637 dest_texture_ref, dest_texture->target(), 0, source_internal_format, |
| 15598 source_width, source_height, 1, 0, source_internal_format, | 15638 source_width, source_height, 1, 0, source_internal_format, |
| 15599 source_type, gfx::Rect(source_width, source_height)); | 15639 source_type, gfx::Rect(source_width, source_height)); |
| 15600 } else { | 15640 } else { |
| 15601 texture_manager()->SetLevelCleared( | 15641 texture_manager()->SetLevelCleared( |
| 15602 dest_texture_ref, dest_texture->target(), 0, true); | 15642 dest_texture_ref, dest_texture->target(), 0, 0, true); |
| 15603 } | 15643 } |
| 15604 | 15644 |
| 15605 if (image->CopyTexImage(dest_texture->target())) | 15645 if (image->CopyTexImage(dest_texture->target())) |
| 15606 return; | 15646 return; |
| 15607 } | 15647 } |
| 15608 | 15648 |
| 15609 TRACE_EVENT0( | 15649 TRACE_EVENT0( |
| 15610 "gpu", | 15650 "gpu", |
| 15611 "GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM, fallback"); | 15651 "GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM, fallback"); |
| 15612 | 15652 |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16073 // when BindTexImage() fails. | 16113 // when BindTexImage() fails. |
| 16074 if (image->BindTexImage(target)) | 16114 if (image->BindTexImage(target)) |
| 16075 image_state = Texture::BOUND; | 16115 image_state = Texture::BOUND; |
| 16076 } | 16116 } |
| 16077 | 16117 |
| 16078 gfx::Size size = image->GetSize(); | 16118 gfx::Size size = image->GetSize(); |
| 16079 GLenum internalformat = image->GetInternalFormat(); | 16119 GLenum internalformat = image->GetInternalFormat(); |
| 16080 texture_manager()->SetLevelInfo( | 16120 texture_manager()->SetLevelInfo( |
| 16081 texture_ref, target, 0, internalformat, size.width(), size.height(), 1, 0, | 16121 texture_ref, target, 0, internalformat, size.width(), size.height(), 1, 0, |
| 16082 internalformat, GL_UNSIGNED_BYTE, gfx::Rect(size)); | 16122 internalformat, GL_UNSIGNED_BYTE, gfx::Rect(size)); |
| 16083 texture_manager()->SetLevelImage(texture_ref, target, 0, image, image_state); | 16123 texture_manager()->SetLevelImage(texture_ref, target, 0, 0, |
| 16124 image, image_state); |
| 16084 } | 16125 } |
| 16085 | 16126 |
| 16086 void GLES2DecoderImpl::DoReleaseTexImage2DCHROMIUM( | 16127 void GLES2DecoderImpl::DoReleaseTexImage2DCHROMIUM( |
| 16087 GLenum target, GLint image_id) { | 16128 GLenum target, GLint image_id) { |
| 16088 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoReleaseTexImage2DCHROMIUM"); | 16129 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoReleaseTexImage2DCHROMIUM"); |
| 16089 | 16130 |
| 16090 // Default target might be conceptually valid, but disallow it to avoid | 16131 // Default target might be conceptually valid, but disallow it to avoid |
| 16091 // accidents. | 16132 // accidents. |
| 16092 TextureRef* texture_ref = | 16133 TextureRef* texture_ref = |
| 16093 texture_manager()->GetTextureInfoForTargetUnlessDefault(&state_, target); | 16134 texture_manager()->GetTextureInfoForTargetUnlessDefault(&state_, target); |
| 16094 if (!texture_ref) { | 16135 if (!texture_ref) { |
| 16095 LOCAL_SET_GL_ERROR( | 16136 LOCAL_SET_GL_ERROR( |
| 16096 GL_INVALID_OPERATION, | 16137 GL_INVALID_OPERATION, |
| 16097 "glReleaseTexImage2DCHROMIUM", "no texture bound"); | 16138 "glReleaseTexImage2DCHROMIUM", "no texture bound"); |
| 16098 return; | 16139 return; |
| 16099 } | 16140 } |
| 16100 | 16141 |
| 16101 gl::GLImage* image = image_manager()->LookupImage(image_id); | 16142 gl::GLImage* image = image_manager()->LookupImage(image_id); |
| 16102 if (!image) { | 16143 if (!image) { |
| 16103 LOCAL_SET_GL_ERROR( | 16144 LOCAL_SET_GL_ERROR( |
| 16104 GL_INVALID_OPERATION, | 16145 GL_INVALID_OPERATION, |
| 16105 "glReleaseTexImage2DCHROMIUM", "no image found with the given ID"); | 16146 "glReleaseTexImage2DCHROMIUM", "no image found with the given ID"); |
| 16106 return; | 16147 return; |
| 16107 } | 16148 } |
| 16108 | 16149 |
| 16109 Texture::ImageState image_state; | 16150 Texture::ImageState image_state; |
| 16110 | 16151 |
| 16111 // Do nothing when image is not currently bound. | 16152 // Do nothing when image is not currently bound. |
| 16112 if (texture_ref->texture()->GetLevelImage(target, 0, &image_state) != image) | 16153 if (texture_ref->texture()->GetLevelImage(target, 0, 0, &image_state) |
| 16154 != image) |
| 16113 return; | 16155 return; |
| 16114 | 16156 |
| 16115 if (image_state == Texture::BOUND) { | 16157 if (image_state == Texture::BOUND) { |
| 16116 ScopedGLErrorSuppressor suppressor( | 16158 ScopedGLErrorSuppressor suppressor( |
| 16117 "GLES2DecoderImpl::DoReleaseTexImage2DCHROMIUM", GetErrorState()); | 16159 "GLES2DecoderImpl::DoReleaseTexImage2DCHROMIUM", GetErrorState()); |
| 16118 | 16160 |
| 16119 image->ReleaseTexImage(target); | 16161 image->ReleaseTexImage(target); |
| 16120 texture_manager()->SetLevelInfo(texture_ref, target, 0, GL_RGBA, 0, 0, 1, 0, | 16162 texture_manager()->SetLevelInfo(texture_ref, target, 0, GL_RGBA, 0, 0, 1, 0, |
| 16121 GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect()); | 16163 GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect()); |
| 16122 } | 16164 } |
| 16123 | 16165 |
| 16124 texture_manager()->SetLevelImage(texture_ref, target, 0, nullptr, | 16166 texture_manager()->SetLevelImage(texture_ref, target, 0, 0, nullptr, |
| 16125 Texture::UNBOUND); | 16167 Texture::UNBOUND); |
| 16126 } | 16168 } |
| 16127 | 16169 |
| 16128 error::Error GLES2DecoderImpl::HandleTraceBeginCHROMIUM( | 16170 error::Error GLES2DecoderImpl::HandleTraceBeginCHROMIUM( |
| 16129 uint32_t immediate_data_size, | 16171 uint32_t immediate_data_size, |
| 16130 const void* cmd_data) { | 16172 const void* cmd_data) { |
| 16131 const gles2::cmds::TraceBeginCHROMIUM& c = | 16173 const gles2::cmds::TraceBeginCHROMIUM& c = |
| 16132 *static_cast<const gles2::cmds::TraceBeginCHROMIUM*>(cmd_data); | 16174 *static_cast<const gles2::cmds::TraceBeginCHROMIUM*>(cmd_data); |
| 16133 Bucket* category_bucket = GetBucket(c.category_bucket_id); | 16175 Bucket* category_bucket = GetBucket(c.category_bucket_id); |
| 16134 Bucket* name_bucket = GetBucket(c.name_bucket_id); | 16176 Bucket* name_bucket = GetBucket(c.name_bucket_id); |
| (...skipping 1623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17758 } | 17800 } |
| 17759 | 17801 |
| 17760 // Include the auto-generated part of this file. We split this because it means | 17802 // Include the auto-generated part of this file. We split this because it means |
| 17761 // we can easily edit the non-auto generated parts right here in this file | 17803 // we can easily edit the non-auto generated parts right here in this file |
| 17762 // instead of having to edit some template or the code generator. | 17804 // instead of having to edit some template or the code generator. |
| 17763 #include "base/macros.h" | 17805 #include "base/macros.h" |
| 17764 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 17806 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 17765 | 17807 |
| 17766 } // namespace gles2 | 17808 } // namespace gles2 |
| 17767 } // namespace gpu | 17809 } // namespace gpu |
| OLD | NEW |