summaryrefslogtreecommitdiffstats
path: root/cc/test/fake_layer_tree_host_client.cc
blob: a4a5d7ea7086783cc6c84d4a06d62e8cebbea753 (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
// Copyright 2012 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 "cc/test/fake_layer_tree_host_client.h"

#include "cc/output/context_provider.h"
#include "cc/test/fake_output_surface.h"
#include "cc/test/test_web_graphics_context_3d.h"
#include "cc/trees/layer_tree_host.h"

namespace cc {

FakeLayerTreeHostClient::FakeLayerTreeHostClient(RendererOptions options)
    : use_software_rendering_(options == DIRECT_SOFTWARE ||
                              options == DELEGATED_SOFTWARE),
      use_delegating_renderer_(options == DELEGATED_3D ||
                               options == DELEGATED_SOFTWARE),
      host_(NULL) {
}

FakeLayerTreeHostClient::~FakeLayerTreeHostClient() {}

void FakeLayerTreeHostClient::RequestNewOutputSurface() {
  DCHECK(host_);
  scoped_ptr<OutputSurface> surface;
  if (use_software_rendering_) {
    if (use_delegating_renderer_) {
      surface = FakeOutputSurface::CreateDelegatingSoftware(
          make_scoped_ptr(new SoftwareOutputDevice));
    } else {
      surface = FakeOutputSurface::CreateSoftware(
          make_scoped_ptr(new SoftwareOutputDevice));
    }
  } else if (use_delegating_renderer_) {
    surface = FakeOutputSurface::CreateDelegating3d();
  } else {
    surface = FakeOutputSurface::Create3d();
  }
  host_->SetOutputSurface(surface.Pass());
}

void FakeLayerTreeHostClient::DidFailToInitializeOutputSurface() {
  RequestNewOutputSurface();
}

}  // namespace cc