GPU workaround to simulate Out of Memory errors with large textures
[chromium-blink-merge.git] / content / common / gpu / null_transport_surface.cc
blobebcea853a675f95a1d5a736e5754eb21d334da86
1 // Copyright (c) 2014 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/common/gpu/null_transport_surface.h"
7 #include "base/command_line.h"
8 #include "content/common/gpu/gpu_channel.h"
9 #include "content/common/gpu/gpu_channel_manager.h"
10 #include "content/common/gpu/gpu_command_buffer_stub.h"
11 #include "content/public/common/content_switches.h"
12 #include "gpu/command_buffer/service/context_group.h"
14 namespace content {
16 NullTransportSurface::NullTransportSurface(
17 GpuChannelManager* manager,
18 GpuCommandBufferStub* stub,
19 const gfx::GLSurfaceHandle& handle)
20 : PassThroughImageTransportSurface(manager,
21 stub,
22 manager->GetDefaultOffscreenSurface()),
23 parent_client_id_(handle.parent_client_id) {
26 NullTransportSurface::~NullTransportSurface() {
29 bool NullTransportSurface::Initialize() {
30 if (!surface())
31 return false;
33 if (!PassThroughImageTransportSurface::Initialize())
34 return false;
36 GpuChannel* parent_channel =
37 GetHelper()->manager()->LookupChannel(parent_client_id_);
38 if (parent_channel) {
39 const base::CommandLine* command_line =
40 base::CommandLine::ForCurrentProcess();
41 if (command_line->HasSwitch(switches::kUIPrioritizeInGpuProcess))
42 GetHelper()->SetPreemptByFlag(parent_channel->GetPreemptionFlag());
45 return true;
48 void NullTransportSurface::Destroy() {
49 // Do not destroy |surface_| since we use the shared offscreen surface.
52 bool NullTransportSurface::SwapBuffers() {
53 NOTIMPLEMENTED();
54 return false;
57 bool NullTransportSurface::PostSubBuffer(
58 int x, int y, int width, int height) {
59 NOTIMPLEMENTED();
60 return false;
63 void NullTransportSurface::SendVSyncUpdateIfAvailable() {
64 NOTREACHED();
67 bool NullTransportSurface::OnMakeCurrent(gfx::GLContext* context) {
68 // Override PassThroughImageTransportSurface default behavior which
69 // sets the swap interval.
70 return true;
73 } // namespace content