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

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

Issue 846063002: compositor: Fix texture flipping for SW mirroring with surfaceless (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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/reflector_impl.h" 5 #include "content/browser/compositor/reflector_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "content/browser/compositor/browser_compositor_output_surface.h" 9 #include "content/browser/compositor/browser_compositor_output_surface.h"
10 #include "content/browser/compositor/owned_mailbox.h" 10 #include "content/browser/compositor/owned_mailbox.h"
11 #include "content/common/gpu/client/gl_helper.h" 11 #include "content/common/gpu/client/gl_helper.h"
12 #include "ui/compositor/layer.h" 12 #include "ui/compositor/layer.h"
13 13
14 namespace content { 14 namespace content {
15 15
16 ReflectorImpl::ReflectorImpl( 16 ReflectorImpl::ReflectorImpl(
17 ui::Compositor* mirrored_compositor, 17 ui::Compositor* mirrored_compositor,
18 ui::Layer* mirroring_layer, 18 ui::Layer* mirroring_layer,
19 IDMap<BrowserCompositorOutputSurface>* output_surface_map, 19 IDMap<BrowserCompositorOutputSurface>* output_surface_map,
20 base::MessageLoopProxy* compositor_thread_loop, 20 base::MessageLoopProxy* compositor_thread_loop,
21 int surface_id) 21 int surface_id)
22 : impl_unsafe_(output_surface_map), 22 : impl_unsafe_(output_surface_map),
23 main_unsafe_(mirrored_compositor, mirroring_layer), 23 main_unsafe_(mirrored_compositor, mirroring_layer),
24 impl_message_loop_(compositor_thread_loop), 24 impl_message_loop_(compositor_thread_loop),
25 main_message_loop_(base::MessageLoopProxy::current()), 25 main_message_loop_(base::MessageLoopProxy::current()),
26 surface_id_(surface_id) { 26 surface_id_(surface_id),
27 flip_texture_(false) {
27 GLHelper* helper = ImageTransportFactory::GetInstance()->GetGLHelper(); 28 GLHelper* helper = ImageTransportFactory::GetInstance()->GetGLHelper();
28 MainThreadData& main = GetMain(); 29 MainThreadData& main = GetMain();
29 main.mailbox = new OwnedMailbox(helper); 30 main.mailbox = new OwnedMailbox(helper);
30 impl_message_loop_->PostTask( 31 impl_message_loop_->PostTask(
31 FROM_HERE, 32 FROM_HERE,
32 base::Bind( 33 base::Bind(
33 &ReflectorImpl::InitOnImplThread, this, main.mailbox->holder())); 34 &ReflectorImpl::InitOnImplThread, this, main.mailbox->holder()));
34 } 35 }
35 36
36 ReflectorImpl::MainThreadData::MainThreadData( 37 ReflectorImpl::MainThreadData::MainThreadData(
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 177
177 void ReflectorImpl::AttachToOutputSurfaceOnImplThread( 178 void ReflectorImpl::AttachToOutputSurfaceOnImplThread(
178 const gpu::MailboxHolder& mailbox_holder, 179 const gpu::MailboxHolder& mailbox_holder,
179 BrowserCompositorOutputSurface* output_surface) { 180 BrowserCompositorOutputSurface* output_surface) {
180 ImplThreadData& impl = GetImpl(); 181 ImplThreadData& impl = GetImpl();
181 if (output_surface == impl.output_surface) 182 if (output_surface == impl.output_surface)
182 return; 183 return;
183 if (impl.output_surface) 184 if (impl.output_surface)
184 DetachFromOutputSurface(); 185 DetachFromOutputSurface();
185 impl.output_surface = output_surface; 186 impl.output_surface = output_surface;
187 flip_texture_ = !output_surface->capabilities().flipped_output_surface;
danakj 2015/01/12 18:27:30 This is getting the flipped-ness of the current ou
achaulk 2015/01/12 18:47:35 All that matters is the flipped-ness of the source
danakj 2015/01/12 19:02:42 Oh this is the source surface? OK great :) I read
186 output_surface->context_provider()->BindToCurrentThread(); 188 output_surface->context_provider()->BindToCurrentThread();
187 impl.gl_helper.reset( 189 impl.gl_helper.reset(
188 new GLHelper(output_surface->context_provider()->ContextGL(), 190 new GLHelper(output_surface->context_provider()->ContextGL(),
189 output_surface->context_provider()->ContextSupport())); 191 output_surface->context_provider()->ContextSupport()));
190 impl.texture_id = impl.gl_helper->ConsumeMailboxToTexture( 192 impl.texture_id = impl.gl_helper->ConsumeMailboxToTexture(
191 mailbox_holder.mailbox, mailbox_holder.sync_point); 193 mailbox_holder.mailbox, mailbox_holder.sync_point);
192 impl.gl_helper->ResizeTexture(impl.texture_id, output_surface->SurfaceSize()); 194 impl.gl_helper->ResizeTexture(impl.texture_id, output_surface->SurfaceSize());
193 impl.gl_helper->Flush(); 195 impl.gl_helper->Flush();
194 output_surface->SetReflector(this); 196 output_surface->SetReflector(this);
195 // The texture doesn't have the data, so invokes full redraw now. 197 // The texture doesn't have the data, so invokes full redraw now.
(...skipping 12 matching lines...) Expand all
208 main.mirroring_layer->SetTextureMailbox( 210 main.mirroring_layer->SetTextureMailbox(
209 cc::TextureMailbox(main.mailbox->holder()), 211 cc::TextureMailbox(main.mailbox->holder()),
210 cc::SingleReleaseCallback::Create( 212 cc::SingleReleaseCallback::Create(
211 base::Bind(ReleaseMailbox, main.mailbox)), 213 base::Bind(ReleaseMailbox, main.mailbox)),
212 size); 214 size);
213 main.needs_set_mailbox = false; 215 main.needs_set_mailbox = false;
214 } else { 216 } else {
215 main.mirroring_layer->SetTextureSize(size); 217 main.mirroring_layer->SetTextureSize(size);
216 } 218 }
217 main.mirroring_layer->SetBounds(gfx::Rect(size)); 219 main.mirroring_layer->SetBounds(gfx::Rect(size));
220 main.mirroring_layer->SetTextureFlipped(flip_texture_);
218 } 221 }
219 222
220 void ReflectorImpl::FullRedrawOnMainThread(gfx::Size size) { 223 void ReflectorImpl::FullRedrawOnMainThread(gfx::Size size) {
221 MainThreadData& main = GetMain(); 224 MainThreadData& main = GetMain();
222 if (!main.mirroring_layer) 225 if (!main.mirroring_layer)
223 return; 226 return;
224 UpdateTextureSizeOnMainThread(size); 227 UpdateTextureSizeOnMainThread(size);
225 main.mirroring_layer->SchedulePaint(main.mirroring_layer->bounds()); 228 main.mirroring_layer->SchedulePaint(main.mirroring_layer->bounds());
226 } 229 }
227 230
228 void ReflectorImpl::UpdateSubBufferOnMainThread(gfx::Size size, 231 void ReflectorImpl::UpdateSubBufferOnMainThread(gfx::Size size,
danakj 2015/01/12 18:27:30 while you're here, these should be const& argument
achaulk 2015/01/12 18:47:35 Done.
229 gfx::Rect rect) { 232 gfx::Rect rect) {
230 MainThreadData& main = GetMain(); 233 MainThreadData& main = GetMain();
231 if (!main.mirroring_layer) 234 if (!main.mirroring_layer)
232 return; 235 return;
233 UpdateTextureSizeOnMainThread(size); 236 UpdateTextureSizeOnMainThread(size);
234 // Flip the coordinates to compositor's one. 237 if(flip_texture_) {
235 int y = size.height() - rect.y() - rect.height(); 238 // Flip the coordinates to compositor's one.
236 gfx::Rect new_rect(rect.x(), y, rect.width(), rect.height()); 239 int y = size.height() - rect.y() - rect.height();
237 main.mirroring_layer->SchedulePaint(new_rect); 240 gfx::Rect new_rect(rect.x(), y, rect.width(), rect.height());
241 main.mirroring_layer->SchedulePaint(new_rect);
242 } else {
243 main.mirroring_layer->SchedulePaint(rect);
danakj 2015/01/12 18:27:30 How about just doing rect math inside an if/else a
achaulk 2015/01/12 18:47:35 Sure
244 }
238 } 245 }
239 246
240 void ReflectorImpl::FullRedrawContentOnMainThread() { 247 void ReflectorImpl::FullRedrawContentOnMainThread() {
241 MainThreadData& main = GetMain(); 248 MainThreadData& main = GetMain();
242 main.mirrored_compositor->ScheduleFullRedraw(); 249 main.mirrored_compositor->ScheduleFullRedraw();
243 } 250 }
244 251
245 } // namespace content 252 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698