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

Side by Side Diff: Source/platform/graphics/GraphicsContext3DImagePacking.cpp

Issue 106503003: Changed GL enums from GraphicsContext3D to standard versions (Take 2) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * Copyright (C) 2010 Mozilla Corporation. All rights reserved. 3 * Copyright (C) 2010 Mozilla Corporation. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 21 matching lines...) Expand all
32 #include "platform/graphics/ImageObserver.h" 32 #include "platform/graphics/ImageObserver.h"
33 33
34 namespace WebCore { 34 namespace WebCore {
35 35
36 namespace { 36 namespace {
37 37
38 GraphicsContext3D::DataFormat getDataFormat(GC3Denum destinationFormat, GC3Denum destinationType) 38 GraphicsContext3D::DataFormat getDataFormat(GC3Denum destinationFormat, GC3Denum destinationType)
39 { 39 {
40 GraphicsContext3D::DataFormat dstFormat = GraphicsContext3D::DataFormatRGBA8 ; 40 GraphicsContext3D::DataFormat dstFormat = GraphicsContext3D::DataFormatRGBA8 ;
41 switch (destinationType) { 41 switch (destinationType) {
42 case GraphicsContext3D::UNSIGNED_BYTE: 42 case GL_UNSIGNED_BYTE:
43 switch (destinationFormat) { 43 switch (destinationFormat) {
44 case GraphicsContext3D::RGB: 44 case GL_RGB:
45 dstFormat = GraphicsContext3D::DataFormatRGB8; 45 dstFormat = GraphicsContext3D::DataFormatRGB8;
46 break; 46 break;
47 case GraphicsContext3D::RGBA: 47 case GL_RGBA:
48 dstFormat = GraphicsContext3D::DataFormatRGBA8; 48 dstFormat = GraphicsContext3D::DataFormatRGBA8;
49 break; 49 break;
50 case GraphicsContext3D::ALPHA: 50 case GL_ALPHA:
51 dstFormat = GraphicsContext3D::DataFormatA8; 51 dstFormat = GraphicsContext3D::DataFormatA8;
52 break; 52 break;
53 case GraphicsContext3D::LUMINANCE: 53 case GL_LUMINANCE:
54 dstFormat = GraphicsContext3D::DataFormatR8; 54 dstFormat = GraphicsContext3D::DataFormatR8;
55 break; 55 break;
56 case GraphicsContext3D::LUMINANCE_ALPHA: 56 case GL_LUMINANCE_ALPHA:
57 dstFormat = GraphicsContext3D::DataFormatRA8; 57 dstFormat = GraphicsContext3D::DataFormatRA8;
58 break; 58 break;
59 default: 59 default:
60 ASSERT_NOT_REACHED(); 60 ASSERT_NOT_REACHED();
61 } 61 }
62 break; 62 break;
63 case GraphicsContext3D::UNSIGNED_SHORT_4_4_4_4: 63 case GL_UNSIGNED_SHORT_4_4_4_4:
64 dstFormat = GraphicsContext3D::DataFormatRGBA4444; 64 dstFormat = GraphicsContext3D::DataFormatRGBA4444;
65 break; 65 break;
66 case GraphicsContext3D::UNSIGNED_SHORT_5_5_5_1: 66 case GL_UNSIGNED_SHORT_5_5_5_1:
67 dstFormat = GraphicsContext3D::DataFormatRGBA5551; 67 dstFormat = GraphicsContext3D::DataFormatRGBA5551;
68 break; 68 break;
69 case GraphicsContext3D::UNSIGNED_SHORT_5_6_5: 69 case GL_UNSIGNED_SHORT_5_6_5:
70 dstFormat = GraphicsContext3D::DataFormatRGB565; 70 dstFormat = GraphicsContext3D::DataFormatRGB565;
71 break; 71 break;
72 case GraphicsContext3D::HALF_FLOAT_OES: // OES_texture_half_float 72 case GL_HALF_FLOAT_OES: // OES_texture_half_float
73 switch (destinationFormat) { 73 switch (destinationFormat) {
74 case GraphicsContext3D::RGB: 74 case GL_RGB:
75 dstFormat = GraphicsContext3D::DataFormatRGB16F; 75 dstFormat = GraphicsContext3D::DataFormatRGB16F;
76 break; 76 break;
77 case GraphicsContext3D::RGBA: 77 case GL_RGBA:
78 dstFormat = GraphicsContext3D::DataFormatRGBA16F; 78 dstFormat = GraphicsContext3D::DataFormatRGBA16F;
79 break; 79 break;
80 case GraphicsContext3D::ALPHA: 80 case GL_ALPHA:
81 dstFormat = GraphicsContext3D::DataFormatA16F; 81 dstFormat = GraphicsContext3D::DataFormatA16F;
82 break; 82 break;
83 case GraphicsContext3D::LUMINANCE: 83 case GL_LUMINANCE:
84 dstFormat = GraphicsContext3D::DataFormatR16F; 84 dstFormat = GraphicsContext3D::DataFormatR16F;
85 break; 85 break;
86 case GraphicsContext3D::LUMINANCE_ALPHA: 86 case GL_LUMINANCE_ALPHA:
87 dstFormat = GraphicsContext3D::DataFormatRA16F; 87 dstFormat = GraphicsContext3D::DataFormatRA16F;
88 break; 88 break;
89 default: 89 default:
90 ASSERT_NOT_REACHED(); 90 ASSERT_NOT_REACHED();
91 } 91 }
92 break; 92 break;
93 case GraphicsContext3D::FLOAT: // OES_texture_float 93 case GL_FLOAT: // OES_texture_float
94 switch (destinationFormat) { 94 switch (destinationFormat) {
95 case GraphicsContext3D::RGB: 95 case GL_RGB:
96 dstFormat = GraphicsContext3D::DataFormatRGB32F; 96 dstFormat = GraphicsContext3D::DataFormatRGB32F;
97 break; 97 break;
98 case GraphicsContext3D::RGBA: 98 case GL_RGBA:
99 dstFormat = GraphicsContext3D::DataFormatRGBA32F; 99 dstFormat = GraphicsContext3D::DataFormatRGBA32F;
100 break; 100 break;
101 case GraphicsContext3D::ALPHA: 101 case GL_ALPHA:
102 dstFormat = GraphicsContext3D::DataFormatA32F; 102 dstFormat = GraphicsContext3D::DataFormatA32F;
103 break; 103 break;
104 case GraphicsContext3D::LUMINANCE: 104 case GL_LUMINANCE:
105 dstFormat = GraphicsContext3D::DataFormatR32F; 105 dstFormat = GraphicsContext3D::DataFormatR32F;
106 break; 106 break;
107 case GraphicsContext3D::LUMINANCE_ALPHA: 107 case GL_LUMINANCE_ALPHA:
108 dstFormat = GraphicsContext3D::DataFormatRA32F; 108 dstFormat = GraphicsContext3D::DataFormatRA32F;
109 break; 109 break;
110 default: 110 default:
111 ASSERT_NOT_REACHED(); 111 ASSERT_NOT_REACHED();
112 } 112 }
113 break; 113 break;
114 default: 114 default:
115 ASSERT_NOT_REACHED(); 115 ASSERT_NOT_REACHED();
116 } 116 }
117 return dstFormat; 117 return dstFormat;
(...skipping 1352 matching lines...) Expand 10 before | Expand all | Expand 10 after
1470 unsigned width, 1470 unsigned width,
1471 unsigned height, 1471 unsigned height,
1472 unsigned sourceUnpackAlignment, 1472 unsigned sourceUnpackAlignment,
1473 Vector<uint8_t>& data) 1473 Vector<uint8_t>& data)
1474 { 1474 {
1475 if (!pixels) 1475 if (!pixels)
1476 return false; 1476 return false;
1477 1477
1478 unsigned packedSize; 1478 unsigned packedSize;
1479 // Output data is tightly packed (alignment == 1). 1479 // Output data is tightly packed (alignment == 1).
1480 if (computeImageSizeInBytes(format, type, width, height, 1, &packedSize, 0) != GraphicsContext3D::NO_ERROR) 1480 if (computeImageSizeInBytes(format, type, width, height, 1, &packedSize, 0) != GL_NO_ERROR)
1481 return false; 1481 return false;
1482 data.resize(packedSize); 1482 data.resize(packedSize);
1483 1483
1484 if (!packPixels(reinterpret_cast<const uint8_t*>(pixels), sourceFormat, widt h, height, sourceUnpackAlignment, format, type, alphaOp, data.data(), flipY)) 1484 if (!packPixels(reinterpret_cast<const uint8_t*>(pixels), sourceFormat, widt h, height, sourceUnpackAlignment, format, type, alphaOp, data.data(), flipY))
1485 return false; 1485 return false;
1486 if (ImageObserver *observer = image->imageObserver()) 1486 if (ImageObserver *observer = image->imageObserver())
1487 observer->didDraw(image); 1487 observer->didDraw(image);
1488 return true; 1488 return true;
1489 } 1489 }
1490 1490
1491 bool GraphicsContext3D::extractImageData( 1491 bool GraphicsContext3D::extractImageData(
1492 const uint8_t* imageData, 1492 const uint8_t* imageData,
1493 const IntSize& imageDataSize, 1493 const IntSize& imageDataSize,
1494 GC3Denum format, 1494 GC3Denum format,
1495 GC3Denum type, 1495 GC3Denum type,
1496 bool flipY, 1496 bool flipY,
1497 bool premultiplyAlpha, 1497 bool premultiplyAlpha,
1498 Vector<uint8_t>& data) 1498 Vector<uint8_t>& data)
1499 { 1499 {
1500 if (!imageData) 1500 if (!imageData)
1501 return false; 1501 return false;
1502 int width = imageDataSize.width(); 1502 int width = imageDataSize.width();
1503 int height = imageDataSize.height(); 1503 int height = imageDataSize.height();
1504 1504
1505 unsigned packedSize; 1505 unsigned packedSize;
1506 // Output data is tightly packed (alignment == 1). 1506 // Output data is tightly packed (alignment == 1).
1507 if (computeImageSizeInBytes(format, type, width, height, 1, &packedSize, 0) != GraphicsContext3D::NO_ERROR) 1507 if (computeImageSizeInBytes(format, type, width, height, 1, &packedSize, 0) != GL_NO_ERROR)
1508 return false; 1508 return false;
1509 data.resize(packedSize); 1509 data.resize(packedSize);
1510 1510
1511 if (!packPixels(imageData, DataFormatRGBA8, width, height, 0, format, type, premultiplyAlpha ? AlphaDoPremultiply : AlphaDoNothing, data.data(), flipY)) 1511 if (!packPixels(imageData, DataFormatRGBA8, width, height, 0, format, type, premultiplyAlpha ? AlphaDoPremultiply : AlphaDoNothing, data.data(), flipY))
1512 return false; 1512 return false;
1513 1513
1514 return true; 1514 return true;
1515 } 1515 }
1516 1516
1517 bool GraphicsContext3D::extractTextureData( 1517 bool GraphicsContext3D::extractTextureData(
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1579 1579
1580 FormatConverter converter(width, height, sourceData, destinationData, srcStr ide, dstStride); 1580 FormatConverter converter(width, height, sourceData, destinationData, srcStr ide, dstStride);
1581 converter.convert(sourceDataFormat, dstDataFormat, alphaOp); 1581 converter.convert(sourceDataFormat, dstDataFormat, alphaOp);
1582 if (!converter.Success()) 1582 if (!converter.Success())
1583 return false; 1583 return false;
1584 return true; 1584 return true;
1585 } 1585 }
1586 1586
1587 } // namespace WebCore 1587 } // namespace WebCore
1588 1588
OLDNEW
« no previous file with comments | « Source/platform/graphics/GraphicsContext3D.cpp ('k') | Source/platform/graphics/GraphicsTypes3D.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698