Changeset 69588 in webkit


Ignore:
Timestamp:
Oct 12, 2010 10:30:55 AM (13 years ago)
Author:
senorblanco@chromium.org
Message:

2010-10-07 Stephen White <senorblanco@chromium.org>

Reviewed by James Robinson.

[chromium] Zero-out all textures created via WebGraphicsContext3DDefaultImpl::texImage2D().
https://bugs.webkit.org/show_bug.cgi?id=47178


Covered by fast/canvas/toDataURL-alpha.html, when run with --accelerated-2d-canvas.

  • src/WebGraphicsContext3DDefaultImpl.cpp: (WebKit::bytesPerComponent): (WebKit::componentsPerPixel): (WebKit::imageSizeInBytes): (WebKit::WebGraphicsContext3DDefaultImpl::texImage2D):
Location:
trunk/WebKit/chromium
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/chromium/ChangeLog

    r69586 r69588  
     12010-10-07  Stephen White  <senorblanco@chromium.org>
     2
     3        Reviewed by James Robinson.
     4
     5        [chromium] Zero-out all textures created via WebGraphicsContext3DDefaultImpl::texImage2D().
     6        https://bugs.webkit.org/show_bug.cgi?id=47178
     7       
     8        Covered by fast/canvas/toDataURL-alpha.html, when run with --accelerated-2d-canvas.
     9
     10        * src/WebGraphicsContext3DDefaultImpl.cpp:
     11        (WebKit::bytesPerComponent):
     12        (WebKit::componentsPerPixel):
     13        (WebKit::imageSizeInBytes):
     14        (WebKit::WebGraphicsContext3DDefaultImpl::texImage2D):
     15
    1162010-10-12  Dave Moore  <davemoore@chromium.org>
    217
  • trunk/WebKit/chromium/src/WebGraphicsContext3DDefaultImpl.cpp

    r69139 r69588  
    3939#include "NotImplemented.h"
    4040#include "WebView.h"
     41#include <wtf/OwnArrayPtr.h>
    4142#include <wtf/PassOwnPtr.h>
    4243#include <wtf/text/CString.h>
     
    11911192DELEGATE_TO_GL_4(scissor, Scissor, long, long, unsigned long, unsigned long)
    11921193
     1194unsigned bytesPerComponent(unsigned type)
     1195{
     1196    switch (type) {
     1197    case GL_BYTE:
     1198    case GL_UNSIGNED_BYTE:
     1199        return 1;
     1200    case GL_SHORT:
     1201    case GL_UNSIGNED_SHORT:
     1202    case GL_UNSIGNED_SHORT_5_6_5:
     1203    case GL_UNSIGNED_SHORT_4_4_4_4:
     1204    case GL_UNSIGNED_SHORT_5_5_5_1:
     1205        return 2;
     1206    case GL_FLOAT:
     1207        return 4;
     1208    default:
     1209        return 4;
     1210    }
     1211}
     1212
     1213unsigned componentsPerPixel(unsigned format, unsigned type)
     1214{
     1215    switch (type) {
     1216    case GL_UNSIGNED_SHORT_5_6_5:
     1217    case GL_UNSIGNED_SHORT_4_4_4_4:
     1218    case GL_UNSIGNED_SHORT_5_5_5_1:
     1219        return 1;
     1220    default:
     1221        break;
     1222    }
     1223    switch (format) {
     1224    case GL_LUMINANCE:
     1225        return 1;
     1226    case GL_LUMINANCE_ALPHA:
     1227        return 2;
     1228    case GL_RGB:
     1229        return 3;
     1230    case GL_RGBA:
     1231    case GL_BGRA_EXT:
     1232        return 4;
     1233    default:
     1234        return 4;
     1235    }
     1236}
     1237
     1238// N.B.:  This code does not protect against integer overflow (as the command
     1239// buffer implementation does), so it should not be considered robust enough
     1240// for use in the browser.  Since this implementation is only used for layout
     1241// tests, this should be ok for now.
     1242size_t imageSizeInBytes(unsigned width, unsigned height, unsigned format, unsigned type)
     1243{
     1244    return width * height * bytesPerComponent(type) * componentsPerPixel(format, type);
     1245}
     1246
     1247void WebGraphicsContext3DDefaultImpl::texImage2D(unsigned target, unsigned level, unsigned internalFormat, unsigned width, unsigned height, unsigned border, unsigned format, unsigned type, const void* pixels)
     1248{
     1249    OwnArrayPtr<uint8> zero;
     1250    if (!pixels) {
     1251        size_t size = imageSizeInBytes(width, height, format, type);
     1252        zero.set(new uint8[size]);
     1253        memset(zero.get(), 0, size);
     1254        pixels = zero.get();
     1255    }
     1256    glTexImage2D(target, level, internalFormat, width, height, border, format, type, pixels);
     1257}
     1258
    11931259void WebGraphicsContext3DDefaultImpl::shaderSource(WebGLId shader, const char* string)
    11941260{
     
    12211287
    12221288DELEGATE_TO_GL_4(stencilOpSeparate, StencilOpSeparate, unsigned long, unsigned long, unsigned long, unsigned long)
    1223 
    1224 DELEGATE_TO_GL_9(texImage2D, TexImage2D, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, const void*)
    12251289
    12261290DELEGATE_TO_GL_3(texParameterf, TexParameterf, unsigned, unsigned, float);
Note: See TracChangeset for help on using the changeset viewer.