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

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

Issue 1154053002: gpu: Use a rectangle to keep track of the cleared area of each texture level. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: v2 Created 5 years, 6 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
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 <stdio.h> 7 #include <stdio.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 bool ClearUnclearedTextures(); 1263 bool ClearUnclearedTextures();
1264 1264
1265 // Clears any uncleared attachments attached to the given frame buffer. 1265 // Clears any uncleared attachments attached to the given frame buffer.
1266 // Returns false if there was a generated GL error. 1266 // Returns false if there was a generated GL error.
1267 void ClearUnclearedAttachments(GLenum target, Framebuffer* framebuffer); 1267 void ClearUnclearedAttachments(GLenum target, Framebuffer* framebuffer);
1268 1268
1269 // overridden from GLES2Decoder 1269 // overridden from GLES2Decoder
1270 bool ClearLevel(Texture* texture, 1270 bool ClearLevel(Texture* texture,
1271 unsigned target, 1271 unsigned target,
1272 int level, 1272 int level,
1273 unsigned internal_format,
1274 unsigned format, 1273 unsigned format,
1275 unsigned type, 1274 unsigned type,
1275 int xoffset,
1276 int yoffset,
1276 int width, 1277 int width,
1277 int height, 1278 int height) override;
1278 bool is_texture_immutable) override;
1279 1279
1280 // Restore all GL state that affects clearing. 1280 // Restore all GL state that affects clearing.
1281 void RestoreClearState(); 1281 void RestoreClearState();
1282 1282
1283 // Remembers the state of some capabilities. 1283 // Remembers the state of some capabilities.
1284 // Returns: true if glEnable/glDisable should actually be called. 1284 // Returns: true if glEnable/glDisable should actually be called.
1285 bool SetCapabilityState(GLenum cap, bool enabled); 1285 bool SetCapabilityState(GLenum cap, bool enabled);
1286 1286
1287 // Check that the currently bound framebuffers are valid. 1287 // Check that the currently bound framebuffers are valid.
1288 // Generates GL error if not. 1288 // Generates GL error if not.
(...skipping 2254 matching lines...) Expand 10 before | Expand all | Expand 10 after
3543 3543
3544 GLenum completeness = framebuffer->IsPossiblyComplete(); 3544 GLenum completeness = framebuffer->IsPossiblyComplete();
3545 if (completeness != GL_FRAMEBUFFER_COMPLETE) { 3545 if (completeness != GL_FRAMEBUFFER_COMPLETE) {
3546 LOCAL_SET_GL_ERROR( 3546 LOCAL_SET_GL_ERROR(
3547 GL_INVALID_FRAMEBUFFER_OPERATION, func_name, "framebuffer incomplete"); 3547 GL_INVALID_FRAMEBUFFER_OPERATION, func_name, "framebuffer incomplete");
3548 return false; 3548 return false;
3549 } 3549 }
3550 3550
3551 // Are all the attachments cleared? 3551 // Are all the attachments cleared?
3552 if (renderbuffer_manager()->HaveUnclearedRenderbuffers() || 3552 if (renderbuffer_manager()->HaveUnclearedRenderbuffers() ||
3553 texture_manager()->HaveUnclearedMips()) { 3553 texture_manager()->HaveUnsafeTextures()) {
3554 if (!framebuffer->IsCleared()) { 3554 if (!framebuffer->IsCleared()) {
3555 // Can we clear them? 3555 // Can we clear them?
3556 if (framebuffer->GetStatus(texture_manager(), target) != 3556 if (framebuffer->GetStatus(texture_manager(), target) !=
3557 GL_FRAMEBUFFER_COMPLETE) { 3557 GL_FRAMEBUFFER_COMPLETE) {
3558 LOCAL_SET_GL_ERROR( 3558 LOCAL_SET_GL_ERROR(
3559 GL_INVALID_FRAMEBUFFER_OPERATION, func_name, 3559 GL_INVALID_FRAMEBUFFER_OPERATION, func_name,
3560 "framebuffer incomplete (clear)"); 3560 "framebuffer incomplete (clear)");
3561 return false; 3561 return false;
3562 } 3562 }
3563 ClearUnclearedAttachments(target, framebuffer); 3563 ClearUnclearedAttachments(target, framebuffer);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
3678 return back_buffer_color_format_; 3678 return back_buffer_color_format_;
3679 } 3679 }
3680 } 3680 }
3681 3681
3682 void GLES2DecoderImpl::UpdateParentTextureInfo() { 3682 void GLES2DecoderImpl::UpdateParentTextureInfo() {
3683 if (!offscreen_saved_color_texture_info_.get()) 3683 if (!offscreen_saved_color_texture_info_.get())
3684 return; 3684 return;
3685 GLenum target = offscreen_saved_color_texture_info_->texture()->target(); 3685 GLenum target = offscreen_saved_color_texture_info_->texture()->target();
3686 glBindTexture(target, offscreen_saved_color_texture_info_->service_id()); 3686 glBindTexture(target, offscreen_saved_color_texture_info_->service_id());
3687 texture_manager()->SetLevelInfo( 3687 texture_manager()->SetLevelInfo(
3688 offscreen_saved_color_texture_info_.get(), 3688 offscreen_saved_color_texture_info_.get(), GL_TEXTURE_2D,
3689 GL_TEXTURE_2D,
3690 0, // level 3689 0, // level
3691 GL_RGBA, 3690 GL_RGBA, offscreen_size_.width(), offscreen_size_.height(),
3692 offscreen_size_.width(),
3693 offscreen_size_.height(),
3694 1, // depth 3691 1, // depth
3695 0, // border 3692 0, // border
3696 GL_RGBA, 3693 GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(offscreen_size_));
3697 GL_UNSIGNED_BYTE,
3698 true);
3699 texture_manager()->SetParameteri( 3694 texture_manager()->SetParameteri(
3700 "UpdateParentTextureInfo", 3695 "UpdateParentTextureInfo",
3701 GetErrorState(), 3696 GetErrorState(),
3702 offscreen_saved_color_texture_info_.get(), 3697 offscreen_saved_color_texture_info_.get(),
3703 GL_TEXTURE_MAG_FILTER, 3698 GL_TEXTURE_MAG_FILTER,
3704 GL_LINEAR); 3699 GL_LINEAR);
3705 texture_manager()->SetParameteri( 3700 texture_manager()->SetParameteri(
3706 "UpdateParentTextureInfo", 3701 "UpdateParentTextureInfo",
3707 GetErrorState(), 3702 GetErrorState(),
3708 offscreen_saved_color_texture_info_.get(), 3703 offscreen_saved_color_texture_info_.get(),
(...skipping 5148 matching lines...) Expand 10 before | Expand all | Expand 10 after
8857 return error::kNoError; 8852 return error::kNoError;
8858 } 8853 }
8859 8854
8860 void GLES2DecoderImpl::DoBufferSubData( 8855 void GLES2DecoderImpl::DoBufferSubData(
8861 GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data) { 8856 GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data) {
8862 // Just delegate it. Some validation is actually done before this. 8857 // Just delegate it. Some validation is actually done before this.
8863 buffer_manager()->ValidateAndDoBufferSubData( 8858 buffer_manager()->ValidateAndDoBufferSubData(
8864 &state_, target, offset, size, data); 8859 &state_, target, offset, size, data);
8865 } 8860 }
8866 8861
8867 bool GLES2DecoderImpl::ClearLevel( 8862 bool GLES2DecoderImpl::ClearLevel(Texture* texture,
8868 Texture* texture, 8863 unsigned target,
8869 unsigned target, 8864 int level,
8870 int level, 8865 unsigned format,
8871 unsigned internal_format, 8866 unsigned type,
8872 unsigned format, 8867 int xoffset,
8873 unsigned type, 8868 int yoffset,
8874 int width, 8869 int width,
8875 int height, 8870 int height) {
8876 bool is_texture_immutable) {
8877 uint32 channels = GLES2Util::GetChannelsForFormat(format); 8871 uint32 channels = GLES2Util::GetChannelsForFormat(format);
8878 if (feature_info_->feature_flags().angle_depth_texture && 8872 if (feature_info_->feature_flags().angle_depth_texture &&
8879 (channels & GLES2Util::kDepth) != 0) { 8873 (channels & GLES2Util::kDepth) != 0 && xoffset == 0 && yoffset == 0) {
8880 // It's a depth format and ANGLE doesn't allow texImage2D or texSubImage2D 8874 // It's a depth format and ANGLE doesn't allow texImage2D or texSubImage2D
8881 // on depth formats. 8875 // on depth formats.
8882 GLuint fb = 0; 8876 GLuint fb = 0;
8883 glGenFramebuffersEXT(1, &fb); 8877 glGenFramebuffersEXT(1, &fb);
8884 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fb); 8878 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fb);
8885 8879
8886 bool have_stencil = (channels & GLES2Util::kStencil) != 0; 8880 bool have_stencil = (channels & GLES2Util::kStencil) != 0;
8887 GLenum attachment = have_stencil ? GL_DEPTH_STENCIL_ATTACHMENT : 8881 GLenum attachment = have_stencil ? GL_DEPTH_STENCIL_ATTACHMENT :
8888 GL_DEPTH_ATTACHMENT; 8882 GL_DEPTH_ATTACHMENT;
8889 8883
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
8942 } 8936 }
8943 } else { 8937 } else {
8944 tile_height = height; 8938 tile_height = height;
8945 } 8939 }
8946 8940
8947 // Assumes the size has already been checked. 8941 // Assumes the size has already been checked.
8948 scoped_ptr<char[]> zero(new char[size]); 8942 scoped_ptr<char[]> zero(new char[size]);
8949 memset(zero.get(), 0, size); 8943 memset(zero.get(), 0, size);
8950 glBindTexture(texture->target(), texture->service_id()); 8944 glBindTexture(texture->target(), texture->service_id());
8951 8945
8952 bool has_images = texture->HasImages();
8953 GLint y = 0; 8946 GLint y = 0;
8954 while (y < height) { 8947 while (y < height) {
8955 GLint h = y + tile_height > height ? height - y : tile_height; 8948 GLint h = y + tile_height > height ? height - y : tile_height;
8956 if (is_texture_immutable || h != height || has_images) { 8949 glTexSubImage2D(target, level, xoffset, yoffset + y, width, h, format, type,
8957 glTexSubImage2D(target, level, 0, y, width, h, format, type, zero.get()); 8950 zero.get());
8958 } else {
8959 glTexImage2D(
8960 target, level, internal_format, width, h, 0, format, type,
8961 zero.get());
8962 }
8963 y += tile_height; 8951 y += tile_height;
8964 } 8952 }
8965 TextureRef* bound_texture = 8953 TextureRef* bound_texture =
8966 texture_manager()->GetTextureInfoForTarget(&state_, texture->target()); 8954 texture_manager()->GetTextureInfoForTarget(&state_, texture->target());
8967 glBindTexture(texture->target(), 8955 glBindTexture(texture->target(),
8968 bound_texture ? bound_texture->service_id() : 0); 8956 bound_texture ? bound_texture->service_id() : 0);
8969 return true; 8957 return true;
8970 } 8958 }
8971 8959
8972 namespace { 8960 namespace {
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
9313 if (!data) { 9301 if (!data) {
9314 zero.reset(new int8[image_size]); 9302 zero.reset(new int8[image_size]);
9315 memset(zero.get(), 0, image_size); 9303 memset(zero.get(), 0, image_size);
9316 data = zero.get(); 9304 data = zero.get();
9317 } 9305 }
9318 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedTexImage2D"); 9306 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedTexImage2D");
9319 glCompressedTexImage2D( 9307 glCompressedTexImage2D(
9320 target, level, internal_format, width, height, border, image_size, data); 9308 target, level, internal_format, width, height, border, image_size, data);
9321 GLenum error = LOCAL_PEEK_GL_ERROR("glCompressedTexImage2D"); 9309 GLenum error = LOCAL_PEEK_GL_ERROR("glCompressedTexImage2D");
9322 if (error == GL_NO_ERROR) { 9310 if (error == GL_NO_ERROR) {
9323 texture_manager()->SetLevelInfo( 9311 texture_manager()->SetLevelInfo(texture_ref, target, level, internal_format,
9324 texture_ref, target, level, internal_format, 9312 width, height, 1, border, 0, 0,
9325 width, height, 1, border, 0, 0, true); 9313 gfx::Rect(width, height));
9326 } 9314 }
9327 9315
9328 // This may be a slow command. Exit command processing to allow for 9316 // This may be a slow command. Exit command processing to allow for
9329 // context preemption and GPU watchdog checks. 9317 // context preemption and GPU watchdog checks.
9330 ExitCommandProcessingEarly(); 9318 ExitCommandProcessingEarly();
9331 return error::kNoError; 9319 return error::kNoError;
9332 } 9320 }
9333 9321
9334 error::Error GLES2DecoderImpl::HandleCompressedTexImage2D( 9322 error::Error GLES2DecoderImpl::HandleCompressedTexImage2D(
9335 uint32 immediate_data_size, 9323 uint32 immediate_data_size,
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
9500 if (!data) { 9488 if (!data) {
9501 zero.reset(new int8[image_size]); 9489 zero.reset(new int8[image_size]);
9502 memset(zero.get(), 0, image_size); 9490 memset(zero.get(), 0, image_size);
9503 data = zero.get(); 9491 data = zero.get();
9504 } 9492 }
9505 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedTexImage3D"); 9493 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedTexImage3D");
9506 glCompressedTexImage3D(target, level, internal_format, width, height, depth, 9494 glCompressedTexImage3D(target, level, internal_format, width, height, depth,
9507 border, image_size, data); 9495 border, image_size, data);
9508 GLenum error = LOCAL_PEEK_GL_ERROR("glCompressedTexImage3D"); 9496 GLenum error = LOCAL_PEEK_GL_ERROR("glCompressedTexImage3D");
9509 if (error == GL_NO_ERROR) { 9497 if (error == GL_NO_ERROR) {
9510 texture_manager()->SetLevelInfo( 9498 texture_manager()->SetLevelInfo(texture_ref, target, level, internal_format,
9511 texture_ref, target, level, internal_format, 9499 width, height, depth, border, 0, 0,
9512 width, height, depth, border, 0, 0, true); 9500 gfx::Rect(width, height));
9513 } 9501 }
9514 9502
9515 // This may be a slow command. Exit command processing to allow for 9503 // This may be a slow command. Exit command processing to allow for
9516 // context preemption and GPU watchdog checks. 9504 // context preemption and GPU watchdog checks.
9517 ExitCommandProcessingEarly(); 9505 ExitCommandProcessingEarly();
9518 return error::kNoError; 9506 return error::kNoError;
9519 } 9507 }
9520 9508
9521 error::Error GLES2DecoderImpl::HandleCompressedTexImage3D( 9509 error::Error GLES2DecoderImpl::HandleCompressedTexImage3D(
9522 uint32 immediate_data_size, const void* cmd_data) { 9510 uint32 immediate_data_size, const void* cmd_data) {
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
9956 GLint copyWidth = 0; 9944 GLint copyWidth = 0;
9957 GLint copyHeight = 0; 9945 GLint copyHeight = 0;
9958 Clip(x, width, size.width(), &copyX, &copyWidth); 9946 Clip(x, width, size.width(), &copyX, &copyWidth);
9959 Clip(y, height, size.height(), &copyY, &copyHeight); 9947 Clip(y, height, size.height(), &copyY, &copyHeight);
9960 9948
9961 if (copyX != x || 9949 if (copyX != x ||
9962 copyY != y || 9950 copyY != y ||
9963 copyWidth != width || 9951 copyWidth != width ||
9964 copyHeight != height) { 9952 copyHeight != height) {
9965 // some part was clipped so clear the texture. 9953 // some part was clipped so clear the texture.
9966 if (!ClearLevel(texture, target, level, internal_format, internal_format, 9954 if (!ClearLevel(texture, target, level, internal_format, GL_UNSIGNED_BYTE,
9967 GL_UNSIGNED_BYTE, width, height, texture->IsImmutable())) { 9955 0, 0, width, height)) {
9968 LOCAL_SET_GL_ERROR( 9956 LOCAL_SET_GL_ERROR(
9969 GL_OUT_OF_MEMORY, "glCopyTexImage2D", "dimensions too big"); 9957 GL_OUT_OF_MEMORY, "glCopyTexImage2D", "dimensions too big");
9970 return; 9958 return;
9971 } 9959 }
9972 if (copyHeight > 0 && copyWidth > 0) { 9960 if (copyHeight > 0 && copyWidth > 0) {
9973 GLint dx = copyX - x; 9961 GLint dx = copyX - x;
9974 GLint dy = copyY - y; 9962 GLint dy = copyY - y;
9975 GLint destX = dx; 9963 GLint destX = dx;
9976 GLint destY = dy; 9964 GLint destY = dy;
9977 ScopedModifyPixels modify(texture_ref); 9965 ScopedModifyPixels modify(texture_ref);
9978 glCopyTexSubImage2D(target, level, 9966 glCopyTexSubImage2D(target, level,
9979 destX, destY, copyX, copyY, 9967 destX, destY, copyX, copyY,
9980 copyWidth, copyHeight); 9968 copyWidth, copyHeight);
9981 } 9969 }
9982 } else { 9970 } else {
9983 ScopedModifyPixels modify(texture_ref); 9971 ScopedModifyPixels modify(texture_ref);
9984 glCopyTexImage2D(target, level, internal_format, 9972 glCopyTexImage2D(target, level, internal_format,
9985 copyX, copyY, copyWidth, copyHeight, border); 9973 copyX, copyY, copyWidth, copyHeight, border);
9986 } 9974 }
9987 GLenum error = LOCAL_PEEK_GL_ERROR("glCopyTexImage2D"); 9975 GLenum error = LOCAL_PEEK_GL_ERROR("glCopyTexImage2D");
9988 if (error == GL_NO_ERROR) { 9976 if (error == GL_NO_ERROR) {
9989 texture_manager()->SetLevelInfo( 9977 texture_manager()->SetLevelInfo(texture_ref, target, level, internal_format,
9990 texture_ref, target, level, internal_format, width, height, 1, 9978 width, height, 1, border, internal_format,
9991 border, internal_format, GL_UNSIGNED_BYTE, true); 9979 GL_UNSIGNED_BYTE, gfx::Rect(width, height));
9992 } 9980 }
9993 9981
9994 // This may be a slow command. Exit command processing to allow for 9982 // This may be a slow command. Exit command processing to allow for
9995 // context preemption and GPU watchdog checks. 9983 // context preemption and GPU watchdog checks.
9996 ExitCommandProcessingEarly(); 9984 ExitCommandProcessingEarly();
9997 } 9985 }
9998 9986
9999 void GLES2DecoderImpl::DoCopyTexSubImage2D( 9987 void GLES2DecoderImpl::DoCopyTexSubImage2D(
10000 GLenum target, 9988 GLenum target,
10001 GLint level, 9989 GLint level,
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
10069 gfx::Size size = GetBoundReadFrameBufferSize(); 10057 gfx::Size size = GetBoundReadFrameBufferSize();
10070 GLint copyX = 0; 10058 GLint copyX = 0;
10071 GLint copyY = 0; 10059 GLint copyY = 0;
10072 GLint copyWidth = 0; 10060 GLint copyWidth = 0;
10073 GLint copyHeight = 0; 10061 GLint copyHeight = 0;
10074 Clip(x, width, size.width(), &copyX, &copyWidth); 10062 Clip(x, width, size.width(), &copyX, &copyWidth);
10075 Clip(y, height, size.height(), &copyY, &copyHeight); 10063 Clip(y, height, size.height(), &copyY, &copyHeight);
10076 10064
10077 if (xoffset != 0 || yoffset != 0 || width != size.width() || 10065 if (xoffset != 0 || yoffset != 0 || width != size.width() ||
10078 height != size.height()) { 10066 height != size.height()) {
10067 // TODO(reveman): Use SetLevelClearedRect when possible instead of clearing
10068 // the texture prematurely.
10079 if (!texture_manager()->ClearTextureLevel(this, texture_ref, target, 10069 if (!texture_manager()->ClearTextureLevel(this, texture_ref, target,
10080 level)) { 10070 level)) {
10081 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopyTexSubImage2D", 10071 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopyTexSubImage2D",
10082 "dimensions too big"); 10072 "dimensions too big");
10083 return; 10073 return;
10084 } 10074 }
10085 } else { 10075 } else {
10086 // Write all pixels in below. 10076 // Write all pixels in below.
10087 texture_manager()->SetLevelCleared(texture_ref, target, level, true); 10077 texture_manager()->SetLevelCleared(texture_ref, target, level, true);
10088 } 10078 }
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
10218 TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget( 10208 TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget(
10219 &state_, target); 10209 &state_, target);
10220 Texture* texture = texture_ref->texture(); 10210 Texture* texture = texture_ref->texture();
10221 GLsizei tex_width = 0; 10211 GLsizei tex_width = 0;
10222 GLsizei tex_height = 0; 10212 GLsizei tex_height = 0;
10223 bool ok = texture->GetLevelSize( 10213 bool ok = texture->GetLevelSize(
10224 target, level, &tex_width, &tex_height, nullptr); 10214 target, level, &tex_width, &tex_height, nullptr);
10225 DCHECK(ok); 10215 DCHECK(ok);
10226 if (xoffset != 0 || yoffset != 0 || 10216 if (xoffset != 0 || yoffset != 0 ||
10227 width != tex_width || height != tex_height) { 10217 width != tex_width || height != tex_height) {
10218 // TODO(reveman): Use SetLevelClearedRect when possible instead of clearing
10219 // the texture prematurely.
10228 if (!texture_manager()->ClearTextureLevel(this, texture_ref, 10220 if (!texture_manager()->ClearTextureLevel(this, texture_ref,
10229 target, level)) { 10221 target, level)) {
10230 LOCAL_SET_GL_ERROR( 10222 LOCAL_SET_GL_ERROR(
10231 GL_OUT_OF_MEMORY, "glTexSubImage2D", "dimensions too big"); 10223 GL_OUT_OF_MEMORY, "glTexSubImage2D", "dimensions too big");
10232 return error::kNoError; 10224 return error::kNoError;
10233 } 10225 }
10234 ScopedTextureUploadTimer timer(&texture_state_); 10226 ScopedTextureUploadTimer timer(&texture_state_);
10235 glTexSubImage2D( 10227 glTexSubImage2D(
10236 target, level, xoffset, yoffset, width, height, format, type, data); 10228 target, level, xoffset, yoffset, width, height, format, type, data);
10237 return error::kNoError; 10229 return error::kNoError;
(...skipping 1496 matching lines...) Expand 10 before | Expand all | Expand 10 after
11734 plane); 11726 plane);
11735 11727
11736 if (err != kCGLNoError) { 11728 if (err != kCGLNoError) {
11737 LOCAL_SET_GL_ERROR( 11729 LOCAL_SET_GL_ERROR(
11738 GL_INVALID_OPERATION, 11730 GL_INVALID_OPERATION,
11739 "glTexImageIOSurface2DCHROMIUM", "error in CGLTexImageIOSurface2D"); 11731 "glTexImageIOSurface2DCHROMIUM", "error in CGLTexImageIOSurface2D");
11740 return; 11732 return;
11741 } 11733 }
11742 11734
11743 texture_manager()->SetLevelInfo( 11735 texture_manager()->SetLevelInfo(
11744 texture_ref, target, 0, GL_RGBA, width, height, 1, 0, 11736 texture_ref, target, 0, GL_RGBA, width, height, 1, 0, GL_BGRA,
11745 GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, true); 11737 GL_UNSIGNED_INT_8_8_8_8_REV, gfx::Rect(width, height));
11746 11738
11747 #else 11739 #else
11748 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, 11740 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
11749 "glTexImageIOSurface2DCHROMIUM", "not supported."); 11741 "glTexImageIOSurface2DCHROMIUM", "not supported.");
11750 #endif 11742 #endif
11751 } 11743 }
11752 11744
11753 static GLenum ExtractFormatFromStorageFormat(GLenum internalformat) { 11745 static GLenum ExtractFormatFromStorageFormat(GLenum internalformat) {
11754 switch (internalformat) { 11746 switch (internalformat) {
11755 case GL_RGB565: 11747 case GL_RGB565:
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
11958 glTexImage2D(GL_TEXTURE_2D, 0, internal_format, source_width, source_height, 11950 glTexImage2D(GL_TEXTURE_2D, 0, internal_format, source_width, source_height,
11959 0, internal_format, dest_type, NULL); 11951 0, internal_format, dest_type, NULL);
11960 GLenum error = LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM"); 11952 GLenum error = LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM");
11961 if (error != GL_NO_ERROR) { 11953 if (error != GL_NO_ERROR) {
11962 RestoreCurrentTextureBindings(&state_, GL_TEXTURE_2D); 11954 RestoreCurrentTextureBindings(&state_, GL_TEXTURE_2D);
11963 return; 11955 return;
11964 } 11956 }
11965 11957
11966 texture_manager()->SetLevelInfo( 11958 texture_manager()->SetLevelInfo(
11967 dest_texture_ref, GL_TEXTURE_2D, 0, internal_format, source_width, 11959 dest_texture_ref, GL_TEXTURE_2D, 0, internal_format, source_width,
11968 source_height, 1, 0, internal_format, dest_type, true); 11960 source_height, 1, 0, internal_format, dest_type,
11961 gfx::Rect(source_width, source_height));
11969 } else { 11962 } else {
11970 texture_manager()->SetLevelCleared(dest_texture_ref, GL_TEXTURE_2D, 0, 11963 texture_manager()->SetLevelCleared(dest_texture_ref, GL_TEXTURE_2D, 0,
11971 true); 11964 true);
11972 } 11965 }
11973 11966
11974 ScopedModifyPixels modify(dest_texture_ref); 11967 ScopedModifyPixels modify(dest_texture_ref);
11975 11968
11976 // Try using GLImage::CopyTexSubImage when possible. 11969 // Try using GLImage::CopyTexSubImage when possible.
11977 bool unpack_premultiply_alpha_change = 11970 bool unpack_premultiply_alpha_change =
11978 unpack_premultiply_alpha_ ^ unpack_unpremultiply_alpha_; 11971 unpack_premultiply_alpha_ ^ unpack_unpremultiply_alpha_;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
12104 return; 12097 return;
12105 } 12098 }
12106 12099
12107 int dest_width = 0; 12100 int dest_width = 0;
12108 int dest_height = 0; 12101 int dest_height = 0;
12109 bool ok = dest_texture->GetLevelSize( 12102 bool ok = dest_texture->GetLevelSize(
12110 GL_TEXTURE_2D, 0, &dest_width, &dest_height, nullptr); 12103 GL_TEXTURE_2D, 0, &dest_width, &dest_height, nullptr);
12111 DCHECK(ok); 12104 DCHECK(ok);
12112 if (xoffset != 0 || yoffset != 0 || width != dest_width || 12105 if (xoffset != 0 || yoffset != 0 || width != dest_width ||
12113 height != dest_height) { 12106 height != dest_height) {
12114 if (!texture_manager()->ClearTextureLevel(this, dest_texture_ref, target, 12107 gfx::Rect cleared_rect(xoffset, yoffset, width, height);
12115 0)) { 12108 gfx::Rect level_cleared_rect = dest_texture->GetLevelClearedRect(target, 0);
12116 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopySubTextureCHROMIUM", 12109 // Try to grow cleared rectangle.
12117 "destination texture dimensions too big"); 12110 if (level_cleared_rect.IsEmpty() ||
12118 return; 12111 level_cleared_rect.SharesEdgeWith(cleared_rect)) {
12112 cleared_rect.Union(level_cleared_rect);
12113 texture_manager()->SetLevelClearedRect(dest_texture_ref, target, 0,
12114 cleared_rect);
12115 } else {
12116 // Otherwise clear part of texture level that is not already cleared.
12117 if (!texture_manager()->ClearTextureLevel(this, dest_texture_ref, target,
12118 0)) {
12119 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopySubTextureCHROMIUM",
12120 "destination texture dimensions too big");
12121 return;
12122 }
12119 } 12123 }
12120 } else { 12124 } else {
12121 texture_manager()->SetLevelCleared(dest_texture_ref, GL_TEXTURE_2D, 0, 12125 texture_manager()->SetLevelCleared(dest_texture_ref, GL_TEXTURE_2D, 0,
12122 true); 12126 true);
12123 } 12127 }
12124 12128
12125 ScopedModifyPixels modify(dest_texture_ref); 12129 ScopedModifyPixels modify(dest_texture_ref);
12126 12130
12127 // Try using GLImage::CopyTexSubImage when possible. 12131 // Try using GLImage::CopyTexSubImage when possible.
12128 bool unpack_premultiply_alpha_change = 12132 bool unpack_premultiply_alpha_change =
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
12254 } 12258 }
12255 } 12259 }
12256 12260
12257 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glTexStorage2DEXT"); 12261 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glTexStorage2DEXT");
12258 glTexStorage2DEXT(target, levels, internal_format, width, height); 12262 glTexStorage2DEXT(target, levels, internal_format, width, height);
12259 GLenum error = LOCAL_PEEK_GL_ERROR("glTexStorage2DEXT"); 12263 GLenum error = LOCAL_PEEK_GL_ERROR("glTexStorage2DEXT");
12260 if (error == GL_NO_ERROR) { 12264 if (error == GL_NO_ERROR) {
12261 GLsizei level_width = width; 12265 GLsizei level_width = width;
12262 GLsizei level_height = height; 12266 GLsizei level_height = height;
12263 for (int ii = 0; ii < levels; ++ii) { 12267 for (int ii = 0; ii < levels; ++ii) {
12264 texture_manager()->SetLevelInfo( 12268 texture_manager()->SetLevelInfo(texture_ref, target, ii, format,
12265 texture_ref, target, ii, format, 12269 level_width, level_height, 1, 0, format,
12266 level_width, level_height, 1, 0, format, type, false); 12270 type, gfx::Rect());
12267 level_width = std::max(1, level_width >> 1); 12271 level_width = std::max(1, level_width >> 1);
12268 level_height = std::max(1, level_height >> 1); 12272 level_height = std::max(1, level_height >> 1);
12269 } 12273 }
12270 texture->SetImmutable(true); 12274 texture->SetImmutable(true);
12271 } 12275 }
12272 } 12276 }
12273 12277
12274 error::Error GLES2DecoderImpl::HandleGenMailboxCHROMIUM( 12278 error::Error GLES2DecoderImpl::HandleGenMailboxCHROMIUM(
12275 uint32 immediate_data_size, 12279 uint32 immediate_data_size,
12276 const void* cmd_data) { 12280 const void* cmd_data) {
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
12606 if (!gl_image->BindTexImage(target)) { 12610 if (!gl_image->BindTexImage(target)) {
12607 LOCAL_SET_GL_ERROR( 12611 LOCAL_SET_GL_ERROR(
12608 GL_INVALID_OPERATION, 12612 GL_INVALID_OPERATION,
12609 "glBindTexImage2DCHROMIUM", "fail to bind image with the given ID"); 12613 "glBindTexImage2DCHROMIUM", "fail to bind image with the given ID");
12610 return; 12614 return;
12611 } 12615 }
12612 } 12616 }
12613 12617
12614 gfx::Size size = gl_image->GetSize(); 12618 gfx::Size size = gl_image->GetSize();
12615 texture_manager()->SetLevelInfo( 12619 texture_manager()->SetLevelInfo(
12616 texture_ref, target, 0, gl_image->GetInternalFormat(), 12620 texture_ref, target, 0, gl_image->GetInternalFormat(), size.width(),
12617 size.width(), size.height(), 1, 0, 12621 size.height(), 1, 0, gl_image->GetInternalFormat(), GL_UNSIGNED_BYTE,
12618 gl_image->GetInternalFormat(), GL_UNSIGNED_BYTE, true); 12622 gfx::Rect(size));
12619 texture_manager()->SetLevelImage(texture_ref, target, 0, gl_image); 12623 texture_manager()->SetLevelImage(texture_ref, target, 0, gl_image);
12620 } 12624 }
12621 12625
12622 void GLES2DecoderImpl::DoReleaseTexImage2DCHROMIUM( 12626 void GLES2DecoderImpl::DoReleaseTexImage2DCHROMIUM(
12623 GLenum target, GLint image_id) { 12627 GLenum target, GLint image_id) {
12624 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoReleaseTexImage2DCHROMIUM"); 12628 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoReleaseTexImage2DCHROMIUM");
12625 12629
12626 // Default target might be conceptually valid, but disallow it to avoid 12630 // Default target might be conceptually valid, but disallow it to avoid
12627 // accidents. 12631 // accidents.
12628 TextureRef* texture_ref = 12632 TextureRef* texture_ref =
(...skipping 18 matching lines...) Expand all
12647 return; 12651 return;
12648 12652
12649 { 12653 {
12650 ScopedGLErrorSuppressor suppressor( 12654 ScopedGLErrorSuppressor suppressor(
12651 "GLES2DecoderImpl::DoReleaseTexImage2DCHROMIUM", GetErrorState()); 12655 "GLES2DecoderImpl::DoReleaseTexImage2DCHROMIUM", GetErrorState());
12652 gl_image->ReleaseTexImage(target); 12656 gl_image->ReleaseTexImage(target);
12653 } 12657 }
12654 12658
12655 texture_manager()->SetLevelInfo( 12659 texture_manager()->SetLevelInfo(
12656 texture_ref, target, 0, gl_image->GetInternalFormat(), 0, 0, 1, 0, 12660 texture_ref, target, 0, gl_image->GetInternalFormat(), 0, 0, 1, 0,
12657 gl_image->GetInternalFormat(), GL_UNSIGNED_BYTE, false); 12661 gl_image->GetInternalFormat(), GL_UNSIGNED_BYTE, gfx::Rect());
12658 } 12662 }
12659 12663
12660 error::Error GLES2DecoderImpl::HandleTraceBeginCHROMIUM( 12664 error::Error GLES2DecoderImpl::HandleTraceBeginCHROMIUM(
12661 uint32 immediate_data_size, 12665 uint32 immediate_data_size,
12662 const void* cmd_data) { 12666 const void* cmd_data) {
12663 const gles2::cmds::TraceBeginCHROMIUM& c = 12667 const gles2::cmds::TraceBeginCHROMIUM& c =
12664 *static_cast<const gles2::cmds::TraceBeginCHROMIUM*>(cmd_data); 12668 *static_cast<const gles2::cmds::TraceBeginCHROMIUM*>(cmd_data);
12665 Bucket* category_bucket = GetBucket(c.category_bucket_id); 12669 Bucket* category_bucket = GetBucket(c.category_bucket_id);
12666 Bucket* name_bucket = GetBucket(c.name_bucket_id); 12670 Bucket* name_bucket = GetBucket(c.name_bucket_id);
12667 if (!category_bucket || category_bucket->size() == 0 || 12671 if (!category_bucket || category_bucket->size() == 0 ||
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
13294 } 13298 }
13295 } 13299 }
13296 13300
13297 // Include the auto-generated part of this file. We split this because it means 13301 // Include the auto-generated part of this file. We split this because it means
13298 // we can easily edit the non-auto generated parts right here in this file 13302 // we can easily edit the non-auto generated parts right here in this file
13299 // instead of having to edit some template or the code generator. 13303 // instead of having to edit some template or the code generator.
13300 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 13304 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
13301 13305
13302 } // namespace gles2 13306 } // namespace gles2
13303 } // namespace gpu 13307 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698