OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "services/ui/surfaces/display_output_surface_ozone.h" | 5 #include "services/ui/surfaces/display_output_surface_ozone.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 } | 76 } |
77 | 77 |
78 void DisplayOutputSurfaceOzone::SwapBuffers(cc::OutputSurfaceFrame frame) { | 78 void DisplayOutputSurfaceOzone::SwapBuffers(cc::OutputSurfaceFrame frame) { |
79 DCHECK(buffer_queue_); | 79 DCHECK(buffer_queue_); |
80 | 80 |
81 // TODO(rjkroege): What if swap happens again before DidReceiveSwapBuffersAck | 81 // TODO(rjkroege): What if swap happens again before DidReceiveSwapBuffersAck |
82 // then it would see the wrong size? | 82 // then it would see the wrong size? |
83 DCHECK(reshape_size_ == frame.size); | 83 DCHECK(reshape_size_ == frame.size); |
84 swap_size_ = reshape_size_; | 84 swap_size_ = reshape_size_; |
85 | 85 |
86 buffer_queue_->SwapBuffers(frame.sub_buffer_rect ? *frame.sub_buffer_rect | 86 gfx::Rect damage_rect = |
87 : gfx::Rect(swap_size_)); | 87 frame.sub_buffer_rect ? *frame.sub_buffer_rect : gfx::Rect(swap_size_); |
| 88 // Use previous buffer when damage rect is empty. This avoids unnecessary |
| 89 // partial swap work and makes it possible to support empty swaps on devices |
| 90 // where partial swaps are disabled. |
| 91 if (!damage_rect.IsEmpty()) |
| 92 buffer_queue_->SwapBuffers(damage_rect); |
| 93 |
88 DisplayOutputSurface::SwapBuffers(std::move(frame)); | 94 DisplayOutputSurface::SwapBuffers(std::move(frame)); |
89 } | 95 } |
90 | 96 |
91 uint32_t DisplayOutputSurfaceOzone::GetFramebufferCopyTextureFormat() { | 97 uint32_t DisplayOutputSurfaceOzone::GetFramebufferCopyTextureFormat() { |
92 return buffer_queue_->internal_format(); | 98 return buffer_queue_->internal_format(); |
93 } | 99 } |
94 | 100 |
95 bool DisplayOutputSurfaceOzone::IsDisplayedAsOverlayPlane() const { | 101 bool DisplayOutputSurfaceOzone::IsDisplayedAsOverlayPlane() const { |
96 // TODO(rjkroege): implement remaining overlay functionality. | 102 // TODO(rjkroege): implement remaining overlay functionality. |
97 return true; | 103 return true; |
98 } | 104 } |
99 | 105 |
100 unsigned DisplayOutputSurfaceOzone::GetOverlayTextureId() const { | 106 unsigned DisplayOutputSurfaceOzone::GetOverlayTextureId() const { |
101 return buffer_queue_->current_texture_id(); | 107 return buffer_queue_->GetCurrentTextureId(); |
102 } | 108 } |
103 | 109 |
104 void DisplayOutputSurfaceOzone::DidReceiveSwapBuffersAck( | 110 void DisplayOutputSurfaceOzone::DidReceiveSwapBuffersAck( |
105 gfx::SwapResult result) { | 111 gfx::SwapResult result) { |
106 bool force_swap = false; | 112 bool force_swap = false; |
107 if (result == gfx::SwapResult::SWAP_NAK_RECREATE_BUFFERS) { | 113 if (result == gfx::SwapResult::SWAP_NAK_RECREATE_BUFFERS) { |
108 // Even through the swap failed, this is a fixable error so we can pretend | 114 // Even through the swap failed, this is a fixable error so we can pretend |
109 // it succeeded to the rest of the system. | 115 // it succeeded to the rest of the system. |
110 result = gfx::SwapResult::SWAP_ACK; | 116 result = gfx::SwapResult::SWAP_ACK; |
111 buffer_queue_->RecreateBuffers(); | 117 buffer_queue_->RecreateBuffers(); |
112 force_swap = true; | 118 force_swap = true; |
113 } | 119 } |
114 | 120 |
115 buffer_queue_->PageFlipComplete(); | 121 buffer_queue_->PageFlipComplete(); |
116 client()->DidReceiveSwapBuffersAck(); | 122 client()->DidReceiveSwapBuffersAck(); |
117 | 123 |
118 if (force_swap) | 124 if (force_swap) |
119 client()->SetNeedsRedrawRect(gfx::Rect(swap_size_)); | 125 client()->SetNeedsRedrawRect(gfx::Rect(swap_size_)); |
120 } | 126 } |
121 | 127 |
122 } // namespace ui | 128 } // namespace ui |
OLD | NEW |