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

Side by Side Diff: content/common/gpu/image_transport_surface_calayer_mac.mm

Issue 783713002: Log serious OpenGL errors in remote CoreAnimation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « no previous file | 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/common/gpu/image_transport_surface_calayer_mac.h" 5 #include "content/common/gpu/image_transport_surface_calayer_mac.h"
6 6
7 #include <OpenGL/CGLRenderers.h> 7 #include <OpenGL/CGLRenderers.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/mac/sdk_forward_declarations.h" 10 #include "base/mac/sdk_forward_declarations.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 storageProvider_->LayerShareGroupContext())); 48 storageProvider_->LayerShareGroupContext()));
49 } 49 }
50 50
51 - (CGLContextObj)copyCGLContextForPixelFormat:(CGLPixelFormatObj)pixelFormat { 51 - (CGLContextObj)copyCGLContextForPixelFormat:(CGLPixelFormatObj)pixelFormat {
52 if (!storageProvider_) 52 if (!storageProvider_)
53 return NULL; 53 return NULL;
54 CGLContextObj context = NULL; 54 CGLContextObj context = NULL;
55 CGLError error = CGLCreateContext( 55 CGLError error = CGLCreateContext(
56 pixelFormat, storageProvider_->LayerShareGroupContext(), &context); 56 pixelFormat, storageProvider_->LayerShareGroupContext(), &context);
57 if (error != kCGLNoError) 57 if (error != kCGLNoError)
58 DLOG(ERROR) << "CGLCreateContext failed with CGL error: " << error; 58 LOG(ERROR) << "CGLCreateContext failed with CGL error: " << error;
59 return context; 59 return context;
60 } 60 }
61 61
62 - (BOOL)canDrawInCGLContext:(CGLContextObj)glContext 62 - (BOOL)canDrawInCGLContext:(CGLContextObj)glContext
63 pixelFormat:(CGLPixelFormatObj)pixelFormat 63 pixelFormat:(CGLPixelFormatObj)pixelFormat
64 forLayerTime:(CFTimeInterval)timeInterval 64 forLayerTime:(CFTimeInterval)timeInterval
65 displayTime:(const CVTimeStamp*)timeStamp { 65 displayTime:(const CVTimeStamp*)timeStamp {
66 if (!storageProvider_) 66 if (!storageProvider_)
67 return NO; 67 return NO;
68 return storageProvider_->LayerCanDraw(); 68 return storageProvider_->LayerCanDraw();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 gfx::Size CALayerStorageProvider::GetRoundedSize(gfx::Size size) { 114 gfx::Size CALayerStorageProvider::GetRoundedSize(gfx::Size size) {
115 return size; 115 return size;
116 } 116 }
117 117
118 bool CALayerStorageProvider::AllocateColorBufferStorage( 118 bool CALayerStorageProvider::AllocateColorBufferStorage(
119 CGLContextObj context, GLuint texture, 119 CGLContextObj context, GLuint texture,
120 gfx::Size pixel_size, float scale_factor) { 120 gfx::Size pixel_size, float scale_factor) {
121 // Allocate an ordinary OpenGL texture to back the FBO. 121 // Allocate an ordinary OpenGL texture to back the FBO.
122 GLenum error; 122 GLenum error;
123 while ((error = glGetError()) != GL_NO_ERROR) { 123 while ((error = glGetError()) != GL_NO_ERROR) {
124 DLOG(ERROR) << "Error found (and ignored) before allocating buffer " 124 LOG(ERROR) << "OpenGL error hit but ignored before allocating buffer "
125 << "storage: " << error; 125 << "storage: " << error;
126 } 126 }
127 glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 127 glTexImage2D(GL_TEXTURE_RECTANGLE_ARB,
128 0, 128 0,
129 GL_RGBA, 129 GL_RGBA,
130 pixel_size.width(), 130 pixel_size.width(),
131 pixel_size.height(), 131 pixel_size.height(),
132 0, 132 0,
133 GL_RGBA, 133 GL_RGBA,
134 GL_UNSIGNED_BYTE, 134 GL_UNSIGNED_BYTE,
135 NULL); 135 NULL);
136 error = glGetError(); 136 glFlush();
137 if (error != GL_NO_ERROR) { 137
138 DLOG(ERROR) << "glTexImage failed with GL error: " << error; 138 bool hit_error = false;
139 while ((error = glGetError()) != GL_NO_ERROR) {
140 LOG(ERROR) << "OpenGL error hit while trying to allocate buffer storage: "
141 << error;
142 hit_error = true;
143 }
144 if (hit_error)
139 return false; 145 return false;
140 }
141 glFlush();
142 146
143 // Set the parameters that will be used to allocate the CALayer to draw the 147 // Set the parameters that will be used to allocate the CALayer to draw the
144 // texture into. 148 // texture into.
145 share_group_context_.reset(CGLRetainContext(context)); 149 share_group_context_.reset(CGLRetainContext(context));
146 fbo_texture_ = texture; 150 fbo_texture_ = texture;
147 fbo_pixel_size_ = pixel_size; 151 fbo_pixel_size_ = pixel_size;
148 fbo_scale_factor_ = scale_factor; 152 fbo_scale_factor_ = scale_factor;
149 return true; 153 return true;
150 } 154 }
151 155
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 glDisable(GL_TEXTURE_RECTANGLE_ARB); 340 glDisable(GL_TEXTURE_RECTANGLE_ARB);
337 341
338 GLint current_renderer_id = 0; 342 GLint current_renderer_id = 0;
339 if (CGLGetParameter(CGLGetCurrentContext(), 343 if (CGLGetParameter(CGLGetCurrentContext(),
340 kCGLCPCurrentRendererID, 344 kCGLCPCurrentRendererID,
341 &current_renderer_id) == kCGLNoError) { 345 &current_renderer_id) == kCGLNoError) {
342 current_renderer_id &= kCGLRendererIDMatchingMask; 346 current_renderer_id &= kCGLRendererIDMatchingMask;
343 transport_surface_->SetRendererID(current_renderer_id); 347 transport_surface_->SetRendererID(current_renderer_id);
344 } 348 }
345 349
350 GLenum error;
351 while ((error = glGetError()) != GL_NO_ERROR) {
352 LOG(ERROR) << "OpenGL error hit while drawing frame: " << error;
353 }
354
346 // Allow forward progress in the context now that the swap is complete. 355 // Allow forward progress in the context now that the swap is complete.
347 UnblockBrowserIfNeeded(); 356 UnblockBrowserIfNeeded();
348 } 357 }
349 358
350 void CALayerStorageProvider::LayerResetStorageProvider() { 359 void CALayerStorageProvider::LayerResetStorageProvider() {
351 // If we are providing back-pressure by waiting for a draw, that draw will 360 // If we are providing back-pressure by waiting for a draw, that draw will
352 // now never come, so release the pressure now. 361 // now never come, so release the pressure now.
353 UnblockBrowserIfNeeded(); 362 UnblockBrowserIfNeeded();
354 } 363 }
355 364
356 void CALayerStorageProvider::OnGpuSwitched() { 365 void CALayerStorageProvider::OnGpuSwitched() {
357 recreate_layer_after_gpu_switch_ = true; 366 recreate_layer_after_gpu_switch_ = true;
358 } 367 }
359 368
360 void CALayerStorageProvider::UnblockBrowserIfNeeded() { 369 void CALayerStorageProvider::UnblockBrowserIfNeeded() {
361 if (!has_pending_draw_) 370 if (!has_pending_draw_)
362 return; 371 return;
363 pending_draw_weak_factory_.InvalidateWeakPtrs(); 372 pending_draw_weak_factory_.InvalidateWeakPtrs();
364 has_pending_draw_ = false; 373 has_pending_draw_ = false;
365 transport_surface_->SendSwapBuffers( 374 transport_surface_->SendSwapBuffers(
366 ui::SurfaceHandleFromCAContextID([context_ contextId]), 375 ui::SurfaceHandleFromCAContextID([context_ contextId]),
367 fbo_pixel_size_, 376 fbo_pixel_size_,
368 fbo_scale_factor_); 377 fbo_scale_factor_);
369 } 378 }
370 379
371 } // namespace content 380 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698