Fix Callback Issue During Card Dismissal Request
[chromium-blink-merge.git] / cc / test / fake_layer_tree_host_client.cc
blob1ee0bb80c17cd4835e87ad2b7dd15af17886c642
1 // Copyright 2012 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 "cc/test/fake_layer_tree_host_client.h"
7 #include "cc/output/context_provider.h"
8 #include "cc/test/fake_output_surface.h"
9 #include "cc/test/test_web_graphics_context_3d.h"
11 namespace cc {
13 FakeLayerTreeHostClient::FakeLayerTreeHostClient(RendererOptions options)
14 : use_software_rendering_(options == DIRECT_SOFTWARE ||
15 options == DELEGATED_SOFTWARE),
16 use_delegating_renderer_(options == DELEGATED_3D ||
17 options == DELEGATED_SOFTWARE) {}
19 FakeLayerTreeHostClient::~FakeLayerTreeHostClient() {}
21 scoped_ptr<OutputSurface> FakeLayerTreeHostClient::CreateOutputSurface(
22 bool fallback) {
23 if (use_software_rendering_) {
24 if (use_delegating_renderer_) {
25 return FakeOutputSurface::CreateDelegatingSoftware(
26 make_scoped_ptr(new SoftwareOutputDevice)).PassAs<OutputSurface>();
29 return FakeOutputSurface::CreateSoftware(
30 make_scoped_ptr(new SoftwareOutputDevice)).PassAs<OutputSurface>();
33 if (use_delegating_renderer_)
34 return FakeOutputSurface::CreateDelegating3d().PassAs<OutputSurface>();
35 return FakeOutputSurface::Create3d().PassAs<OutputSurface>();
38 scoped_refptr<ContextProvider>
39 FakeLayerTreeHostClient::OffscreenContextProvider() {
40 if (!offscreen_contexts_.get() ||
41 offscreen_contexts_->DestroyedOnMainThread())
42 offscreen_contexts_ = TestContextProvider::Create();
43 return offscreen_contexts_;
46 } // namespace cc