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 13 namespace cc { 14 15 class OutputSurface; 16 class ResourceProvider; 17 18 class CC_EXPORT DelegatingRenderer : public Renderer { 19 public: 20 static scoped_ptr<DelegatingRenderer> Create( 21 RendererClient* client, 22 OutputSurface* output_surface, 23 ResourceProvider* resource_provider); 24 virtual ~DelegatingRenderer(); 25 26 virtual const RendererCapabilities& Capabilities() const OVERRIDE; 27 28 virtual bool CanReadPixels() const OVERRIDE; 29 30 virtual void DrawFrame(RenderPassList* render_passes_in_draw_order, 31 bool disable_picture_quad_image_filtering) 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