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

Side by Side Diff: ui/accelerated_widget_mac/io_surface_texture.mm

Issue 1164363005: Mac: Only allow NSOpenGLContext displaying on the main display (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add GPU switch Created 5 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
« no previous file with comments | « ui/accelerated_widget_mac/io_surface_texture.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 // 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 "ui/accelerated_widget_mac/io_surface_texture.h" 5 #include "ui/accelerated_widget_mac/io_surface_texture.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/gl.h> 9 #include <OpenGL/gl.h>
10 #include <OpenGL/OpenGL.h> 10 #include <OpenGL/OpenGL.h>
(...skipping 11 matching lines...) Expand all
22 #include "ui/accelerated_widget_mac/io_surface_context.h" 22 #include "ui/accelerated_widget_mac/io_surface_context.h"
23 #include "ui/base/ui_base_switches.h" 23 #include "ui/base/ui_base_switches.h"
24 #include "ui/gfx/geometry/rect.h" 24 #include "ui/gfx/geometry/rect.h"
25 #include "ui/gfx/geometry/size_conversions.h" 25 #include "ui/gfx/geometry/size_conversions.h"
26 #include "ui/gl/gl_context.h" 26 #include "ui/gl/gl_context.h"
27 27
28 namespace ui { 28 namespace ui {
29 29
30 // static 30 // static
31 scoped_refptr<IOSurfaceTexture> IOSurfaceTexture::Create( 31 scoped_refptr<IOSurfaceTexture> IOSurfaceTexture::Create(
32 bool needs_gl_finish_workaround) { 32 bool needs_gl_finish_workaround,
33 static bool use_ns_gl_surfaces = 33 bool use_ns_apis) {
34 base::CommandLine::ForCurrentProcess()->HasSwitch(
35 switches::kEnableNSGLSurfaces);
36 scoped_refptr<IOSurfaceContext> offscreen_context; 34 scoped_refptr<IOSurfaceContext> offscreen_context;
37 if (!use_ns_gl_surfaces) { 35 if (!use_ns_apis) {
38 offscreen_context = IOSurfaceContext::Get( 36 offscreen_context = IOSurfaceContext::Get(
39 IOSurfaceContext::kOffscreenContext); 37 IOSurfaceContext::kOffscreenContext);
40 if (!offscreen_context.get()) { 38 if (!offscreen_context.get()) {
41 LOG(ERROR) << "Failed to create context for offscreen operations"; 39 LOG(ERROR) << "Failed to create context for offscreen operations";
42 return NULL; 40 return NULL;
43 } 41 }
44 } 42 }
45 return new IOSurfaceTexture(offscreen_context, needs_gl_finish_workaround); 43 return new IOSurfaceTexture(
44 offscreen_context, use_ns_apis, needs_gl_finish_workaround);
46 } 45 }
47 46
48 IOSurfaceTexture::IOSurfaceTexture( 47 IOSurfaceTexture::IOSurfaceTexture(
49 const scoped_refptr<IOSurfaceContext>& offscreen_context, 48 const scoped_refptr<IOSurfaceContext>& offscreen_context,
49 bool use_ns_apis,
50 bool needs_gl_finish_workaround) 50 bool needs_gl_finish_workaround)
51 : offscreen_context_(offscreen_context), 51 : offscreen_context_(offscreen_context),
52 texture_(0), 52 texture_(0),
53 gl_error_(GL_NO_ERROR), 53 gl_error_(GL_NO_ERROR),
54 eviction_queue_iterator_(eviction_queue_.Get().end()), 54 eviction_queue_iterator_(eviction_queue_.Get().end()),
55 eviction_has_been_drawn_since_updated_(false), 55 eviction_has_been_drawn_since_updated_(false),
56 needs_gl_finish_workaround_(needs_gl_finish_workaround) { 56 needs_gl_finish_workaround_(needs_gl_finish_workaround),
57 using_ns_apis_(use_ns_apis) {
57 } 58 }
58 59
59 IOSurfaceTexture::~IOSurfaceTexture() { 60 IOSurfaceTexture::~IOSurfaceTexture() {
60 ReleaseIOSurfaceAndTexture(); 61 ReleaseIOSurfaceAndTexture();
61 offscreen_context_ = NULL; 62 offscreen_context_ = NULL;
62 DCHECK(eviction_queue_iterator_ == eviction_queue_.Get().end()); 63 DCHECK(eviction_queue_iterator_ == eviction_queue_.Get().end());
63 } 64 }
64 65
65 bool IOSurfaceTexture::DrawIOSurface() { 66 bool IOSurfaceTexture::DrawIOSurface() {
66 return DrawIOSurfaceWithDamageRect(gfx::Rect(pixel_size_)); 67 return DrawIOSurfaceWithDamageRect(gfx::Rect(pixel_size_));
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 } 316 }
316 317
317 // static 318 // static
318 base::LazyInstance<IOSurfaceTexture::EvictionQueue> 319 base::LazyInstance<IOSurfaceTexture::EvictionQueue>
319 IOSurfaceTexture::eviction_queue_; 320 IOSurfaceTexture::eviction_queue_;
320 321
321 // static 322 // static
322 bool IOSurfaceTexture::eviction_scheduled_ = false; 323 bool IOSurfaceTexture::eviction_scheduled_ = false;
323 324
324 } // namespace ui 325 } // namespace ui
OLDNEW
« no previous file with comments | « ui/accelerated_widget_mac/io_surface_texture.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698