delegating_renderer.h revision eb525c5499e34cc9c4b825d6d9e75bb07cc06ace
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.
4
5#ifndef CC_OUTPUT_DELEGATING_RENDERER_H_
6#define CC_OUTPUT_DELEGATING_RENDERER_H_
7
8#include "base/memory/scoped_ptr.h"
9#include "cc/base/cc_export.h"
10#include "cc/output/compositor_frame.h"
11#include "cc/output/renderer.h"
12#include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
13
14namespace cc {
15
16class OutputSurface;
17class ResourceProvider;
18
19class CC_EXPORT DelegatingRenderer : public Renderer {
20 public:
21  static scoped_ptr<DelegatingRenderer> Create(
22      RendererClient* client,
23      OutputSurface* output_surface,
24      ResourceProvider* resource_provider);
25  virtual ~DelegatingRenderer();
26
27  virtual const RendererCapabilities& Capabilities() const OVERRIDE;
28
29  virtual bool CanReadPixels() const OVERRIDE;
30
31  virtual void DrawFrame(RenderPassList* render_passes_in_draw_order) OVERRIDE;
32
33  virtual void Finish() OVERRIDE {}
34
35  virtual void SwapBuffers() OVERRIDE;
36  virtual void ReceiveSwapBuffersAck(const CompositorFrameAck&) OVERRIDE;
37
38  virtual void GetFramebufferPixels(void* pixels, gfx::Rect rect) OVERRIDE;
39
40  virtual bool IsContextLost() OVERRIDE;
41
42  virtual void SetVisible(bool visible) OVERRIDE;
43
44  virtual void SendManagedMemoryStats(size_t bytes_visible,
45                                      size_t bytes_visible_and_nearby,
46                                      size_t bytes_allocated) OVERRIDE;
47
48  virtual void SetDiscardBackBufferWhenNotVisible(bool discard) OVERRIDE;
49
50 private:
51  DelegatingRenderer(RendererClient* client,
52                     OutputSurface* output_surface,
53                     ResourceProvider* resource_provider);
54  bool Initialize();
55
56  OutputSurface* output_surface_;
57  ResourceProvider* resource_provider_;
58  RendererCapabilities capabilities_;
59  CompositorFrame frame_for_swap_buffers_;
60  bool visible_;
61
62  DISALLOW_COPY_AND_ASSIGN(DelegatingRenderer);
63};
64
65}  // namespace cc
66
67#endif  // CC_OUTPUT_DELEGATING_RENDERER_H_
68