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

Side by Side Diff: content/browser/renderer_host/compositing_iosurface_mac.mm

Issue 311263003: Delete non-CoreAnimation code in RWHVMac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@swappressure
Patch Set: Update driver bug Created 6 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser/renderer_host/compositing_iosurface_mac.h" 5 #include "content/browser/renderer_host/compositing_iosurface_mac.h"
6 6
7 #include <OpenGL/CGLIOSurface.h> 7 #include <OpenGL/CGLIOSurface.h>
8 #include <OpenGL/CGLRenderers.h> 8 #include <OpenGL/CGLRenderers.h>
9 #include <OpenGL/OpenGL.h> 9 #include <OpenGL/OpenGL.h>
10 10
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 if (CGLGetParameter(offscreen_context_->cgl_context(), 276 if (CGLGetParameter(offscreen_context_->cgl_context(),
277 kCGLCPCurrentRendererID, 277 kCGLCPCurrentRendererID,
278 &current_renderer_id) == kCGLNoError) 278 &current_renderer_id) == kCGLNoError)
279 return current_renderer_id & kCGLRendererIDMatchingMask; 279 return current_renderer_id & kCGLRendererIDMatchingMask;
280 return -1; 280 return -1;
281 } 281 }
282 282
283 bool CompositingIOSurfaceMac::DrawIOSurface( 283 bool CompositingIOSurfaceMac::DrawIOSurface(
284 scoped_refptr<CompositingIOSurfaceContext> drawing_context, 284 scoped_refptr<CompositingIOSurfaceContext> drawing_context,
285 const gfx::Rect& window_rect, 285 const gfx::Rect& window_rect,
286 float window_scale_factor, 286 float window_scale_factor) {
287 bool flush_drawable) {
288 DCHECK_EQ(CGLGetCurrentContext(), drawing_context->cgl_context()); 287 DCHECK_EQ(CGLGetCurrentContext(), drawing_context->cgl_context());
289 288
290 bool has_io_surface = HasIOSurface(); 289 bool has_io_surface = HasIOSurface();
291 TRACE_EVENT1("browser", "CompositingIOSurfaceMac::DrawIOSurface", 290 TRACE_EVENT1("browser", "CompositingIOSurfaceMac::DrawIOSurface",
292 "has_io_surface", has_io_surface); 291 "has_io_surface", has_io_surface);
293 292
294 gfx::Rect pixel_window_rect = 293 gfx::Rect pixel_window_rect =
295 ToNearestRect(gfx::ScaleRect(window_rect, window_scale_factor)); 294 ToNearestRect(gfx::ScaleRect(window_rect, window_scale_factor));
296 glViewport( 295 glViewport(
297 pixel_window_rect.x(), pixel_window_rect.y(), 296 pixel_window_rect.x(), pixel_window_rect.y(),
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 glUseProgram(0); CHECK_AND_SAVE_GL_ERROR(); 350 glUseProgram(0); CHECK_AND_SAVE_GL_ERROR();
352 } else { 351 } else {
353 // Should match the clear color of RenderWidgetHostViewMac. 352 // Should match the clear color of RenderWidgetHostViewMac.
354 glClearColor(1.0f, 1.0f, 1.0f, 1.0f); 353 glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
355 glClear(GL_COLOR_BUFFER_BIT); 354 glClear(GL_COLOR_BUFFER_BIT);
356 } 355 }
357 356
358 bool workaround_needed = 357 bool workaround_needed =
359 GpuDataManagerImpl::GetInstance()->IsDriverBugWorkaroundActive( 358 GpuDataManagerImpl::GetInstance()->IsDriverBugWorkaroundActive(
360 gpu::FORCE_GL_FINISH_AFTER_COMPOSITING); 359 gpu::FORCE_GL_FINISH_AFTER_COMPOSITING);
361 // Note that this is not necessary when not flushing the drawable in Mavericks
362 // or later if we are in one of the two following situations:
363 // - we are drawing an underlay, and we will call glFinish() when drawing
364 // the overlay.
365 // - we are using CoreAnimation, where this bug does not manifest.
366 if (workaround_needed && !flush_drawable && base::mac::IsOSMavericksOrLater())
367 workaround_needed = false;
368
369 if (workaround_needed) { 360 if (workaround_needed) {
370 TRACE_EVENT0("gpu", "glFinish"); 361 TRACE_EVENT0("gpu", "glFinish");
371 glFinish(); 362 glFinish();
372 } 363 }
373 364
374 bool result = true;
375 if (flush_drawable) {
376 TRACE_EVENT0("gpu", "flushBuffer");
377 [drawing_context->nsgl_context() flushBuffer];
378 }
379
380 // Check if any of the drawing calls result in an error. 365 // Check if any of the drawing calls result in an error.
381 GetAndSaveGLError(); 366 GetAndSaveGLError();
367 bool result = true;
382 if (gl_error_ != GL_NO_ERROR) { 368 if (gl_error_ != GL_NO_ERROR) {
383 LOG(ERROR) << "GL error in DrawIOSurface: " << gl_error_; 369 LOG(ERROR) << "GL error in DrawIOSurface: " << gl_error_;
384 result = false; 370 result = false;
385 // If there was an error, clear the screen to a light grey to avoid 371 // If there was an error, clear the screen to a light grey to avoid
386 // rendering artifacts. If we're in a really bad way, this too may 372 // rendering artifacts. If we're in a really bad way, this too may
387 // generate an error. Clear the GL error afterwards just in case. 373 // generate an error. Clear the GL error afterwards just in case.
388 glClearColor(0.8, 0.8, 0.8, 1.0); 374 glClearColor(0.8, 0.8, 0.8, 1.0);
389 glClear(GL_COLOR_BUFFER_BIT); 375 glClear(GL_COLOR_BUFFER_BIT);
390 glGetError(); 376 glGetError();
391 } 377 }
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 void CompositingIOSurfaceMac::EvictionMarkEvicted() { 914 void CompositingIOSurfaceMac::EvictionMarkEvicted() {
929 if (eviction_queue_iterator_ == eviction_queue_.Get().end()) 915 if (eviction_queue_iterator_ == eviction_queue_.Get().end())
930 return; 916 return;
931 eviction_queue_.Get().erase(eviction_queue_iterator_); 917 eviction_queue_.Get().erase(eviction_queue_iterator_);
932 eviction_queue_iterator_ = eviction_queue_.Get().end(); 918 eviction_queue_iterator_ = eviction_queue_.Get().end();
933 eviction_has_been_drawn_since_updated_ = false; 919 eviction_has_been_drawn_since_updated_ = false;
934 } 920 }
935 921
936 // static 922 // static
937 void CompositingIOSurfaceMac::EvictionScheduleDoEvict() { 923 void CompositingIOSurfaceMac::EvictionScheduleDoEvict() {
938 if (GetCoreAnimationStatus() == CORE_ANIMATION_DISABLED)
939 return;
940 if (eviction_scheduled_) 924 if (eviction_scheduled_)
941 return; 925 return;
942 if (eviction_queue_.Get().size() <= kMaximumUnevictedSurfaces) 926 if (eviction_queue_.Get().size() <= kMaximumUnevictedSurfaces)
943 return; 927 return;
944 928
945 eviction_scheduled_ = true; 929 eviction_scheduled_ = true;
946 base::MessageLoop::current()->PostTask( 930 base::MessageLoop::current()->PostTask(
947 FROM_HERE, 931 FROM_HERE,
948 base::Bind(&CompositingIOSurfaceMac::EvictionDoEvict)); 932 base::Bind(&CompositingIOSurfaceMac::EvictionDoEvict));
949 } 933 }
(...skipping 27 matching lines...) Expand all
977 } 961 }
978 962
979 // static 963 // static
980 base::LazyInstance<CompositingIOSurfaceMac::EvictionQueue> 964 base::LazyInstance<CompositingIOSurfaceMac::EvictionQueue>
981 CompositingIOSurfaceMac::eviction_queue_; 965 CompositingIOSurfaceMac::eviction_queue_;
982 966
983 // static 967 // static
984 bool CompositingIOSurfaceMac::eviction_scheduled_ = false; 968 bool CompositingIOSurfaceMac::eviction_scheduled_ = false;
985 969
986 } // namespace content 970 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698