[Ozone-Gbm] Explicitly crash if trying software rendering on GBM
[chromium-blink-merge.git] / content / browser / compositor / software_browser_compositor_output_surface.cc
blob647a062550aa3d255ae16f819d89dd13e8dd61f5
1 // Copyright 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/browser/compositor/software_browser_compositor_output_surface.h"
7 #include "base/memory/ref_counted.h"
8 #include "base/message_loop/message_loop.h"
9 #include "base/time/time.h"
10 #include "cc/output/compositor_frame.h"
11 #include "cc/output/output_surface_client.h"
12 #include "cc/output/software_output_device.h"
13 #include "content/browser/renderer_host/render_widget_host_impl.h"
14 #include "ui/events/latency_info.h"
15 #include "ui/gfx/vsync_provider.h"
17 namespace content {
19 SoftwareBrowserCompositorOutputSurface::SoftwareBrowserCompositorOutputSurface(
20 scoped_ptr<cc::SoftwareOutputDevice> software_device,
21 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager)
22 : BrowserCompositorOutputSurface(software_device.Pass(),
23 vsync_manager),
24 weak_factory_(this) {
27 SoftwareBrowserCompositorOutputSurface::
28 ~SoftwareBrowserCompositorOutputSurface() {
31 void SoftwareBrowserCompositorOutputSurface::SwapBuffers(
32 cc::CompositorFrame* frame) {
33 for (size_t i = 0; i < frame->metadata.latency_info.size(); i++) {
34 frame->metadata.latency_info[i].AddLatencyNumber(
35 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0);
37 base::MessageLoop::current()->PostTask(
38 FROM_HERE,
39 base::Bind(
40 &RenderWidgetHostImpl::CompositorFrameDrawn,
41 frame->metadata.latency_info));
43 gfx::VSyncProvider* vsync_provider = software_device()->GetVSyncProvider();
44 if (vsync_provider) {
45 vsync_provider->GetVSyncParameters(base::Bind(
46 &BrowserCompositorOutputSurface::OnUpdateVSyncParametersFromGpu,
47 weak_factory_.GetWeakPtr()));
49 PostSwapBuffersComplete();
50 client_->DidSwapBuffers();
53 #if defined(OS_MACOSX)
54 void SoftwareBrowserCompositorOutputSurface::OnSurfaceDisplayed() {
55 // See GpuBrowserCompositorOutputSurface for when and how this is used.
56 NOTREACHED() << "Not expected for software surfaces.";
59 void SoftwareBrowserCompositorOutputSurface::OnSurfaceRecycled() {
62 bool SoftwareBrowserCompositorOutputSurface::ShouldNotShowFramesAfterRecycle()
63 const {
64 return false;
66 #endif
68 } // namespace content