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

Side by Side Diff: ui/accelerated_widget_mac/io_surface_texture.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: gn check 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/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/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"
29 #include "ui/gfx/rect.h" 22 #include "ui/accelerated_widget_mac/io_surface_context.h"
30 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" 23 #include "ui/gfx/geometry/rect.h"
31 #include "ui/gfx/size_conversions.h" 24 #include "ui/gfx/geometry/size_conversions.h"
32 #include "ui/gl/gl_context.h" 25 #include "ui/gl/gl_context.h"
33 26
34 namespace content { 27 namespace ui {
35 28
36 // static 29 // static
37 scoped_refptr<IOSurfaceTexture> IOSurfaceTexture::Create() { 30 scoped_refptr<IOSurfaceTexture> IOSurfaceTexture::Create(
31 bool needs_gl_finish_workaround) {
38 scoped_refptr<IOSurfaceContext> offscreen_context = 32 scoped_refptr<IOSurfaceContext> offscreen_context =
39 IOSurfaceContext::Get( 33 IOSurfaceContext::Get(
40 IOSurfaceContext::kOffscreenContext); 34 IOSurfaceContext::kOffscreenContext);
41 if (!offscreen_context.get()) { 35 if (!offscreen_context.get()) {
42 LOG(ERROR) << "Failed to create context for offscreen operations"; 36 LOG(ERROR) << "Failed to create context for offscreen operations";
43 return NULL; 37 return NULL;
44 } 38 }
45 39
46 return new IOSurfaceTexture(offscreen_context); 40 return new IOSurfaceTexture(offscreen_context, needs_gl_finish_workaround);
47 } 41 }
48 42
49 IOSurfaceTexture::IOSurfaceTexture( 43 IOSurfaceTexture::IOSurfaceTexture(
50 const scoped_refptr<IOSurfaceContext>& offscreen_context) 44 const scoped_refptr<IOSurfaceContext>& offscreen_context,
45 bool needs_gl_finish_workaround)
51 : offscreen_context_(offscreen_context), 46 : offscreen_context_(offscreen_context),
52 texture_(0), 47 texture_(0),
53 gl_error_(GL_NO_ERROR), 48 gl_error_(GL_NO_ERROR),
54 eviction_queue_iterator_(eviction_queue_.Get().end()), 49 eviction_queue_iterator_(eviction_queue_.Get().end()),
55 eviction_has_been_drawn_since_updated_(false) { 50 eviction_has_been_drawn_since_updated_(false),
51 needs_gl_finish_workaround_(needs_gl_finish_workaround) {
56 CHECK(offscreen_context_.get()); 52 CHECK(offscreen_context_.get());
57 } 53 }
58 54
59 IOSurfaceTexture::~IOSurfaceTexture() { 55 IOSurfaceTexture::~IOSurfaceTexture() {
60 ReleaseIOSurfaceAndTexture(); 56 ReleaseIOSurfaceAndTexture();
61 offscreen_context_ = NULL; 57 offscreen_context_ = NULL;
62 DCHECK(eviction_queue_iterator_ == eviction_queue_.Get().end()); 58 DCHECK(eviction_queue_iterator_ == eviction_queue_.Get().end());
63 } 59 }
64 60
65 bool IOSurfaceTexture::DrawIOSurface() { 61 bool IOSurfaceTexture::DrawIOSurface() {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 glEnd(); 99 glEnd();
104 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0); 100 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
105 glDisable(GL_TEXTURE_RECTANGLE_ARB); 101 glDisable(GL_TEXTURE_RECTANGLE_ARB);
106 102
107 // Workaround for issue 158469. Issue a dummy draw call with texture_ not 103 // 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 104 // bound to a texture, in order to shake all references to the IOSurface out
109 // of the driver. 105 // of the driver.
110 glBegin(GL_TRIANGLES); 106 glBegin(GL_TRIANGLES);
111 glEnd(); 107 glEnd();
112 108
113 bool workaround_needed = 109 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"); 110 TRACE_EVENT0("gpu", "glFinish");
118 glFinish(); 111 glFinish();
119 } 112 }
120 113
121 // Check if any of the drawing calls result in an error. 114 // Check if any of the drawing calls result in an error.
122 GetAndSaveGLError(); 115 GetAndSaveGLError();
123 bool result = true; 116 bool result = true;
124 if (gl_error_ != GL_NO_ERROR) { 117 if (gl_error_ != GL_NO_ERROR) {
125 LOG(ERROR) << "GL error in DrawIOSurface: " << gl_error_; 118 LOG(ERROR) << "GL error in DrawIOSurface: " << gl_error_;
126 result = false; 119 result = false;
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 } 280 }
288 } 281 }
289 282
290 // static 283 // static
291 base::LazyInstance<IOSurfaceTexture::EvictionQueue> 284 base::LazyInstance<IOSurfaceTexture::EvictionQueue>
292 IOSurfaceTexture::eviction_queue_; 285 IOSurfaceTexture::eviction_queue_;
293 286
294 // static 287 // static
295 bool IOSurfaceTexture::eviction_scheduled_ = false; 288 bool IOSurfaceTexture::eviction_scheduled_ = false;
296 289
297 } // namespace content 290 } // namespace ui
OLDNEW
« no previous file with comments | « ui/accelerated_widget_mac/io_surface_texture.h ('k') | ui/accelerated_widget_mac/software_layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698