synchronous_compositor.h revision fb250657ef40d7500f20882d5c9909c1013367d3
1// Copyright 2013 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 CONTENT_PUBLIC_BROWSER_ANDROID_SYNCHRONOUS_COMPOSITOR_H_ 6#define CONTENT_PUBLIC_BROWSER_ANDROID_SYNCHRONOUS_COMPOSITOR_H_ 7 8#include "content/common/content_export.h" 9#include "ui/gfx/rect.h" 10#include "ui/gfx/size.h" 11 12class SkCanvas; 13 14namespace gfx { 15class Transform; 16}; 17 18namespace content { 19 20class WebContents; 21 22class SynchronousCompositorClient; 23 24// Interface for embedders that wish to direct compositing operations 25// synchronously under their own control. Only meaningful when the 26// kEnableSyncrhonousRendererCompositor flag is specified. 27class CONTENT_EXPORT SynchronousCompositor { 28 public: 29 // Must be called once per WebContents instance. Will create the compositor 30 // instance as needed, but only if |client| is non-NULL. 31 static void SetClientForWebContents(WebContents* contents, 32 SynchronousCompositorClient* client); 33 34 // Allows changing or resetting the client to NULL (this must be used if 35 // the client is being deleted prior to the DidDestroyCompositor() call 36 // being received by the client). Ownership of |client| remains with 37 // the caller. 38 virtual void SetClient(SynchronousCompositorClient* client) = 0; 39 40 // Synchronously initialize compositor for hardware draw. Can only be called 41 // while compositor is in software only mode, either after compositor is 42 // first created or after ReleaseHwDraw is called. It is invalid to 43 // DemandDrawHw before this returns true. 44 virtual bool InitializeHwDraw() = 0; 45 46 // Reverse of InitializeHwDraw above. Can only be called while hardware draw 47 // is already initialized. Brings compositor back to software only mode and 48 // releases all hardware resources. 49 virtual void ReleaseHwDraw() = 0; 50 51 // "On demand" hardware draw. The content is first clipped to |damage_area|, 52 // then transformed through |transform|, and finally clipped to |view_size| 53 // and by the existing stencil buffer if any. 54 virtual bool DemandDrawHw( 55 gfx::Size view_size, 56 const gfx::Transform& transform, 57 gfx::Rect damage_area, 58 bool stencil_enabled) = 0; 59 60 // "On demand" SW draw, into the supplied canvas (observing the transform 61 // and clip set there-in). 62 virtual bool DemandDrawSw(SkCanvas* canvas) = 0; 63 64 // Should be called by the embedder after the embedder had modified the 65 // scroll offset of the root layer (as returned by 66 // SynchronousCompositorClient::GetTotalRootLayerScrollOffset). 67 virtual void DidChangeRootLayerScrollOffset() = 0; 68 69 protected: 70 virtual ~SynchronousCompositor() {} 71}; 72 73} // namespace content 74 75#endif // CONTENT_PUBLIC_BROWSER_ANDROID_SYNCHRONOUS_COMPOSITOR_H_ 76