Make USB permissions work in the new permission message system
[chromium-blink-merge.git] / content / browser / compositor / reflector_texture.cc
blobed6a3bd86dbe7774254ad83b629fcf1b869e793c
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/browser/compositor/reflector_texture.h"
7 #include "content/browser/compositor/owned_mailbox.h"
8 #include "content/common/gpu/client/context_provider_command_buffer.h"
9 #include "content/common/gpu/client/gl_helper.h"
10 #include "gpu/command_buffer/client/context_support.h"
11 #include "gpu/command_buffer/client/gles2_interface.h"
13 namespace content {
15 ReflectorTexture::ReflectorTexture(cc::ContextProvider* context_provider)
16 : texture_id_(0) {
17 GLHelper* shared_helper =
18 ImageTransportFactory::GetInstance()->GetGLHelper();
19 mailbox_ = new OwnedMailbox(shared_helper);
20 gpu::gles2::GLES2Interface* gl = context_provider->ContextGL();
22 gl_helper_.reset(new GLHelper(gl, context_provider->ContextSupport()));
24 texture_id_ = gl_helper_->ConsumeMailboxToTexture(
25 mailbox_->mailbox(), mailbox_->sync_point());
28 ReflectorTexture::~ReflectorTexture() {
29 gl_helper_->DeleteTexture(texture_id_);
32 void ReflectorTexture::CopyTextureFullImage(const gfx::Size& size) {
33 gl_helper_->CopyTextureFullImage(texture_id_, size);
34 // Insert a barrier to make the copy show up in the mirroring compositor's
35 // mailbox. Since the the compositor contexts and the
36 // ImageTransportFactory's
37 // GLHelper are all on the same GPU channel, this is sufficient instead of
38 // plumbing through a sync point.
39 gl_helper_->InsertOrderingBarrier();
42 void ReflectorTexture::CopyTextureSubImage(const gfx::Rect& rect) {
43 gl_helper_->CopyTextureSubImage(texture_id_, rect);
44 // Insert a barrier for the same reason above.
45 gl_helper_->InsertOrderingBarrier();
48 } // namespace content