Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(388)

Side by Side Diff: content/browser/compositor/gpu_browser_compositor_output_surface.cc

Issue 2646243002: Use IDCompositionSurface to implement DirectCompositionSurfaceWin. (Closed)
Patch Set: better Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/gpu_browser_compositor_output_surface.h" 5 #include "content/browser/compositor/gpu_browser_compositor_output_surface.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "cc/output/output_surface_client.h" 10 #include "cc/output/output_surface_client.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 void GpuBrowserCompositorOutputSurface::BindFramebuffer() { 83 void GpuBrowserCompositorOutputSurface::BindFramebuffer() {
84 context_provider()->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, 0); 84 context_provider()->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, 0);
85 } 85 }
86 86
87 void GpuBrowserCompositorOutputSurface::Reshape( 87 void GpuBrowserCompositorOutputSurface::Reshape(
88 const gfx::Size& size, 88 const gfx::Size& size,
89 float device_scale_factor, 89 float device_scale_factor,
90 const gfx::ColorSpace& color_space, 90 const gfx::ColorSpace& color_space,
91 bool has_alpha, 91 bool has_alpha,
92 bool use_stencil) { 92 bool use_stencil) {
93 size_ = size;
94 has_set_draw_rectangle_ = false;
93 context_provider()->ContextGL()->ResizeCHROMIUM( 95 context_provider()->ContextGL()->ResizeCHROMIUM(
94 size.width(), size.height(), device_scale_factor, has_alpha); 96 size.width(), size.height(), device_scale_factor, has_alpha);
95 } 97 }
96 98
97 void GpuBrowserCompositorOutputSurface::SwapBuffers( 99 void GpuBrowserCompositorOutputSurface::SwapBuffers(
98 cc::OutputSurfaceFrame frame) { 100 cc::OutputSurfaceFrame frame) {
99 GetCommandBufferProxy()->SetLatencyInfo(frame.latency_info); 101 GetCommandBufferProxy()->SetLatencyInfo(frame.latency_info);
100 102
101 gfx::Rect swap_rect = frame.sub_buffer_rect; 103 gfx::Rect swap_rect = frame.sub_buffer_rect;
102 gfx::Size surface_size = frame.size; 104 gfx::Size surface_size = frame.size;
103 if (reflector_) { 105 if (reflector_) {
104 if (swap_rect == gfx::Rect(surface_size)) { 106 if (swap_rect == gfx::Rect(surface_size)) {
105 reflector_texture_->CopyTextureFullImage(surface_size); 107 reflector_texture_->CopyTextureFullImage(surface_size);
106 reflector_->OnSourceSwapBuffers(surface_size); 108 reflector_->OnSourceSwapBuffers(surface_size);
107 } else { 109 } else {
108 reflector_texture_->CopyTextureSubImage(swap_rect); 110 reflector_texture_->CopyTextureSubImage(swap_rect);
109 reflector_->OnSourcePostSubBuffer(swap_rect, surface_size); 111 reflector_->OnSourcePostSubBuffer(swap_rect, surface_size);
110 } 112 }
111 } 113 }
112 114
115 set_draw_rectangle_for_frame_ = false;
116
113 if (swap_rect == gfx::Rect(frame.size)) 117 if (swap_rect == gfx::Rect(frame.size))
114 context_provider_->ContextSupport()->Swap(); 118 context_provider_->ContextSupport()->Swap();
115 else 119 else
116 context_provider_->ContextSupport()->PartialSwapBuffers(swap_rect); 120 context_provider_->ContextSupport()->PartialSwapBuffers(swap_rect);
117 } 121 }
118 122
119 uint32_t GpuBrowserCompositorOutputSurface::GetFramebufferCopyTextureFormat() { 123 uint32_t GpuBrowserCompositorOutputSurface::GetFramebufferCopyTextureFormat() {
120 auto* gl = static_cast<ui::ContextProviderCommandBuffer*>(context_provider()); 124 auto* gl = static_cast<ui::ContextProviderCommandBuffer*>(context_provider());
121 return gl->GetCopyTextureInternalFormat(); 125 return gl->GetCopyTextureInternalFormat();
122 } 126 }
123 127
124 bool GpuBrowserCompositorOutputSurface::IsDisplayedAsOverlayPlane() const { 128 bool GpuBrowserCompositorOutputSurface::IsDisplayedAsOverlayPlane() const {
125 return false; 129 return false;
126 } 130 }
127 131
128 unsigned GpuBrowserCompositorOutputSurface::GetOverlayTextureId() const { 132 unsigned GpuBrowserCompositorOutputSurface::GetOverlayTextureId() const {
129 return 0; 133 return 0;
130 } 134 }
131 135
132 bool GpuBrowserCompositorOutputSurface::SurfaceIsSuspendForRecycle() const { 136 bool GpuBrowserCompositorOutputSurface::SurfaceIsSuspendForRecycle() const {
133 return false; 137 return false;
134 } 138 }
135 139
136 #if defined(OS_MACOSX) 140 #if defined(OS_MACOSX)
137 void GpuBrowserCompositorOutputSurface::SetSurfaceSuspendedForRecycle( 141 void GpuBrowserCompositorOutputSurface::SetSurfaceSuspendedForRecycle(
138 bool suspended) {} 142 bool suspended) {}
139 #endif 143 #endif
140 144
145 void GpuBrowserCompositorOutputSurface::SetDrawRectangle(
146 const gfx::Rect& rect) {
147 if (set_draw_rectangle_for_frame_)
148 return;
149 DCHECK(gfx::Rect(size_).Contains(rect));
150 DCHECK(has_set_draw_rectangle_ || (gfx::Rect(size_) == rect));
151 set_draw_rectangle_for_frame_ = true;
152 has_set_draw_rectangle_ = true;
153 context_provider()->ContextGL()->SetDrawRectangleCHROMIUM(
154 rect.x(), rect.y(), rect.width(), rect.height());
155 }
156
141 gpu::CommandBufferProxyImpl* 157 gpu::CommandBufferProxyImpl*
142 GpuBrowserCompositorOutputSurface::GetCommandBufferProxy() { 158 GpuBrowserCompositorOutputSurface::GetCommandBufferProxy() {
143 ui::ContextProviderCommandBuffer* provider_command_buffer = 159 ui::ContextProviderCommandBuffer* provider_command_buffer =
144 static_cast<ui::ContextProviderCommandBuffer*>(context_provider_.get()); 160 static_cast<ui::ContextProviderCommandBuffer*>(context_provider_.get());
145 gpu::CommandBufferProxyImpl* command_buffer_proxy = 161 gpu::CommandBufferProxyImpl* command_buffer_proxy =
146 provider_command_buffer->GetCommandBufferProxy(); 162 provider_command_buffer->GetCommandBufferProxy();
147 DCHECK(command_buffer_proxy); 163 DCHECK(command_buffer_proxy);
148 return command_buffer_proxy; 164 return command_buffer_proxy;
149 } 165 }
150 166
151 } // namespace content 167 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698