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

Side by Side Diff: Source/platform/graphics/gpu/DrawingBuffer.cpp

Issue 1160493002: Determine WebGL back-buffer on Mali-400 GPU Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 7 months 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
« no previous file with comments | « Source/platform/graphics/gpu/DrawingBuffer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 extensionsUtil->ensureExtensionEnabled("GL_EXT_multisampled_render_t o_texture"); 98 extensionsUtil->ensureExtensionEnabled("GL_EXT_multisampled_render_t o_texture");
99 } 99 }
100 bool packedDepthStencilSupported = extensionsUtil->supportsExtension("GL_OES _packed_depth_stencil"); 100 bool packedDepthStencilSupported = extensionsUtil->supportsExtension("GL_OES _packed_depth_stencil");
101 if (packedDepthStencilSupported) 101 if (packedDepthStencilSupported)
102 extensionsUtil->ensureExtensionEnabled("GL_OES_packed_depth_stencil"); 102 extensionsUtil->ensureExtensionEnabled("GL_OES_packed_depth_stencil");
103 bool discardFramebufferSupported = extensionsUtil->supportsExtension("GL_EXT _discard_framebuffer"); 103 bool discardFramebufferSupported = extensionsUtil->supportsExtension("GL_EXT _discard_framebuffer");
104 if (discardFramebufferSupported) 104 if (discardFramebufferSupported)
105 extensionsUtil->ensureExtensionEnabled("GL_EXT_discard_framebuffer"); 105 extensionsUtil->ensureExtensionEnabled("GL_EXT_discard_framebuffer");
106 106
107 RefPtr<DrawingBuffer> drawingBuffer = adoptRef(new DrawingBuffer(context, ex tensionsUtil.release(), multisampleSupported, packedDepthStencilSupported, disca rdFramebufferSupported, preserve, requestedAttributes)); 107 RefPtr<DrawingBuffer> drawingBuffer = adoptRef(new DrawingBuffer(context, ex tensionsUtil.release(), multisampleSupported, packedDepthStencilSupported, disca rdFramebufferSupported, preserve, requestedAttributes));
108 Platform::current()->getGPUBlackList(&drawingBuffer->m_gpuBlackList);
109 // determineRGBTextureSupport() if GL_RGB not supported
110 if (!drawingBuffer->gpuBlackList().IsRGBTextureSupported())
111 drawingBuffer->determineRGBTextureSupport();
112
108 if (!drawingBuffer->initialize(size)) { 113 if (!drawingBuffer->initialize(size)) {
109 drawingBuffer->beginDestruction(); 114 drawingBuffer->beginDestruction();
110 return PassRefPtr<DrawingBuffer>(); 115 return PassRefPtr<DrawingBuffer>();
111 } 116 }
112 return drawingBuffer.release(); 117 return drawingBuffer.release();
113 } 118 }
114 119
115 DrawingBuffer::DrawingBuffer(PassOwnPtr<WebGraphicsContext3D> context, 120 DrawingBuffer::DrawingBuffer(PassOwnPtr<WebGraphicsContext3D> context,
116 PassOwnPtr<Extensions3DUtil> extensionsUtil, 121 PassOwnPtr<Extensions3DUtil> extensionsUtil,
117 bool multisampleExtensionSupported, 122 bool multisampleExtensionSupported,
(...skipping 25 matching lines...) Expand all
143 , m_multisampleMode(None) 148 , m_multisampleMode(None)
144 , m_internalColorFormat(0) 149 , m_internalColorFormat(0)
145 , m_colorFormat(0) 150 , m_colorFormat(0)
146 , m_internalRenderbufferFormat(0) 151 , m_internalRenderbufferFormat(0)
147 , m_maxTextureSize(0) 152 , m_maxTextureSize(0)
148 , m_sampleCount(0) 153 , m_sampleCount(0)
149 , m_packAlignment(4) 154 , m_packAlignment(4)
150 , m_destructionInProgress(false) 155 , m_destructionInProgress(false)
151 , m_isHidden(false) 156 , m_isHidden(false)
152 , m_filterQuality(kLow_SkFilterQuality) 157 , m_filterQuality(kLow_SkFilterQuality)
158 , m_RGBTextureSupported(true)
153 { 159 {
154 // Used by browser tests to detect the use of a DrawingBuffer. 160 // Used by browser tests to detect the use of a DrawingBuffer.
155 TRACE_EVENT_INSTANT0("test_gpu", "DrawingBufferCreation", TRACE_EVENT_SCOPE_ GLOBAL); 161 TRACE_EVENT_INSTANT0("test_gpu", "DrawingBufferCreation", TRACE_EVENT_SCOPE_ GLOBAL);
156 #ifndef NDEBUG 162 #ifndef NDEBUG
157 drawingBufferCounter.increment(); 163 drawingBufferCounter.increment();
158 #endif 164 #endif
159 } 165 }
160 166
161 DrawingBuffer::~DrawingBuffer() 167 DrawingBuffer::~DrawingBuffer()
162 { 168 {
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 ASSERT_NOT_REACHED(); 402 ASSERT_NOT_REACHED();
397 } 403 }
398 404
399 bool DrawingBuffer::initialize(const IntSize& size) 405 bool DrawingBuffer::initialize(const IntSize& size)
400 { 406 {
401 if (m_context->isContextLost()) { 407 if (m_context->isContextLost()) {
402 // Need to try to restore the context again later. 408 // Need to try to restore the context again later.
403 return false; 409 return false;
404 } 410 }
405 411
406 if (m_requestedAttributes.alpha) { 412 if (m_requestedAttributes.alpha || !isRGBTextureSupported()) {
407 m_internalColorFormat = GL_RGBA; 413 m_internalColorFormat = GL_RGBA;
408 m_colorFormat = GL_RGBA; 414 m_colorFormat = GL_RGBA;
409 m_internalRenderbufferFormat = GL_RGBA8_OES; 415 m_internalRenderbufferFormat = GL_RGBA8_OES;
410 } else { 416 } else {
411 m_internalColorFormat = GL_RGB; 417 m_internalColorFormat = GL_RGB;
412 m_colorFormat = GL_RGB; 418 m_colorFormat = GL_RGB;
413 m_internalRenderbufferFormat = GL_RGB8_OES; 419 m_internalRenderbufferFormat = GL_RGB8_OES;
414 } 420 }
415 421
416 m_context->getIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize); 422 m_context->getIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize);
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 void DrawingBuffer::clearFramebuffers(GLbitfield clearMask) 714 void DrawingBuffer::clearFramebuffers(GLbitfield clearMask)
709 { 715 {
710 // We will clear the multisample FBO, but we also need to clear the non-mult isampled buffer. 716 // We will clear the multisample FBO, but we also need to clear the non-mult isampled buffer.
711 if (m_multisampleFBO) { 717 if (m_multisampleFBO) {
712 m_context->bindFramebuffer(GL_FRAMEBUFFER, m_fbo); 718 m_context->bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
713 m_context->clear(GL_COLOR_BUFFER_BIT); 719 m_context->clear(GL_COLOR_BUFFER_BIT);
714 } 720 }
715 721
716 m_context->bindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO ? m_multisampleF BO : m_fbo); 722 m_context->bindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO ? m_multisampleF BO : m_fbo);
717 m_context->clear(clearMask); 723 m_context->clear(clearMask);
724
725 if (!m_requestedAttributes.alpha && !isRGBTextureSupported())
726 m_context->colorMask(true, true, true, false);
718 } 727 }
719 728
720 void DrawingBuffer::setSize(const IntSize& size) 729 void DrawingBuffer::setSize(const IntSize& size)
721 { 730 {
722 if (m_size == size) 731 if (m_size == size)
723 return; 732 return;
724 733
725 m_size = size; 734 m_size = size;
726 } 735 }
727 736
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 989
981 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) 990 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info)
982 { 991 {
983 if (info->imageId) { 992 if (info->imageId) {
984 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId); 993 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId);
985 m_context->destroyImageCHROMIUM(info->imageId); 994 m_context->destroyImageCHROMIUM(info->imageId);
986 info->imageId = 0; 995 info->imageId = 0;
987 } 996 }
988 } 997 }
989 998
999 void DrawingBuffer::determineRGBTextureSupport()
1000 {
1001 // One time validation is required for GL_RGB texture
1002 // so that DrawingBuffer can choose format for the backbuffer correctly.
1003 // DrawingBuffer tries to allocate GL_RGB texture in case of alpha attribute false
1004 // and fails because GL_RGB not supported on specific GPU's (e.g Mali- 2/3/4 00 family).
1005 Platform3DObject fbo = m_context->createFramebuffer();
1006 m_context->bindFramebuffer(GL_FRAMEBUFFER, fbo);
1007 unsigned offscreenRGBTexture = createColorTexture();
1008 m_context->texImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED _BYTE, 0);
1009 m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEX TURE_2D, offscreenRGBTexture, 0);
1010 m_RGBTextureSupported = m_context->checkFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE;
1011
1012 if (fbo) {
1013 m_context->deleteFramebuffer(fbo);
1014 m_context->bindFramebuffer(GL_FRAMEBUFFER, 0);
1015 }
1016
1017 if (offscreenRGBTexture)
1018 m_context->deleteTexture(offscreenRGBTexture);
1019 }
1020
990 } // namespace blink 1021 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/graphics/gpu/DrawingBuffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698