| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "gpu/ipc/service/direct_composition_surface_win.h" | 5 #include "gpu/ipc/service/direct_composition_surface_win.h" |
| 6 | 6 |
| 7 #include "base/optional.h" | 7 #include "base/optional.h" |
| 8 #include "gpu/ipc/service/gpu_channel_manager.h" | 8 #include "gpu/ipc/service/gpu_channel_manager.h" |
| 9 #include "gpu/ipc/service/gpu_channel_manager_delegate.h" | 9 #include "gpu/ipc/service/gpu_channel_manager_delegate.h" |
| 10 #include "ui/gfx/native_widget_types.h" | 10 #include "ui/gfx/native_widget_types.h" |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 if (gfx::Rect(size_) != rectangle && !has_been_rendered_to_) { | 288 if (gfx::Rect(size_) != rectangle && !has_been_rendered_to_) { |
| 289 DLOG(ERROR) << "First draw to surface must draw to everything"; | 289 DLOG(ERROR) << "First draw to surface must draw to everything"; |
| 290 return false; | 290 return false; |
| 291 } | 291 } |
| 292 | 292 |
| 293 DCHECK(!real_surface_); | 293 DCHECK(!real_surface_); |
| 294 CHECK(!g_current_surface); | 294 CHECK(!g_current_surface); |
| 295 ScopedReleaseCurrent release_current(this); | 295 ScopedReleaseCurrent release_current(this); |
| 296 | 296 |
| 297 RECT rect = rectangle.ToRECT(); | 297 RECT rect = rectangle.ToRECT(); |
| 298 // TODO(jbauman): Use update_offset | |
| 299 POINT update_offset; | 298 POINT update_offset; |
| 300 | 299 |
| 301 HRESULT hr = dcomp_surface_->BeginDraw( | 300 HRESULT hr = dcomp_surface_->BeginDraw( |
| 302 &rect, IID_PPV_ARGS(draw_texture_.Receive()), &update_offset); | 301 &rect, IID_PPV_ARGS(draw_texture_.Receive()), &update_offset); |
| 303 CHECK(SUCCEEDED(hr)); | 302 CHECK(SUCCEEDED(hr)); |
| 304 has_been_rendered_to_ = true; | 303 has_been_rendered_to_ = true; |
| 305 | 304 |
| 305 draw_offset_ = gfx::Point(update_offset) - gfx::Rect(rect).origin(); |
| 306 |
| 306 g_current_surface = dcomp_surface_.get(); | 307 g_current_surface = dcomp_surface_.get(); |
| 307 | 308 |
| 308 std::vector<EGLint> pbuffer_attribs{ | 309 std::vector<EGLint> pbuffer_attribs{ |
| 309 EGL_WIDTH, | 310 EGL_WIDTH, |
| 310 size_.width(), | 311 size_.width(), |
| 311 EGL_HEIGHT, | 312 EGL_HEIGHT, |
| 312 size_.height(), | 313 size_.height(), |
| 313 EGL_FLEXIBLE_SURFACE_COMPATIBILITY_SUPPORTED_ANGLE, | 314 EGL_FLEXIBLE_SURFACE_COMPATIBILITY_SUPPORTED_ANGLE, |
| 314 EGL_TRUE, | 315 EGL_TRUE, |
| 315 EGL_NONE}; | 316 EGL_NONE}; |
| 316 | 317 |
| 317 EGLClientBuffer buffer = | 318 EGLClientBuffer buffer = |
| 318 reinterpret_cast<EGLClientBuffer>(draw_texture_.get()); | 319 reinterpret_cast<EGLClientBuffer>(draw_texture_.get()); |
| 319 real_surface_ = eglCreatePbufferFromClientBuffer( | 320 real_surface_ = eglCreatePbufferFromClientBuffer( |
| 320 GetDisplay(), EGL_D3D_TEXTURE_ANGLE, buffer, GetConfig(), | 321 GetDisplay(), EGL_D3D_TEXTURE_ANGLE, buffer, GetConfig(), |
| 321 &pbuffer_attribs[0]); | 322 &pbuffer_attribs[0]); |
| 322 | 323 |
| 323 return true; | 324 return true; |
| 324 } | 325 } |
| 325 | 326 |
| 327 gfx::Vector2d DirectCompositionSurfaceWin::GetDrawOffset() const { |
| 328 return draw_offset_; |
| 329 } |
| 330 |
| 326 scoped_refptr<base::TaskRunner> | 331 scoped_refptr<base::TaskRunner> |
| 327 DirectCompositionSurfaceWin::GetWindowTaskRunnerForTesting() { | 332 DirectCompositionSurfaceWin::GetWindowTaskRunnerForTesting() { |
| 328 return child_window_.GetTaskRunnerForTesting(); | 333 return child_window_.GetTaskRunnerForTesting(); |
| 329 } | 334 } |
| 330 | 335 |
| 331 DirectCompositionSurfaceWin::Overlay::Overlay(int z_order, | 336 DirectCompositionSurfaceWin::Overlay::Overlay(int z_order, |
| 332 gfx::OverlayTransform transform, | 337 gfx::OverlayTransform transform, |
| 333 scoped_refptr<gl::GLImage> image, | 338 scoped_refptr<gl::GLImage> image, |
| 334 gfx::Rect bounds_rect, | 339 gfx::Rect bounds_rect, |
| 335 gfx::RectF crop_rect) | 340 gfx::RectF crop_rect) |
| 336 : z_order(z_order), | 341 : z_order(z_order), |
| 337 transform(transform), | 342 transform(transform), |
| 338 image(image), | 343 image(image), |
| 339 bounds_rect(bounds_rect), | 344 bounds_rect(bounds_rect), |
| 340 crop_rect(crop_rect) {} | 345 crop_rect(crop_rect) {} |
| 341 | 346 |
| 342 DirectCompositionSurfaceWin::Overlay::Overlay(const Overlay& overlay) = default; | 347 DirectCompositionSurfaceWin::Overlay::Overlay(const Overlay& overlay) = default; |
| 343 | 348 |
| 344 DirectCompositionSurfaceWin::Overlay::~Overlay() {} | 349 DirectCompositionSurfaceWin::Overlay::~Overlay() {} |
| 345 | 350 |
| 346 } // namespace gpu | 351 } // namespace gpu |
| OLD | NEW |