| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 bool wantDepth, | 147 bool wantDepth, |
| 148 bool wantStencil) | 148 bool wantStencil) |
| 149 : m_preserveDrawingBuffer(preserve) | 149 : m_preserveDrawingBuffer(preserve) |
| 150 , m_webGLVersion(webGLVersion) | 150 , m_webGLVersion(webGLVersion) |
| 151 , m_contextProvider(std::move(contextProvider)) | 151 , m_contextProvider(std::move(contextProvider)) |
| 152 , m_gl(m_contextProvider->contextGL()) | 152 , m_gl(m_contextProvider->contextGL()) |
| 153 , m_extensionsUtil(std::move(extensionsUtil)) | 153 , m_extensionsUtil(std::move(extensionsUtil)) |
| 154 , m_discardFramebufferSupported(discardFramebufferSupported) | 154 , m_discardFramebufferSupported(discardFramebufferSupported) |
| 155 , m_wantAlphaChannel(wantAlphaChannel) | 155 , m_wantAlphaChannel(wantAlphaChannel) |
| 156 , m_premultipliedAlpha(premultipliedAlpha) | 156 , m_premultipliedAlpha(premultipliedAlpha) |
| 157 , m_softwareRendering(m_contextProvider->isSoftwareRendering()) |
| 157 , m_wantDepth(wantDepth) | 158 , m_wantDepth(wantDepth) |
| 158 , m_wantStencil(wantStencil) | 159 , m_wantStencil(wantStencil) |
| 159 { | 160 { |
| 160 memset(m_colorMask, 0, 4 * sizeof(GLboolean)); | 161 memset(m_colorMask, 0, 4 * sizeof(GLboolean)); |
| 161 memset(m_clearColor, 0, 4 * sizeof(GLfloat)); | 162 memset(m_clearColor, 0, 4 * sizeof(GLfloat)); |
| 162 // Used by browser tests to detect the use of a DrawingBuffer. | 163 // Used by browser tests to detect the use of a DrawingBuffer. |
| 163 TRACE_EVENT_INSTANT0("test_gpu", "DrawingBufferCreation", TRACE_EVENT_SCOPE_
GLOBAL); | 164 TRACE_EVENT_INSTANT0("test_gpu", "DrawingBufferCreation", TRACE_EVENT_SCOPE_
GLOBAL); |
| 164 } | 165 } |
| 165 | 166 |
| 166 DrawingBuffer::~DrawingBuffer() | 167 DrawingBuffer::~DrawingBuffer() |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 // 1. WebGL draws something. | 270 // 1. WebGL draws something. |
| 270 // 2. The compositor begins the frame. | 271 // 2. The compositor begins the frame. |
| 271 // 3. Javascript makes a context lost using WEBGL_lose_context extension
. | 272 // 3. Javascript makes a context lost using WEBGL_lose_context extension
. |
| 272 // 4. Here. | 273 // 4. Here. |
| 273 return false; | 274 return false; |
| 274 } | 275 } |
| 275 ASSERT(!m_isHidden); | 276 ASSERT(!m_isHidden); |
| 276 if (!m_contentsChanged) | 277 if (!m_contentsChanged) |
| 277 return false; | 278 return false; |
| 278 | 279 |
| 280 // If the context is lost, we don't know if we should be producing GPU or |
| 281 // software frames, until we get a new context, since the compositor will |
| 282 // be trying to get a new context and may change modes. |
| 283 if (m_gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) |
| 284 return false; |
| 285 |
| 279 TRACE_EVENT0("blink,rail", "DrawingBuffer::prepareMailbox"); | 286 TRACE_EVENT0("blink,rail", "DrawingBuffer::prepareMailbox"); |
| 280 | 287 |
| 281 if (m_newMailboxCallback) | 288 if (m_newMailboxCallback) |
| 282 (*m_newMailboxCallback)(); | 289 (*m_newMailboxCallback)(); |
| 283 | 290 |
| 284 // Resolve the multisampled buffer into m_colorBuffer texture. | 291 // Resolve the multisampled buffer into m_colorBuffer texture. |
| 285 if (m_antiAliasingMode != None) | 292 if (m_antiAliasingMode != None) |
| 286 commit(); | 293 commit(); |
| 287 | 294 |
| 288 if (useSharedMemory) { | 295 if (m_softwareRendering) { |
| 289 std::unique_ptr<cc::SharedBitmap> bitmap = createOrRecycleBitmap(); | 296 std::unique_ptr<cc::SharedBitmap> bitmap = createOrRecycleBitmap(); |
| 290 if (!bitmap) | 297 if (!bitmap) |
| 291 return false; | 298 return false; |
| 292 unsigned char* pixels = bitmap->pixels(); | 299 unsigned char* pixels = bitmap->pixels(); |
| 293 DCHECK(pixels); | 300 DCHECK(pixels); |
| 294 | 301 |
| 295 bool needPremultiply = m_wantAlphaChannel && !m_premultipliedAlpha; | 302 bool needPremultiply = m_wantAlphaChannel && !m_premultipliedAlpha; |
| 296 WebGLImageConversion::AlphaOp op = needPremultiply ? WebGLImageConversio
n::AlphaDoPremultiply : WebGLImageConversion::AlphaDoNothing; | 303 WebGLImageConversion::AlphaOp op = needPremultiply ? WebGLImageConversio
n::AlphaDoPremultiply : WebGLImageConversion::AlphaDoNothing; |
| 297 readBackFramebuffer(pixels, size().width(), size().height(), ReadbackSki
a, op); | 304 readBackFramebuffer(pixels, size().width(), size().height(), ReadbackSki
a, op); |
| 298 | 305 |
| (...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1213 | 1220 |
| 1214 void DrawingBuffer::restoreTextureBindings() | 1221 void DrawingBuffer::restoreTextureBindings() |
| 1215 { | 1222 { |
| 1216 // This class potentially modifies the bindings for GL_TEXTURE_2D and | 1223 // This class potentially modifies the bindings for GL_TEXTURE_2D and |
| 1217 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since | 1224 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since |
| 1218 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE. | 1225 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE. |
| 1219 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); | 1226 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); |
| 1220 } | 1227 } |
| 1221 | 1228 |
| 1222 } // namespace blink | 1229 } // namespace blink |
| OLD | NEW |