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 const LayerTreeSettings* settings, 23 OutputSurface* output_surface, 24 ResourceProvider* resource_provider); 25 virtual ~DelegatingRenderer(); 26 27 virtual const RendererCapabilitiesImpl& Capabilities() const OVERRIDE; 28 29 virtual bool CanReadPixels() const OVERRIDE; 30 31 virtual void DrawFrame(RenderPassList* render_passes_in_draw_order, 32 ContextProvider* offscreen_context_provider, 33 float device_scale_factor, 34 gfx::Rect device_viewport_rect, 35 gfx::Rect device_clip_rect, 36 bool allow_partial_swap, 37 bool disable_picture_quad_image_filtering) OVERRIDE; 38 Finish()39 virtual void Finish() OVERRIDE {} 40 41 virtual void SwapBuffers(const CompositorFrameMetadata& metadata) OVERRIDE; 42 virtual void ReceiveSwapBuffersAck(const CompositorFrameAck&) OVERRIDE; 43 44 virtual void GetFramebufferPixels(void* pixels, gfx::Rect rect) OVERRIDE; 45 46 virtual bool IsContextLost() OVERRIDE; 47 48 virtual void SetVisible(bool visible) OVERRIDE; 49 50 virtual void SendManagedMemoryStats(size_t bytes_visible, 51 size_t bytes_visible_and_nearby, 52 size_t bytes_allocated) OVERRIDE; 53 54 private: 55 DelegatingRenderer(RendererClient* client, 56 const LayerTreeSettings* settings, 57 OutputSurface* output_surface, 58 ResourceProvider* resource_provider); 59 bool Initialize(); 60 61 OutputSurface* output_surface_; 62 ResourceProvider* resource_provider_; 63 RendererCapabilitiesImpl capabilities_; 64 scoped_ptr<DelegatedFrameData> delegated_frame_data_; 65 bool visible_; 66 67 DISALLOW_COPY_AND_ASSIGN(DelegatingRenderer); 68 }; 69 70 } // namespace cc 71 72 #endif // CC_OUTPUT_DELEGATING_RENDERER_H_ 73