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

Side by Side Diff: ui/compositor/mac/io_surface_texture_mac.mm

Issue 753933002: MacViews: Move content::AcceleratedWidget to new component, ui/accelerated_widget_mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@20141124-MacViews-MoveSoftwareLayerMac-fromcl
Patch Set: nit DEPS, deps and gn 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
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/compositor/io_surface_texture_mac.h" 5 #include "ui/compositor/mac/io_surface_texture_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/gl.h>
9 #include <OpenGL/OpenGL.h> 10 #include <OpenGL/OpenGL.h>
10 #include <OpenGL/gl.h>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/bind_helpers.h" 13 #include "base/bind_helpers.h"
14 #include "base/callback_helpers.h" 14 #include "base/callback_helpers.h"
15 #include "base/debug/trace_event.h" 15 #include "base/debug/trace_event.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/mac/bind_objc_block.h" 17 #include "base/mac/bind_objc_block.h"
18 #include "base/mac/mac_util.h" 18 #include "base/mac/mac_util.h"
19 #include "base/message_loop/message_loop.h" 19 #include "base/message_loop/message_loop.h"
20 #include "base/threading/platform_thread.h" 20 #include "base/threading/platform_thread.h"
21 #include "content/browser/compositor/io_surface_context_mac.h"
22 #include "content/browser/gpu/gpu_data_manager_impl.h"
23 #include "content/browser/renderer_host/render_widget_host_impl.h"
24 #include "content/browser/renderer_host/render_widget_host_view_mac.h"
25 #include "content/common/content_constants_internal.h"
26 #include "gpu/config/gpu_driver_bug_workaround_type.h"
27 #include "media/base/video_util.h"
28 #include "third_party/skia/include/core/SkBitmap.h" 21 #include "third_party/skia/include/core/SkBitmap.h"
22 #include "ui/compositor/mac/io_surface_context_mac.h"
29 #include "ui/gfx/rect.h" 23 #include "ui/gfx/rect.h"
30 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" 24 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
31 #include "ui/gfx/size_conversions.h" 25 #include "ui/gfx/size_conversions.h"
32 #include "ui/gl/gl_context.h" 26 #include "ui/gl/gl_context.h"
33 27
34 namespace content { 28 namespace content {
35 29
36 // static 30 // static
37 scoped_refptr<IOSurfaceTexture> IOSurfaceTexture::Create() { 31 scoped_refptr<IOSurfaceTexture> IOSurfaceTexture::Create(
32 bool needs_gl_finish_workaround) {
38 scoped_refptr<IOSurfaceContext> offscreen_context = 33 scoped_refptr<IOSurfaceContext> offscreen_context =
39 IOSurfaceContext::Get( 34 IOSurfaceContext::Get(
40 IOSurfaceContext::kOffscreenContext); 35 IOSurfaceContext::kOffscreenContext);
41 if (!offscreen_context.get()) { 36 if (!offscreen_context.get()) {
42 LOG(ERROR) << "Failed to create context for offscreen operations"; 37 LOG(ERROR) << "Failed to create context for offscreen operations";
43 return NULL; 38 return NULL;
44 } 39 }
45 40
46 return new IOSurfaceTexture(offscreen_context); 41 return new IOSurfaceTexture(offscreen_context, needs_gl_finish_workaround);
47 } 42 }
48 43
49 IOSurfaceTexture::IOSurfaceTexture( 44 IOSurfaceTexture::IOSurfaceTexture(
50 const scoped_refptr<IOSurfaceContext>& offscreen_context) 45 const scoped_refptr<IOSurfaceContext>& offscreen_context,
46 bool needs_gl_finish_workaround)
51 : offscreen_context_(offscreen_context), 47 : offscreen_context_(offscreen_context),
52 texture_(0), 48 texture_(0),
53 gl_error_(GL_NO_ERROR), 49 gl_error_(GL_NO_ERROR),
54 eviction_queue_iterator_(eviction_queue_.Get().end()), 50 eviction_queue_iterator_(eviction_queue_.Get().end()),
55 eviction_has_been_drawn_since_updated_(false) { 51 eviction_has_been_drawn_since_updated_(false),
52 needs_gl_finish_workaround_(needs_gl_finish_workaround) {
56 CHECK(offscreen_context_.get()); 53 CHECK(offscreen_context_.get());
57 } 54 }
58 55
59 IOSurfaceTexture::~IOSurfaceTexture() { 56 IOSurfaceTexture::~IOSurfaceTexture() {
60 ReleaseIOSurfaceAndTexture(); 57 ReleaseIOSurfaceAndTexture();
61 offscreen_context_ = NULL; 58 offscreen_context_ = NULL;
62 DCHECK(eviction_queue_iterator_ == eviction_queue_.Get().end()); 59 DCHECK(eviction_queue_iterator_ == eviction_queue_.Get().end());
63 } 60 }
64 61
65 bool IOSurfaceTexture::DrawIOSurface() { 62 bool IOSurfaceTexture::DrawIOSurface() {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 glEnd(); 100 glEnd();
104 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0); 101 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
105 glDisable(GL_TEXTURE_RECTANGLE_ARB); 102 glDisable(GL_TEXTURE_RECTANGLE_ARB);
106 103
107 // Workaround for issue 158469. Issue a dummy draw call with texture_ not 104 // Workaround for issue 158469. Issue a dummy draw call with texture_ not
108 // bound to a texture, in order to shake all references to the IOSurface out 105 // bound to a texture, in order to shake all references to the IOSurface out
109 // of the driver. 106 // of the driver.
110 glBegin(GL_TRIANGLES); 107 glBegin(GL_TRIANGLES);
111 glEnd(); 108 glEnd();
112 109
113 bool workaround_needed = 110 if (needs_gl_finish_workaround_) {
114 GpuDataManagerImpl::GetInstance()->IsDriverBugWorkaroundActive(
115 gpu::FORCE_GL_FINISH_AFTER_COMPOSITING);
116 if (workaround_needed) {
117 TRACE_EVENT0("gpu", "glFinish"); 111 TRACE_EVENT0("gpu", "glFinish");
118 glFinish(); 112 glFinish();
119 } 113 }
120 114
121 // Check if any of the drawing calls result in an error. 115 // Check if any of the drawing calls result in an error.
122 GetAndSaveGLError(); 116 GetAndSaveGLError();
123 bool result = true; 117 bool result = true;
124 if (gl_error_ != GL_NO_ERROR) { 118 if (gl_error_ != GL_NO_ERROR) {
125 LOG(ERROR) << "GL error in DrawIOSurface: " << gl_error_; 119 LOG(ERROR) << "GL error in DrawIOSurface: " << gl_error_;
126 result = false; 120 result = false;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 } 282 }
289 283
290 // static 284 // static
291 base::LazyInstance<IOSurfaceTexture::EvictionQueue> 285 base::LazyInstance<IOSurfaceTexture::EvictionQueue>
292 IOSurfaceTexture::eviction_queue_; 286 IOSurfaceTexture::eviction_queue_;
293 287
294 // static 288 // static
295 bool IOSurfaceTexture::eviction_scheduled_ = false; 289 bool IOSurfaceTexture::eviction_scheduled_ = false;
296 290
297 } // namespace content 291 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698