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 "ui/gl/gl_surface.h" | 5 #include "ui/gl/gl_surface.h" |
6 | 6 |
7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 // This OSMesa GL surface can use GDI to swap the contents of the buffer to a | 30 // This OSMesa GL surface can use GDI to swap the contents of the buffer to a |
31 // view. | 31 // view. |
32 class NativeViewGLSurfaceOSMesa : public GLSurfaceOSMesa { | 32 class NativeViewGLSurfaceOSMesa : public GLSurfaceOSMesa { |
33 public: | 33 public: |
34 explicit NativeViewGLSurfaceOSMesa(gfx::AcceleratedWidget window); | 34 explicit NativeViewGLSurfaceOSMesa(gfx::AcceleratedWidget window); |
35 | 35 |
36 // Implement subset of GLSurface. | 36 // Implement subset of GLSurface. |
37 bool Initialize() override; | 37 bool Initialize() override; |
38 void Destroy() override; | 38 void Destroy() override; |
39 bool IsOffscreen() override; | 39 bool IsOffscreen() override; |
40 gfx::SwapResult SwapBuffers() override; | 40 bool SwapBuffers() override; |
41 bool SupportsPostSubBuffer() override; | 41 bool SupportsPostSubBuffer() override; |
42 gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override; | 42 bool PostSubBuffer(int x, int y, int width, int height) override; |
43 | 43 |
44 private: | 44 private: |
45 ~NativeViewGLSurfaceOSMesa() override; | 45 ~NativeViewGLSurfaceOSMesa() override; |
46 | 46 |
47 gfx::AcceleratedWidget window_; | 47 gfx::AcceleratedWidget window_; |
48 HDC device_context_; | 48 HDC device_context_; |
49 | 49 |
50 DISALLOW_COPY_AND_ASSIGN(NativeViewGLSurfaceOSMesa); | 50 DISALLOW_COPY_AND_ASSIGN(NativeViewGLSurfaceOSMesa); |
51 }; | 51 }; |
52 | 52 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 | 201 |
202 device_context_ = NULL; | 202 device_context_ = NULL; |
203 | 203 |
204 GLSurfaceOSMesa::Destroy(); | 204 GLSurfaceOSMesa::Destroy(); |
205 } | 205 } |
206 | 206 |
207 bool NativeViewGLSurfaceOSMesa::IsOffscreen() { | 207 bool NativeViewGLSurfaceOSMesa::IsOffscreen() { |
208 return false; | 208 return false; |
209 } | 209 } |
210 | 210 |
211 gfx::SwapResult NativeViewGLSurfaceOSMesa::SwapBuffers() { | 211 bool NativeViewGLSurfaceOSMesa::SwapBuffers() { |
212 DCHECK(device_context_); | 212 DCHECK(device_context_); |
213 | 213 |
214 gfx::Size size = GetSize(); | 214 gfx::Size size = GetSize(); |
215 | 215 |
216 // Note: negating the height below causes GDI to treat the bitmap data as row | 216 // Note: negating the height below causes GDI to treat the bitmap data as row |
217 // 0 being at the top. | 217 // 0 being at the top. |
218 BITMAPV4HEADER info = { sizeof(BITMAPV4HEADER) }; | 218 BITMAPV4HEADER info = { sizeof(BITMAPV4HEADER) }; |
219 info.bV4Width = size.width(); | 219 info.bV4Width = size.width(); |
220 info.bV4Height = -size.height(); | 220 info.bV4Height = -size.height(); |
221 info.bV4Planes = 1; | 221 info.bV4Planes = 1; |
(...skipping 12 matching lines...) Expand all Loading... |
234 // browser test to become flaky if there is a race condition between GL | 234 // browser test to become flaky if there is a race condition between GL |
235 // context destruction and window destruction. | 235 // context destruction and window destruction. |
236 StretchDIBits(device_context_, | 236 StretchDIBits(device_context_, |
237 0, 0, size.width(), size.height(), | 237 0, 0, size.width(), size.height(), |
238 0, 0, size.width(), size.height(), | 238 0, 0, size.width(), size.height(), |
239 GetHandle(), | 239 GetHandle(), |
240 reinterpret_cast<BITMAPINFO*>(&info), | 240 reinterpret_cast<BITMAPINFO*>(&info), |
241 DIB_RGB_COLORS, | 241 DIB_RGB_COLORS, |
242 SRCCOPY); | 242 SRCCOPY); |
243 | 243 |
244 return gfx::SwapResult::SWAP_ACK; | 244 return true; |
245 } | 245 } |
246 | 246 |
247 bool NativeViewGLSurfaceOSMesa::SupportsPostSubBuffer() { | 247 bool NativeViewGLSurfaceOSMesa::SupportsPostSubBuffer() { |
248 return true; | 248 return true; |
249 } | 249 } |
250 | 250 |
251 gfx::SwapResult NativeViewGLSurfaceOSMesa::PostSubBuffer(int x, | 251 bool NativeViewGLSurfaceOSMesa::PostSubBuffer( |
252 int y, | 252 int x, int y, int width, int height) { |
253 int width, | |
254 int height) { | |
255 DCHECK(device_context_); | 253 DCHECK(device_context_); |
256 | 254 |
257 gfx::Size size = GetSize(); | 255 gfx::Size size = GetSize(); |
258 | 256 |
259 // Note: negating the height below causes GDI to treat the bitmap data as row | 257 // Note: negating the height below causes GDI to treat the bitmap data as row |
260 // 0 being at the top. | 258 // 0 being at the top. |
261 BITMAPV4HEADER info = { sizeof(BITMAPV4HEADER) }; | 259 BITMAPV4HEADER info = { sizeof(BITMAPV4HEADER) }; |
262 info.bV4Width = size.width(); | 260 info.bV4Width = size.width(); |
263 info.bV4Height = -size.height(); | 261 info.bV4Height = -size.height(); |
264 info.bV4Planes = 1; | 262 info.bV4Planes = 1; |
(...skipping 12 matching lines...) Expand all Loading... |
277 // browser test to become flaky if there is a race condition between GL | 275 // browser test to become flaky if there is a race condition between GL |
278 // context destruction and window destruction. | 276 // context destruction and window destruction. |
279 StretchDIBits(device_context_, | 277 StretchDIBits(device_context_, |
280 x, size.height() - y - height, width, height, | 278 x, size.height() - y - height, width, height, |
281 x, y, width, height, | 279 x, y, width, height, |
282 GetHandle(), | 280 GetHandle(), |
283 reinterpret_cast<BITMAPINFO*>(&info), | 281 reinterpret_cast<BITMAPINFO*>(&info), |
284 DIB_RGB_COLORS, | 282 DIB_RGB_COLORS, |
285 SRCCOPY); | 283 SRCCOPY); |
286 | 284 |
287 return gfx::SwapResult::SWAP_ACK; | 285 return true; |
288 } | 286 } |
289 | 287 |
290 scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( | 288 scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( |
291 gfx::AcceleratedWidget window) { | 289 gfx::AcceleratedWidget window) { |
292 TRACE_EVENT0("gpu", "GLSurface::CreateViewGLSurface"); | 290 TRACE_EVENT0("gpu", "GLSurface::CreateViewGLSurface"); |
293 switch (GetGLImplementation()) { | 291 switch (GetGLImplementation()) { |
294 case kGLImplementationOSMesaGL: { | 292 case kGLImplementationOSMesaGL: { |
295 scoped_refptr<GLSurface> surface( | 293 scoped_refptr<GLSurface> surface( |
296 new NativeViewGLSurfaceOSMesa(window)); | 294 new NativeViewGLSurfaceOSMesa(window)); |
297 if (!surface->Initialize()) | 295 if (!surface->Initialize()) |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 NOTREACHED(); | 356 NOTREACHED(); |
359 return NULL; | 357 return NULL; |
360 } | 358 } |
361 } | 359 } |
362 | 360 |
363 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { | 361 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { |
364 return GetDC(NULL); | 362 return GetDC(NULL); |
365 } | 363 } |
366 | 364 |
367 } // namespace gfx | 365 } // namespace gfx |
OLD | NEW |