| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010, Google Inc. All rights reserved. | 2 * Copyright (c) 2010, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 ASSERT_NOT_REACHED(); | 341 ASSERT_NOT_REACHED(); |
| 342 } | 342 } |
| 343 | 343 |
| 344 DrawingBuffer::TextureParameters DrawingBuffer::chromiumImageTextureParameters() | 344 DrawingBuffer::TextureParameters DrawingBuffer::chromiumImageTextureParameters() |
| 345 { | 345 { |
| 346 #if OS(MACOSX) | 346 #if OS(MACOSX) |
| 347 // A CHROMIUM_image backed texture requires a specialized set of parameters | 347 // A CHROMIUM_image backed texture requires a specialized set of parameters |
| 348 // on OSX. | 348 // on OSX. |
| 349 TextureParameters parameters; | 349 TextureParameters parameters; |
| 350 parameters.target = GC3D_TEXTURE_RECTANGLE_ARB; | 350 parameters.target = GC3D_TEXTURE_RECTANGLE_ARB; |
| 351 parameters.internalColorFormat = GL_BGRA_EXT; | 351 if (m_requestedAttributes.alpha) { |
| 352 parameters.internalRenderbufferFormat = GL_RGBA8_OES; | 352 parameters.internalColorFormat = GL_BGRA_EXT; |
| 353 parameters.colorFormat = GL_RGBA; | 353 parameters.internalRenderbufferFormat = GL_RGBA8_OES; |
| 354 parameters.colorFormat = GL_RGBA; |
| 355 } else { |
| 356 parameters.internalColorFormat = GL_BGR_EXT; |
| 357 parameters.internalRenderbufferFormat = GL_RGB8_OES; |
| 358 parameters.colorFormat = GL_RGB; |
| 359 } |
| 354 return parameters; | 360 return parameters; |
| 355 #else | 361 #else |
| 356 return defaultTextureParameters(); | 362 return defaultTextureParameters(); |
| 357 #endif | 363 #endif |
| 358 } | 364 } |
| 359 | 365 |
| 360 DrawingBuffer::TextureParameters DrawingBuffer::defaultTextureParameters() | 366 DrawingBuffer::TextureParameters DrawingBuffer::defaultTextureParameters() |
| 361 { | 367 { |
| 362 TextureParameters parameters; | 368 TextureParameters parameters; |
| 363 parameters.target = GL_TEXTURE_2D; | 369 parameters.target = GL_TEXTURE_2D; |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 if (info->imageId) { | 957 if (info->imageId) { |
| 952 m_gl->BindTexture(info->parameters.target, info->textureId); | 958 m_gl->BindTexture(info->parameters.target, info->textureId); |
| 953 m_gl->ReleaseTexImage2DCHROMIUM(info->parameters.target, info->imageId); | 959 m_gl->ReleaseTexImage2DCHROMIUM(info->parameters.target, info->imageId); |
| 954 m_gl->DestroyImageCHROMIUM(info->imageId); | 960 m_gl->DestroyImageCHROMIUM(info->imageId); |
| 955 info->imageId = 0; | 961 info->imageId = 0; |
| 956 } | 962 } |
| 957 } | 963 } |
| 958 | 964 |
| 959 DrawingBuffer::TextureInfo DrawingBuffer::createTextureAndAllocateMemory(const I
ntSize& size) | 965 DrawingBuffer::TextureInfo DrawingBuffer::createTextureAndAllocateMemory(const I
ntSize& size) |
| 960 { | 966 { |
| 961 // TODO(erikchen): Add support for a CHROMIUM_image back buffer whose | |
| 962 // behavior mimics a texture with internal format GL_RGB. | |
| 963 // https://crbug.com/581777. | |
| 964 if (!m_requestedAttributes.alpha) | |
| 965 return createDefaultTextureAndAllocateMemory(size); | |
| 966 | |
| 967 if (!RuntimeEnabledFeatures::webGLImageChromiumEnabled()) | 967 if (!RuntimeEnabledFeatures::webGLImageChromiumEnabled()) |
| 968 return createDefaultTextureAndAllocateMemory(size); | 968 return createDefaultTextureAndAllocateMemory(size); |
| 969 | 969 |
| 970 // First, try to allocate a CHROMIUM_image. This always has the potential to | 970 // First, try to allocate a CHROMIUM_image. This always has the potential to |
| 971 // fail. | 971 // fail. |
| 972 TextureParameters parameters = chromiumImageTextureParameters(); | 972 TextureParameters parameters = chromiumImageTextureParameters(); |
| 973 WGC3Duint imageId = m_gl->CreateGpuMemoryBufferImageCHROMIUM(size.width(), s
ize.height(), parameters.internalColorFormat, GC3D_SCANOUT_CHROMIUM); | 973 WGC3Duint imageId = m_gl->CreateGpuMemoryBufferImageCHROMIUM(size.width(), s
ize.height(), parameters.internalColorFormat, GC3D_SCANOUT_CHROMIUM); |
| 974 if (!imageId) | 974 if (!imageId) |
| 975 return createDefaultTextureAndAllocateMemory(size); | 975 return createDefaultTextureAndAllocateMemory(size); |
| 976 | 976 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1026 | 1026 |
| 1027 if (m_antiAliasingMode == MSAAImplicitResolve) | 1027 if (m_antiAliasingMode == MSAAImplicitResolve) |
| 1028 m_gl->FramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACH
MENT0, target, m_colorBuffer.textureId, 0, m_sampleCount); | 1028 m_gl->FramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACH
MENT0, target, m_colorBuffer.textureId, 0, m_sampleCount); |
| 1029 else | 1029 else |
| 1030 m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target,
m_colorBuffer.textureId, 0); | 1030 m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target,
m_colorBuffer.textureId, 0); |
| 1031 | 1031 |
| 1032 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); | 1032 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); |
| 1033 } | 1033 } |
| 1034 | 1034 |
| 1035 } // namespace blink | 1035 } // namespace blink |
| OLD | NEW |