OLD | NEW |
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/common/gpu/image_transport_surface.h" | 5 #include "content/common/gpu/image_transport_surface.h" |
6 | 6 |
7 #include "base/mac/scoped_cftyperef.h" | 7 #include "base/mac/scoped_cftyperef.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "content/common/gpu/gpu_messages.h" | 9 #include "content/common/gpu/gpu_messages.h" |
10 #include "ui/gfx/native_widget_types.h" | 10 #include "ui/gfx/native_widget_types.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; | 52 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; |
53 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; | 53 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; |
54 virtual bool SetBackbufferAllocation(bool allocated) OVERRIDE; | 54 virtual bool SetBackbufferAllocation(bool allocated) OVERRIDE; |
55 virtual void SetFrontbufferAllocation(bool allocated) OVERRIDE; | 55 virtual void SetFrontbufferAllocation(bool allocated) OVERRIDE; |
56 | 56 |
57 protected: | 57 protected: |
58 // ImageTransportSurface implementation | 58 // ImageTransportSurface implementation |
59 virtual void OnBufferPresented( | 59 virtual void OnBufferPresented( |
60 const AcceleratedSurfaceMsg_BufferPresented_Params& params) OVERRIDE; | 60 const AcceleratedSurfaceMsg_BufferPresented_Params& params) OVERRIDE; |
61 virtual void OnResizeViewACK() OVERRIDE; | 61 virtual void OnResizeViewACK() OVERRIDE; |
62 virtual void OnResize(gfx::Size size) OVERRIDE; | 62 virtual void OnResize(gfx::Size size, float scale_factor) OVERRIDE; |
63 virtual void SetLatencyInfo(const cc::LatencyInfo&) OVERRIDE; | 63 virtual void SetLatencyInfo(const cc::LatencyInfo&) OVERRIDE; |
64 | 64 |
65 private: | 65 private: |
66 virtual ~IOSurfaceImageTransportSurface() OVERRIDE; | 66 virtual ~IOSurfaceImageTransportSurface() OVERRIDE; |
67 | 67 |
68 void AdjustBufferAllocation(); | 68 void AdjustBufferAllocation(); |
69 void UnrefIOSurface(); | 69 void UnrefIOSurface(); |
70 void CreateIOSurface(); | 70 void CreateIOSurface(); |
71 | 71 |
72 // Tracks the current buffer allocation state. | 72 // Tracks the current buffer allocation state. |
73 bool backbuffer_suggested_allocation_; | 73 bool backbuffer_suggested_allocation_; |
74 bool frontbuffer_suggested_allocation_; | 74 bool frontbuffer_suggested_allocation_; |
75 | 75 |
76 uint32 fbo_id_; | 76 uint32 fbo_id_; |
77 GLuint texture_id_; | 77 GLuint texture_id_; |
78 | 78 |
79 base::mac::ScopedCFTypeRef<CFTypeRef> io_surface_; | 79 base::mac::ScopedCFTypeRef<CFTypeRef> io_surface_; |
80 | 80 |
81 // The id of |io_surface_| or 0 if that's NULL. | 81 // The id of |io_surface_| or 0 if that's NULL. |
82 uint64 io_surface_handle_; | 82 uint64 io_surface_handle_; |
83 | 83 |
84 // Weak pointer to the context that this was last made current to. | 84 // Weak pointer to the context that this was last made current to. |
85 gfx::GLContext* context_; | 85 gfx::GLContext* context_; |
86 | 86 |
87 gfx::Size size_; | 87 gfx::Size size_; |
88 gfx::Size rounded_size_; | 88 gfx::Size rounded_size_; |
| 89 float scale_factor_; |
89 | 90 |
90 // Whether or not we've successfully made the surface current once. | 91 // Whether or not we've successfully made the surface current once. |
91 bool made_current_; | 92 bool made_current_; |
92 | 93 |
93 // Whether a SwapBuffers is pending. | 94 // Whether a SwapBuffers is pending. |
94 bool is_swap_buffers_pending_; | 95 bool is_swap_buffers_pending_; |
95 | 96 |
96 // Whether we unscheduled command buffer because of pending SwapBuffers. | 97 // Whether we unscheduled command buffer because of pending SwapBuffers. |
97 bool did_unschedule_; | 98 bool did_unschedule_; |
98 | 99 |
(...skipping 23 matching lines...) Expand all Loading... |
122 GpuChannelManager* manager, | 123 GpuChannelManager* manager, |
123 GpuCommandBufferStub* stub, | 124 GpuCommandBufferStub* stub, |
124 gfx::PluginWindowHandle handle) | 125 gfx::PluginWindowHandle handle) |
125 : gfx::NoOpGLSurfaceCGL(gfx::Size(1, 1)), | 126 : gfx::NoOpGLSurfaceCGL(gfx::Size(1, 1)), |
126 backbuffer_suggested_allocation_(true), | 127 backbuffer_suggested_allocation_(true), |
127 frontbuffer_suggested_allocation_(true), | 128 frontbuffer_suggested_allocation_(true), |
128 fbo_id_(0), | 129 fbo_id_(0), |
129 texture_id_(0), | 130 texture_id_(0), |
130 io_surface_handle_(0), | 131 io_surface_handle_(0), |
131 context_(NULL), | 132 context_(NULL), |
| 133 scale_factor_(1), |
132 made_current_(false), | 134 made_current_(false), |
133 is_swap_buffers_pending_(false), | 135 is_swap_buffers_pending_(false), |
134 did_unschedule_(false) { | 136 did_unschedule_(false) { |
135 helper_.reset(new ImageTransportHelper(this, manager, stub, handle)); | 137 helper_.reset(new ImageTransportHelper(this, manager, stub, handle)); |
136 } | 138 } |
137 | 139 |
138 IOSurfaceImageTransportSurface::~IOSurfaceImageTransportSurface() { | 140 IOSurfaceImageTransportSurface::~IOSurfaceImageTransportSurface() { |
139 Destroy(); | 141 Destroy(); |
140 } | 142 } |
141 | 143 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 bool IOSurfaceImageTransportSurface::IsOffscreen() { | 179 bool IOSurfaceImageTransportSurface::IsOffscreen() { |
178 return false; | 180 return false; |
179 } | 181 } |
180 | 182 |
181 bool IOSurfaceImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { | 183 bool IOSurfaceImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { |
182 context_ = context; | 184 context_ = context; |
183 | 185 |
184 if (made_current_) | 186 if (made_current_) |
185 return true; | 187 return true; |
186 | 188 |
187 OnResize(gfx::Size(1, 1)); | 189 OnResize(gfx::Size(1, 1), 1.f); |
188 | 190 |
189 made_current_ = true; | 191 made_current_ = true; |
190 return true; | 192 return true; |
191 } | 193 } |
192 | 194 |
193 unsigned int IOSurfaceImageTransportSurface::GetBackingFrameBufferObject() { | 195 unsigned int IOSurfaceImageTransportSurface::GetBackingFrameBufferObject() { |
194 return fbo_id_; | 196 return fbo_id_; |
195 } | 197 } |
196 | 198 |
197 bool IOSurfaceImageTransportSurface::SetBackbufferAllocation(bool allocation) { | 199 bool IOSurfaceImageTransportSurface::SetBackbufferAllocation(bool allocation) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 if (did_unschedule_) { | 284 if (did_unschedule_) { |
283 did_unschedule_ = false; | 285 did_unschedule_ = false; |
284 helper_->SetScheduled(true); | 286 helper_->SetScheduled(true); |
285 } | 287 } |
286 } | 288 } |
287 | 289 |
288 void IOSurfaceImageTransportSurface::OnResizeViewACK() { | 290 void IOSurfaceImageTransportSurface::OnResizeViewACK() { |
289 NOTREACHED(); | 291 NOTREACHED(); |
290 } | 292 } |
291 | 293 |
292 void IOSurfaceImageTransportSurface::OnResize(gfx::Size size) { | 294 void IOSurfaceImageTransportSurface::OnResize(gfx::Size size, |
| 295 float scale_factor) { |
293 // This trace event is used in gpu_feature_browsertest.cc - the test will need | 296 // This trace event is used in gpu_feature_browsertest.cc - the test will need |
294 // to be updated if this event is changed or moved. | 297 // to be updated if this event is changed or moved. |
295 TRACE_EVENT2("gpu", "IOSurfaceImageTransportSurface::OnResize", | 298 TRACE_EVENT2("gpu", "IOSurfaceImageTransportSurface::OnResize", |
296 "old_width", size_.width(), "new_width", size.width()); | 299 "old_width", size_.width(), "new_width", size.width()); |
297 // Caching |context_| from OnMakeCurrent. It should still be current. | 300 // Caching |context_| from OnMakeCurrent. It should still be current. |
298 DCHECK(context_->IsCurrent(this)); | 301 DCHECK(context_->IsCurrent(this)); |
299 | 302 |
300 size_ = size; | 303 size_ = size; |
| 304 scale_factor_ = scale_factor; |
301 | 305 |
302 CreateIOSurface(); | 306 CreateIOSurface(); |
303 } | 307 } |
304 | 308 |
305 void IOSurfaceImageTransportSurface::SetLatencyInfo( | 309 void IOSurfaceImageTransportSurface::SetLatencyInfo( |
306 const cc::LatencyInfo& latency_info) { | 310 const cc::LatencyInfo& latency_info) { |
307 latency_info_ = latency_info; | 311 latency_info_ = latency_info; |
308 } | 312 } |
309 | 313 |
310 void IOSurfaceImageTransportSurface::UnrefIOSurface() { | 314 void IOSurfaceImageTransportSurface::UnrefIOSurface() { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 manager, stub, surface.get(), false)); | 482 manager, stub, surface.get(), false)); |
479 } | 483 } |
480 } | 484 } |
481 | 485 |
482 // static | 486 // static |
483 void ImageTransportSurface::SetAllowOSMesaForTesting(bool allow) { | 487 void ImageTransportSurface::SetAllowOSMesaForTesting(bool allow) { |
484 g_allow_os_mesa = allow; | 488 g_allow_os_mesa = allow; |
485 } | 489 } |
486 | 490 |
487 } // namespace content | 491 } // namespace content |
OLD | NEW |