summaryrefslogtreecommitdiffstats
path: root/content/common/gpu/null_transport_surface.cc
blob: 33521a06d4c4965468afd69bce6aace448e28606 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright (c) 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "content/common/gpu/null_transport_surface.h"

#include "base/command_line.h"
#include "content/common/gpu/gpu_channel.h"
#include "content/common/gpu/gpu_channel_manager.h"
#include "content/common/gpu/gpu_command_buffer_stub.h"
#include "content/public/common/content_switches.h"
#include "gpu/command_buffer/service/context_group.h"

namespace content {

NullTransportSurface::NullTransportSurface(
    GpuChannelManager* manager,
    GpuCommandBufferStub* stub,
    const gfx::GLSurfaceHandle& handle)
    : PassThroughImageTransportSurface(manager,
                                       stub,
                                       manager->GetDefaultOffscreenSurface()),
      parent_client_id_(handle.parent_client_id) {
}

NullTransportSurface::~NullTransportSurface() {
}

bool NullTransportSurface::Initialize() {
  if (!surface())
    return false;

  if (!PassThroughImageTransportSurface::Initialize())
    return false;

  GpuChannel* parent_channel =
      GetHelper()->manager()->LookupChannel(parent_client_id_);
  if (parent_channel) {
    const base::CommandLine* command_line =
        base::CommandLine::ForCurrentProcess();
    if (command_line->HasSwitch(switches::kUIPrioritizeInGpuProcess))
      GetHelper()->SetPreemptByFlag(parent_channel->GetPreemptionFlag());
  }

  return true;
}

void NullTransportSurface::Destroy() {
  // Do not destroy |surface_| since we use the shared offscreen surface.
}

gfx::SwapResult NullTransportSurface::SwapBuffers() {
  NOTIMPLEMENTED();
  return gfx::SwapResult::SWAP_FAILED;
}

gfx::SwapResult NullTransportSurface::PostSubBuffer(int x,
                                                    int y,
                                                    int width,
                                                    int height) {
  NOTIMPLEMENTED();
  return gfx::SwapResult::SWAP_FAILED;
}

void NullTransportSurface::SendVSyncUpdateIfAvailable() {
  NOTREACHED();
}

bool NullTransportSurface::OnMakeCurrent(gfx::GLContext* context) {
  // Override PassThroughImageTransportSurface default behavior which
  // sets the swap interval.
  return true;
}

}  // namespace content