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

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

Issue 1119723003: Add glCopyCompressedTextureCHROMIUM (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase 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 30 matching lines...) Expand all
41 #include "gpu/command_buffer/service/error_state.h" 41 #include "gpu/command_buffer/service/error_state.h"
42 #include "gpu/command_buffer/service/feature_info.h" 42 #include "gpu/command_buffer/service/feature_info.h"
43 #include "gpu/command_buffer/service/framebuffer_manager.h" 43 #include "gpu/command_buffer/service/framebuffer_manager.h"
44 #include "gpu/command_buffer/service/gl_utils.h" 44 #include "gpu/command_buffer/service/gl_utils.h"
45 #include "gpu/command_buffer/service/gles2_cmd_clear_framebuffer.h" 45 #include "gpu/command_buffer/service/gles2_cmd_clear_framebuffer.h"
46 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" 46 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h"
47 #include "gpu/command_buffer/service/gles2_cmd_validation.h" 47 #include "gpu/command_buffer/service/gles2_cmd_validation.h"
48 #include "gpu/command_buffer/service/gpu_state_tracer.h" 48 #include "gpu/command_buffer/service/gpu_state_tracer.h"
49 #include "gpu/command_buffer/service/gpu_switches.h" 49 #include "gpu/command_buffer/service/gpu_switches.h"
50 #include "gpu/command_buffer/service/gpu_tracer.h" 50 #include "gpu/command_buffer/service/gpu_tracer.h"
51 #include "gpu/command_buffer/service/image_factory.h"
51 #include "gpu/command_buffer/service/image_manager.h" 52 #include "gpu/command_buffer/service/image_manager.h"
52 #include "gpu/command_buffer/service/mailbox_manager.h" 53 #include "gpu/command_buffer/service/mailbox_manager.h"
53 #include "gpu/command_buffer/service/memory_tracking.h" 54 #include "gpu/command_buffer/service/memory_tracking.h"
54 #include "gpu/command_buffer/service/program_manager.h" 55 #include "gpu/command_buffer/service/program_manager.h"
55 #include "gpu/command_buffer/service/query_manager.h" 56 #include "gpu/command_buffer/service/query_manager.h"
56 #include "gpu/command_buffer/service/renderbuffer_manager.h" 57 #include "gpu/command_buffer/service/renderbuffer_manager.h"
57 #include "gpu/command_buffer/service/shader_manager.h" 58 #include "gpu/command_buffer/service/shader_manager.h"
58 #include "gpu/command_buffer/service/shader_translator.h" 59 #include "gpu/command_buffer/service/shader_translator.h"
59 #include "gpu/command_buffer/service/shader_translator_cache.h" 60 #include "gpu/command_buffer/service/shader_translator_cache.h"
60 #include "gpu/command_buffer/service/texture_manager.h" 61 #include "gpu/command_buffer/service/texture_manager.h"
61 #include "gpu/command_buffer/service/valuebuffer_manager.h" 62 #include "gpu/command_buffer/service/valuebuffer_manager.h"
62 #include "gpu/command_buffer/service/vertex_array_manager.h" 63 #include "gpu/command_buffer/service/vertex_array_manager.h"
63 #include "gpu/command_buffer/service/vertex_attrib_manager.h" 64 #include "gpu/command_buffer/service/vertex_attrib_manager.h"
64 #include "third_party/smhasher/src/City.h" 65 #include "third_party/smhasher/src/City.h"
65 #include "ui/gl/gl_fence.h" 66 #include "ui/gl/gl_fence.h"
66 #include "ui/gl/gl_image.h" 67 #include "ui/gl/gl_image.h"
68 #include "ui/gl/gl_image_memory.h"
67 #include "ui/gl/gl_implementation.h" 69 #include "ui/gl/gl_implementation.h"
68 #include "ui/gl/gl_surface.h" 70 #include "ui/gl/gl_surface.h"
69 71
70 #if defined(OS_MACOSX) 72 #if defined(OS_MACOSX)
71 #include <IOSurface/IOSurfaceAPI.h> 73 #include <IOSurface/IOSurfaceAPI.h>
72 // Note that this must be included after gl_bindings.h to avoid conflicts. 74 // Note that this must be included after gl_bindings.h to avoid conflicts.
73 #include <OpenGL/CGLIOSurface.h> 75 #include <OpenGL/CGLIOSurface.h>
74 #endif 76 #endif
75 77
76 namespace gpu { 78 namespace gpu {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 // Return the union of |rect1| and |rect2| if they share an edge. 209 // Return the union of |rect1| and |rect2| if they share an edge.
208 if (rect1.SharesEdgeWith(rect2)) { 210 if (rect1.SharesEdgeWith(rect2)) {
209 *result = gfx::UnionRects(rect1, rect2); 211 *result = gfx::UnionRects(rect1, rect2);
210 return true; 212 return true;
211 } 213 }
212 214
213 // Return false if it's not possible to combine |rect1| and |rect2|. 215 // Return false if it's not possible to combine |rect1| and |rect2|.
214 return false; 216 return false;
215 } 217 }
216 218
219 bool GetImageSizeInBytes(gfx::GLImage& image, size_t* size_in_bytes) {
220 gfx::Size size = image.GetSize();
221 if (size.IsEmpty())
222 return false;
223
224 gfx::GpuMemoryBuffer::Format format =
225 ImageFactory::ImageFormatToGpuMemoryBufferFormat(
226 image.GetInternalFormat());
227
228 size_t stride_in_bytes = 0;
229 if (!gfx::GLImageMemory::StrideInBytes(
reveman 2015/06/11 22:40:42 hm, it's a bit awkward to depend on GLImageMemory
christiank 2015/06/12 11:38:38 Done.
230 size.width(), format, &stride_in_bytes)) {
231 return false;
232 }
233
234 base::CheckedNumeric<size_t> s = stride_in_bytes;
235 s *= size.height();
236 if (!s.IsValid())
237 return false;
238 *size_in_bytes = s.ValueOrDie();
239 return true;
240 }
241
217 } // namespace 242 } // namespace
218 243
219 class GLES2DecoderImpl; 244 class GLES2DecoderImpl;
220 245
221 // Local versions of the SET_GL_ERROR macros 246 // Local versions of the SET_GL_ERROR macros
222 #define LOCAL_SET_GL_ERROR(error, function_name, msg) \ 247 #define LOCAL_SET_GL_ERROR(error, function_name, msg) \
223 ERRORSTATE_SET_GL_ERROR(state_.GetErrorState(), error, function_name, msg) 248 ERRORSTATE_SET_GL_ERROR(state_.GetErrorState(), error, function_name, msg)
224 #define LOCAL_SET_GL_ERROR_INVALID_ENUM(function_name, value, label) \ 249 #define LOCAL_SET_GL_ERROR_INVALID_ENUM(function_name, value, label) \
225 ERRORSTATE_SET_GL_ERROR_INVALID_ENUM(state_.GetErrorState(), \ 250 ERRORSTATE_SET_GL_ERROR_INVALID_ENUM(state_.GetErrorState(), \
226 function_name, value, label) 251 function_name, value, label)
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 void DoCopySubTextureCHROMIUM(GLenum target, 1064 void DoCopySubTextureCHROMIUM(GLenum target,
1040 GLuint source_id, 1065 GLuint source_id,
1041 GLuint dest_id, 1066 GLuint dest_id,
1042 GLint xoffset, 1067 GLint xoffset,
1043 GLint yoffset, 1068 GLint yoffset,
1044 GLint x, 1069 GLint x,
1045 GLint y, 1070 GLint y,
1046 GLsizei width, 1071 GLsizei width,
1047 GLsizei height); 1072 GLsizei height);
1048 1073
1074 void DoCompressedCopyTextureCHROMIUM(GLenum target,
1075 GLuint source_id,
1076 GLuint dest_id);
1077
1049 // Wrapper for TexStorage2DEXT. 1078 // Wrapper for TexStorage2DEXT.
1050 void DoTexStorage2DEXT( 1079 void DoTexStorage2DEXT(
1051 GLenum target, 1080 GLenum target,
1052 GLint levels, 1081 GLint levels,
1053 GLenum internal_format, 1082 GLenum internal_format,
1054 GLsizei width, 1083 GLsizei width,
1055 GLsizei height); 1084 GLsizei height);
1056 1085
1057 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key); 1086 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key);
1058 void DoProduceTextureDirectCHROMIUM(GLuint texture, GLenum target, 1087 void DoProduceTextureDirectCHROMIUM(GLuint texture, GLenum target,
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
1778 bool ValidateCompressedTexSubDimensions( 1807 bool ValidateCompressedTexSubDimensions(
1779 const char* function_name, 1808 const char* function_name,
1780 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, 1809 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
1781 GLsizei width, GLsizei height, GLsizei depth, GLenum format, 1810 GLsizei width, GLsizei height, GLsizei depth, GLenum format,
1782 Texture* texture); 1811 Texture* texture);
1783 bool ValidateCopyTextureCHROMIUM(const char* function_name, 1812 bool ValidateCopyTextureCHROMIUM(const char* function_name,
1784 GLenum target, 1813 GLenum target,
1785 TextureRef* source_texture_ref, 1814 TextureRef* source_texture_ref,
1786 TextureRef* dest_texture_ref, 1815 TextureRef* dest_texture_ref,
1787 GLenum dest_internal_format); 1816 GLenum dest_internal_format);
1817 bool ValidateCompressedCopyTextureCHROMIUM(const char* function_name,
1818 GLenum target,
1819 TextureRef* source_texture_ref,
1820 TextureRef* dest_texture_ref);
1788 1821
1789 void RenderWarning(const char* filename, int line, const std::string& msg); 1822 void RenderWarning(const char* filename, int line, const std::string& msg);
1790 void PerformanceWarning( 1823 void PerformanceWarning(
1791 const char* filename, int line, const std::string& msg); 1824 const char* filename, int line, const std::string& msg);
1792 1825
1793 const FeatureInfo::FeatureFlags& features() const { 1826 const FeatureInfo::FeatureFlags& features() const {
1794 return feature_info_->feature_flags(); 1827 return feature_info_->feature_flags();
1795 } 1828 }
1796 1829
1797 const FeatureInfo::Workarounds& workarounds() const { 1830 const FeatureInfo::Workarounds& workarounds() const {
(...skipping 10118 matching lines...) Expand 10 before | Expand all | Expand 10 after
11916 source_internal_format == GL_LUMINANCE_ALPHA || 11949 source_internal_format == GL_LUMINANCE_ALPHA ||
11917 source_internal_format == GL_BGRA_EXT; 11950 source_internal_format == GL_BGRA_EXT;
11918 if (!valid_source_format || !valid_dest_format) { 11951 if (!valid_source_format || !valid_dest_format) {
11919 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, 11952 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
11920 "invalid internal format"); 11953 "invalid internal format");
11921 return false; 11954 return false;
11922 } 11955 }
11923 return true; 11956 return true;
11924 } 11957 }
11925 11958
11959 bool GLES2DecoderImpl::ValidateCompressedCopyTextureCHROMIUM(
11960 const char* function_name,
11961 GLenum target,
11962 TextureRef* source_texture_ref,
11963 TextureRef* dest_texture_ref) {
11964 if (!source_texture_ref || !dest_texture_ref) {
11965 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "unknown texture id");
11966 return false;
11967 }
11968
11969 if (GL_TEXTURE_2D != target) {
11970 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name,
11971 "invalid texture target");
11972 return false;
11973 }
11974
11975 Texture* source_texture = source_texture_ref->texture();
11976 Texture* dest_texture = dest_texture_ref->texture();
11977 if (source_texture == dest_texture) {
11978 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
11979 "source and destination textures are the same");
11980 return false;
11981 }
11982
11983 if (dest_texture->target() != GL_TEXTURE_2D ||
11984 (source_texture->target() != GL_TEXTURE_2D &&
11985 source_texture->target() != GL_TEXTURE_RECTANGLE_ARB &&
11986 source_texture->target() != GL_TEXTURE_EXTERNAL_OES)) {
11987 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name,
11988 "invalid texture target binding");
11989 return false;
11990 }
11991
11992 GLenum source_type = 0;
11993 GLenum source_internal_format = 0;
11994 source_texture->GetLevelType(source_texture->target(), 0, &source_type,
11995 &source_internal_format);
11996
11997 bool valid_format =
11998 source_internal_format == GL_ATC_RGB_AMD ||
11999 source_internal_format == GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD ||
12000 source_internal_format == GL_COMPRESSED_RGB_S3TC_DXT1_EXT ||
12001 source_internal_format == GL_COMPRESSED_RGBA_S3TC_DXT5_EXT ||
12002 source_internal_format == GL_ETC1_RGB8_OES;
12003
12004 if (!valid_format) {
12005 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
12006 "invalid internal format");
12007 return false;
12008 }
12009
12010 return true;
12011 }
12012
11926 void GLES2DecoderImpl::DoCopyTextureCHROMIUM(GLenum target, 12013 void GLES2DecoderImpl::DoCopyTextureCHROMIUM(GLenum target,
11927 GLuint source_id, 12014 GLuint source_id,
11928 GLuint dest_id, 12015 GLuint dest_id,
11929 GLenum internal_format, 12016 GLenum internal_format,
11930 GLenum dest_type) { 12017 GLenum dest_type) {
11931 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopyTextureCHROMIUM"); 12018 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopyTextureCHROMIUM");
11932 12019
11933 TextureRef* source_texture_ref = GetTexture(source_id); 12020 TextureRef* source_texture_ref = GetTexture(source_id);
11934 TextureRef* dest_texture_ref = GetTexture(dest_id); 12021 TextureRef* dest_texture_ref = GetTexture(dest_id);
11935 Texture* source_texture = source_texture_ref->texture(); 12022 Texture* source_texture = source_texture_ref->texture();
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
12221 copy_texture_CHROMIUM_->DoCopySubTexture( 12308 copy_texture_CHROMIUM_->DoCopySubTexture(
12222 this, source_texture->target(), source_texture->service_id(), 12309 this, source_texture->target(), source_texture->service_id(),
12223 source_internal_format, dest_texture->service_id(), dest_internal_format, 12310 source_internal_format, dest_texture->service_id(), dest_internal_format,
12224 xoffset, yoffset, x, y, width, height, dest_width, dest_height, 12311 xoffset, yoffset, x, y, width, height, dest_width, dest_height,
12225 source_width, source_height, unpack_flip_y_, unpack_premultiply_alpha_, 12312 source_width, source_height, unpack_flip_y_, unpack_premultiply_alpha_,
12226 unpack_unpremultiply_alpha_); 12313 unpack_unpremultiply_alpha_);
12227 12314
12228 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); 12315 DoDidUseTexImageIfNeeded(source_texture, source_texture->target());
12229 } 12316 }
12230 12317
12318 void GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM(GLenum target,
12319 GLuint source_id,
12320 GLuint dest_id) {
12321 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM");
12322
12323 TextureRef* source_texture_ref = GetTexture(source_id);
12324 TextureRef* dest_texture_ref = GetTexture(dest_id);
12325 Texture* source_texture = source_texture_ref->texture();
12326 Texture* dest_texture = dest_texture_ref->texture();
12327 int source_width = 0;
12328 int source_height = 0;
12329 gfx::GLImage* image =
12330 source_texture->GetLevelImage(source_texture->target(), 0);
12331 if (image) {
12332 gfx::Size size = image->GetSize();
12333 source_width = size.width();
12334 source_height = size.height();
12335 if (source_width <= 0 || source_height <= 0) {
12336 LOCAL_SET_GL_ERROR(
12337 GL_INVALID_VALUE,
12338 "glCompressedCopyTextureCHROMIUM", "invalid image size");
12339 return;
12340 }
12341 } else {
12342 if (!source_texture->GetLevelSize(source_texture->target(), 0,
12343 &source_width, &source_height, nullptr)) {
12344 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE,
12345 "glCompressedCopyTextureCHROMIUM",
12346 "source texture has no level 0");
12347 return;
12348 }
12349
12350 // Check that this type of texture is allowed.
12351 if (!texture_manager()->ValidForTarget(source_texture->target(), 0,
12352 source_width, source_height, 1)) {
12353 LOCAL_SET_GL_ERROR(
12354 GL_INVALID_VALUE, "glCompressedCopyTextureCHROMIUM",
12355 "Bad dimensions");
12356 return;
12357 }
12358 }
12359
12360 GLenum source_type = 0;
12361 GLenum source_internal_format = 0;
12362 source_texture->GetLevelType(
12363 source_texture->target(), 0, &source_type, &source_internal_format);
12364
12365 if (dest_texture->IsImmutable()) {
12366 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
12367 "glCompressedCopyTextureCHROMIUM",
12368 "texture is immutable");
12369 return;
12370 }
12371
12372 if (!ValidateCompressedCopyTextureCHROMIUM(
12373 "glCompressedCopyTextureCHROMIUM",
12374 target,
12375 source_texture_ref, dest_texture_ref)) {
12376 return;
12377 }
12378
12379 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is
12380 // needed because it takes 10s of milliseconds to initialize.
12381 if (!copy_texture_CHROMIUM_.get()) {
12382 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM");
12383 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager());
12384 copy_texture_CHROMIUM_->Initialize(this);
12385 RestoreCurrentFramebufferBindings();
12386 if (LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM") != GL_NO_ERROR)
12387 return;
12388 }
12389
12390 // Clear the source texture if necessary.
12391 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref,
12392 source_texture->target(), 0)) {
12393 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCompressedCopyTextureCHROMIUM",
12394 "dimensions too big");
12395 return;
12396 }
12397
12398 ScopedModifyPixels modify(dest_texture_ref);
12399
12400 bool unpack_premultiply_alpha_change =
12401 unpack_premultiply_alpha_ ^ unpack_unpremultiply_alpha_;
12402 if (unpack_flip_y_ || unpack_premultiply_alpha_change) {
12403 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCompressedCopyTextureCHROMIUM",
12404 "pixel-storage multipliers are not supported");
12405 }
12406
12407 // Try using GLImage::CopyTexImage when possible.
12408 if (image) {
12409 GLenum dest_type = 0;
12410 GLenum dest_internal_format = 0;
12411 int dest_width = 0;
12412 int dest_height = 0;
12413 bool dest_level_defined = dest_texture->GetLevelSize(
12414 GL_TEXTURE_2D, 0, &dest_width, &dest_height, nullptr);
12415
12416 if (dest_level_defined) {
12417 dest_texture->GetLevelType(GL_TEXTURE_2D, 0, &dest_type,
12418 &dest_internal_format);
12419 }
12420
12421 // Resize the destination texture to the dimensions of the source texture.
12422 if (!dest_level_defined || dest_width != source_width ||
reveman 2015/06/11 22:40:42 I understand that this is not needed in the "!imag
christiank 2015/06/12 11:38:38 Done.
12423 dest_height != source_height ||
12424 dest_internal_format != source_internal_format) {
12425 size_t source_size = 0;
12426 if (!GetImageSizeInBytes(*image, &source_size)) {
12427 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
12428 "glCompressedCopyTextureCHROMIUM",
12429 "could not compute image byte size");
12430 return;
12431 }
12432
12433 // Ensure that the glCompressedTexImage2D succeeds.
12434 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedCopyTextureCHROMIUM");
12435 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id());
12436 glCompressedTexImage2D(GL_TEXTURE_2D, 0, source_internal_format,
12437 source_width, source_height, 0, source_size,
12438 NULL);
12439 GLenum error = LOCAL_PEEK_GL_ERROR("glCompressedCopyTextureCHROMIUM");
12440 if (error != GL_NO_ERROR) {
12441 RestoreCurrentTextureBindings(&state_, GL_TEXTURE_2D);
12442 return;
12443 }
12444
12445 texture_manager()->SetLevelInfo(
12446 dest_texture_ref, GL_TEXTURE_2D, 0, source_internal_format,
12447 source_width, source_height, 1, 0, source_internal_format,
12448 source_type, gfx::Rect(source_width, source_height));
12449 } else {
12450 texture_manager()->SetLevelCleared(dest_texture_ref, GL_TEXTURE_2D, 0,
12451 true);
12452 }
12453
12454 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id());
12455 if (image->CopyTexSubImage(GL_TEXTURE_2D, gfx::Point(0, 0),
12456 gfx::Rect(0, 0, source_width, source_height))) {
12457 return;
12458 }
12459 }
12460
12461 TRACE_EVENT0(
12462 "gpu",
12463 "GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM, fallback");
12464
12465 DoWillUseTexImageIfNeeded(source_texture, source_texture->target());
12466
12467 // As a fallback, copy into a non-compressed GL_RGBA texture.
12468 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedCopyTextureCHROMIUM");
12469 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id());
12470 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, source_width, source_height,
12471 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
12472 GLenum error = LOCAL_PEEK_GL_ERROR("glCompressedCopyTextureCHROMIUM");
12473 if (error != GL_NO_ERROR) {
12474 RestoreCurrentTextureBindings(&state_, GL_TEXTURE_2D);
12475 return;
12476 }
12477
12478 texture_manager()->SetLevelInfo(
12479 dest_texture_ref, GL_TEXTURE_2D, 0, GL_RGBA, source_width,
12480 source_height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
12481 gfx::Rect(source_width, source_height));
12482
12483 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix
12484 // before presenting.
12485 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) {
12486 // TODO(hkuang): get the StreamTexture transform matrix in GPU process
12487 // instead of using kIdentityMatrix crbug.com/226218.
12488 copy_texture_CHROMIUM_->DoCopyTextureWithTransform(
12489 this, source_texture->target(), source_texture->service_id(),
12490 dest_texture->service_id(), source_width, source_height,
12491 unpack_flip_y_, unpack_premultiply_alpha_,
12492 unpack_unpremultiply_alpha_, kIdentityMatrix);
12493 } else {
12494 copy_texture_CHROMIUM_->DoCopyTexture(
12495 this, source_texture->target(), source_texture->service_id(),
12496 source_internal_format, dest_texture->service_id(), GL_RGBA,
12497 source_width, source_height, unpack_flip_y_,
12498 unpack_premultiply_alpha_, unpack_unpremultiply_alpha_);
12499 }
12500
12501 DoDidUseTexImageIfNeeded(source_texture, source_texture->target());
12502 }
12503
12231 static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) { 12504 static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) {
12232 switch (internalformat) { 12505 switch (internalformat) {
12233 case GL_RGB565: 12506 case GL_RGB565:
12234 return GL_UNSIGNED_SHORT_5_6_5; 12507 return GL_UNSIGNED_SHORT_5_6_5;
12235 case GL_RGBA4: 12508 case GL_RGBA4:
12236 return GL_UNSIGNED_SHORT_4_4_4_4; 12509 return GL_UNSIGNED_SHORT_4_4_4_4;
12237 case GL_RGB5_A1: 12510 case GL_RGB5_A1:
12238 return GL_UNSIGNED_SHORT_5_5_5_1; 12511 return GL_UNSIGNED_SHORT_5_5_5_1;
12239 case GL_RGB8_OES: 12512 case GL_RGB8_OES:
12240 return GL_UNSIGNED_BYTE; 12513 return GL_UNSIGNED_BYTE;
(...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after
13426 } 13699 }
13427 } 13700 }
13428 13701
13429 // Include the auto-generated part of this file. We split this because it means 13702 // Include the auto-generated part of this file. We split this because it means
13430 // we can easily edit the non-auto generated parts right here in this file 13703 // we can easily edit the non-auto generated parts right here in this file
13431 // instead of having to edit some template or the code generator. 13704 // instead of having to edit some template or the code generator.
13432 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 13705 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
13433 13706
13434 } // namespace gles2 13707 } // namespace gles2
13435 } // namespace gpu 13708 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/common/gles2_cmd_ids_autogen.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698