| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_layer_mac.h" | 5 #include "ui/accelerated_widget_mac/io_surface_layer.h" |
| 6 | 6 |
| 7 #include <CoreFoundation/CoreFoundation.h> | 7 #include <CoreFoundation/CoreFoundation.h> |
| 8 #include <OpenGL/CGLIOSurface.h> | 8 #include <OpenGL/CGLIOSurface.h> |
| 9 #include <OpenGL/CGLRenderers.h> | 9 #include <OpenGL/CGLRenderers.h> |
| 10 #include <OpenGL/gl.h> | 10 #include <OpenGL/gl.h> |
| 11 #include <OpenGL/OpenGL.h> | 11 #include <OpenGL/OpenGL.h> |
| 12 | 12 |
| 13 #include "base/debug/trace_event.h" | 13 #include "base/debug/trace_event.h" |
| 14 #include "base/mac/mac_util.h" | 14 #include "base/mac/mac_util.h" |
| 15 #include "base/mac/sdk_forward_declarations.h" | 15 #include "base/mac/sdk_forward_declarations.h" |
| 16 #include "content/browser/compositor/io_surface_context_mac.h" | 16 #include "ui/accelerated_widget_mac/io_surface_context.h" |
| 17 #include "content/browser/compositor/io_surface_texture_mac.h" | 17 #include "ui/accelerated_widget_mac/io_surface_texture.h" |
| 18 #include "ui/base/cocoa/animation_utils.h" | 18 #include "ui/base/cocoa/animation_utils.h" |
| 19 #include "ui/gfx/size_conversions.h" | 19 #include "ui/gfx/geometry/size_conversions.h" |
| 20 #include "ui/gl/gpu_switching_manager.h" | 20 #include "ui/gl/gpu_switching_manager.h" |
| 21 | 21 |
| 22 //////////////////////////////////////////////////////////////////////////////// | 22 //////////////////////////////////////////////////////////////////////////////// |
| 23 // IOSurfaceLayerHelper | 23 // IOSurfaceLayerHelper |
| 24 | 24 |
| 25 namespace content { | 25 namespace ui { |
| 26 | 26 |
| 27 IOSurfaceLayerHelper::IOSurfaceLayerHelper( | 27 IOSurfaceLayerHelper::IOSurfaceLayerHelper( |
| 28 IOSurfaceLayerClient* client, | 28 IOSurfaceLayerClient* client, |
| 29 IOSurfaceLayer* layer) | 29 IOSurfaceLayer* layer) |
| 30 : client_(client), | 30 : client_(client), |
| 31 layer_(layer), | 31 layer_(layer), |
| 32 needs_display_(false), | 32 needs_display_(false), |
| 33 has_pending_frame_(false), | 33 has_pending_frame_(false), |
| 34 did_not_draw_counter_(0), | 34 did_not_draw_counter_(0), |
| 35 is_pumping_frames_(false), | 35 is_pumping_frames_(false), |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 | 153 |
| 154 void IOSurfaceLayerHelper::BeginPumpingFrames() { | 154 void IOSurfaceLayerHelper::BeginPumpingFrames() { |
| 155 is_pumping_frames_ = true; | 155 is_pumping_frames_ = true; |
| 156 } | 156 } |
| 157 | 157 |
| 158 void IOSurfaceLayerHelper::EndPumpingFrames() { | 158 void IOSurfaceLayerHelper::EndPumpingFrames() { |
| 159 is_pumping_frames_ = false; | 159 is_pumping_frames_ = false; |
| 160 DisplayIfNeededAndAck(); | 160 DisplayIfNeededAndAck(); |
| 161 } | 161 } |
| 162 | 162 |
| 163 } // namespace content | 163 } // namespace ui |
| 164 | 164 |
| 165 //////////////////////////////////////////////////////////////////////////////// | 165 //////////////////////////////////////////////////////////////////////////////// |
| 166 // IOSurfaceLayer | 166 // IOSurfaceLayer |
| 167 | 167 |
| 168 @implementation IOSurfaceLayer | 168 @implementation IOSurfaceLayer |
| 169 | 169 |
| 170 - (id)initWithClient:(content::IOSurfaceLayerClient*)client | 170 - (id)initWithClient:(ui::IOSurfaceLayerClient*)client |
| 171 withScaleFactor:(float)scale_factor { | 171 withScaleFactor:(float)scale_factor |
| 172 needsGLFinishWorkaround:(bool)needs_gl_finish_workaround { |
| 172 if (self = [super init]) { | 173 if (self = [super init]) { |
| 173 helper_.reset(new content::IOSurfaceLayerHelper(client, self)); | 174 helper_.reset(new ui::IOSurfaceLayerHelper(client, self)); |
| 174 | 175 |
| 175 iosurface_ = content::IOSurfaceTexture::Create(); | 176 iosurface_ = ui::IOSurfaceTexture::Create(needs_gl_finish_workaround); |
| 176 context_ = content::IOSurfaceContext::Get( | 177 context_ = ui::IOSurfaceContext::Get( |
| 177 content::IOSurfaceContext::kCALayerContext); | 178 ui::IOSurfaceContext::kCALayerContext); |
| 178 if (!iosurface_.get() || !context_.get()) { | 179 if (!iosurface_.get() || !context_.get()) { |
| 179 LOG(ERROR) << "Failed create CompositingIOSurface or context"; | 180 LOG(ERROR) << "Failed create CompositingIOSurface or context"; |
| 180 [self resetClient]; | 181 [self resetClient]; |
| 181 [self release]; | 182 [self release]; |
| 182 return nil; | 183 return nil; |
| 183 } | 184 } |
| 184 | 185 |
| 185 [self setBackgroundColor:CGColorGetConstantColor(kCGColorWhite)]; | 186 [self setBackgroundColor:CGColorGetConstantColor(kCGColorWhite)]; |
| 186 [self setAnchorPoint:CGPointMake(0, 0)]; | 187 [self setAnchorPoint:CGPointMake(0, 0)]; |
| 187 // Setting contents gravity is necessary to prevent the layer from being | 188 // Setting contents gravity is necessary to prevent the layer from being |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 if (helper_) | 293 if (helper_) |
| 293 helper_->DidDraw(draw_succeeded); | 294 helper_->DidDraw(draw_succeeded); |
| 294 | 295 |
| 295 [super drawInCGLContext:glContext | 296 [super drawInCGLContext:glContext |
| 296 pixelFormat:pixelFormat | 297 pixelFormat:pixelFormat |
| 297 forLayerTime:timeInterval | 298 forLayerTime:timeInterval |
| 298 displayTime:timeStamp]; | 299 displayTime:timeStamp]; |
| 299 } | 300 } |
| 300 | 301 |
| 301 @end | 302 @end |
| OLD | NEW |