OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 { | 103 { |
104 PlatformCanvas::Painter painter(&canvas, PlatformCanvas::Painter::Graysc
aleText); | 104 PlatformCanvas::Painter painter(&canvas, PlatformCanvas::Painter::Graysc
aleText); |
105 drawHudContents(painter.context(), hudSize); | 105 drawHudContents(painter.context(), hudSize); |
106 } | 106 } |
107 | 107 |
108 // Upload to GL. | 108 // Upload to GL. |
109 { | 109 { |
110 PlatformCanvas::AutoLocker locker(&canvas); | 110 PlatformCanvas::AutoLocker locker(&canvas); |
111 | 111 |
112 m_hudTexture->bindTexture(); | 112 m_hudTexture->bindTexture(); |
| 113 bool uploadedViaMap = false; |
113 if (m_useMapSubForUploads) { | 114 if (m_useMapSubForUploads) { |
114 Extensions3DChromium* extensions = static_cast<Extensions3DChromium*
>(context->getExtensions()); | 115 Extensions3DChromium* extensions = static_cast<Extensions3DChromium*
>(context->getExtensions()); |
115 uint8_t* pixelDest = static_cast<uint8_t*>(extensions->mapTexSubImag
e2DCHROMIUM(GraphicsContext3D::TEXTURE_2D, 0, 0, 0, hudSize.width(), hudSize.hei
ght(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, Extensions3DCh
romium::WRITE_ONLY)); | 116 uint8_t* pixelDest = static_cast<uint8_t*>(extensions->mapTexSubImag
e2DCHROMIUM(GraphicsContext3D::TEXTURE_2D, 0, 0, 0, hudSize.width(), hudSize.hei
ght(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, Extensions3DCh
romium::WRITE_ONLY)); |
116 memcpy(pixelDest, locker.pixels(), hudSize.width() * hudSize.height(
) * 4); | 117 |
117 extensions->unmapTexSubImage2DCHROMIUM(pixelDest); | 118 if (pixelDest) { |
118 } else | 119 uploadedViaMap = true; |
| 120 memcpy(pixelDest, locker.pixels(), hudSize.width() * hudSize.hei
ght() * 4); |
| 121 extensions->unmapTexSubImage2DCHROMIUM(pixelDest); |
| 122 } |
| 123 } |
| 124 |
| 125 if (!uploadedViaMap) { |
119 GLC(context, context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, G
raphicsContext3D::RGBA, canvas.size().width(), canvas.size().height(), 0, Graphi
csContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, locker.pixels())); | 126 GLC(context, context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, G
raphicsContext3D::RGBA, canvas.size().width(), canvas.size().height(), 0, Graphi
csContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, locker.pixels())); |
| 127 } |
120 } | 128 } |
121 | 129 |
122 // Draw the HUD onto the default render surface. | 130 // Draw the HUD onto the default render surface. |
123 const Program* program = m_layerRenderer->headsUpDisplayProgram(); | 131 const Program* program = m_layerRenderer->headsUpDisplayProgram(); |
124 ASSERT(program && program->initialized()); | 132 ASSERT(program && program->initialized()); |
125 GLC(context, context->activeTexture(GraphicsContext3D::TEXTURE0)); | 133 GLC(context, context->activeTexture(GraphicsContext3D::TEXTURE0)); |
126 m_hudTexture->bindTexture(); | 134 m_hudTexture->bindTexture(); |
127 GLC(context, context->useProgram(program->program())); | 135 GLC(context, context->useProgram(program->program())); |
128 GLC(context, context->uniform1i(program->fragmentShader().samplerLocation(),
0)); | 136 GLC(context, context->uniform1i(program->fragmentShader().samplerLocation(),
0)); |
129 | 137 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 } | 240 } |
233 | 241 |
234 void CCHeadsUpDisplay::onPresent() | 242 void CCHeadsUpDisplay::onPresent() |
235 { | 243 { |
236 m_currentFrameNumber += 1; | 244 m_currentFrameNumber += 1; |
237 } | 245 } |
238 | 246 |
239 } | 247 } |
240 | 248 |
241 #endif // USE(ACCELERATED_COMPOSITING) | 249 #endif // USE(ACCELERATED_COMPOSITING) |
OLD | NEW |