diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-09 21:03:45 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-09 21:03:45 +0000 |
commit | 09f6738713c25d6ab583ed0f94722495ee78b05d (patch) | |
tree | e72922013ccaaa1ebf513f6933a40da10362a29d /cc/layers/delegated_frame_provider.h | |
parent | ad87c674c4bb4200b6c25dec05ac25f3eceba24c (diff) | |
download | chromium_src-09f6738713c25d6ab583ed0f94722495ee78b05d.zip chromium_src-09f6738713c25d6ab583ed0f94722495ee78b05d.tar.gz chromium_src-09f6738713c25d6ab583ed0f94722495ee78b05d.tar.bz2 |
aura: Allow delegated frames to be used by more than one impl layer.
Delegated frames can be used by multiple impl layers within a single
compositor if they are given to different DelegatedRendererLayers which
each send the frame to their impl layer.
Also, they can be given to different DelegatedRendererLayers that live
in different compositors.
So we need something that outlives any DelegatedRendererLayer and will
receive returned resources from the impl side of multiple compositors
and know when to release resoures back to the child compositor, and how
many resources to release.
This patch introduces two new classes:
DelegatedFrameProvider. This class holds a delegated frame and notifies
a single DelegatedRendererLayer (the latest one to attach to it) about
new frames so that it can grab them and display them. If a new
DelegatedRendererLayer steals a DelegatedFrameProvider it will receive
notifications in the future and the first layer will stop updating.
DelegatedFrameResourceCollection. This class holds resources and ref
counts on them to keep track of how many refs are being used by
compositor instances, and how many refs have been received from the
child compositor. Once a resource is not in use anymore by any
compositors, all references passed from the child compositor will
be made available via TakeUnusedResourcesForChildCompositor().
Tests:
LayerTreeHostDelegatedTestTwoImplLayers
LayerTreeHostDelegatedTestRemoveAndAddToTree
LayerTreeHostDelegatedTestRemoveAndChangeResources
R=piman,alexst@chromium.org
BUG=263069
Review URL: https://codereview.chromium.org/26023004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@227807 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/layers/delegated_frame_provider.h')
-rw-r--r-- | cc/layers/delegated_frame_provider.h | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/cc/layers/delegated_frame_provider.h b/cc/layers/delegated_frame_provider.h new file mode 100644 index 0000000..b71c748 --- /dev/null +++ b/cc/layers/delegated_frame_provider.h @@ -0,0 +1,75 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CC_LAYERS_DELEGATED_FRAME_PROVIDER_H_ +#define CC_LAYERS_DELEGATED_FRAME_PROVIDER_H_ + +#include <vector> + +#include "base/memory/ref_counted.h" +#include "base/memory/scoped_ptr.h" +#include "cc/base/cc_export.h" +#include "cc/resources/return_callback.h" +#include "cc/resources/returned_resource.h" +#include "ui/gfx/rect_f.h" +#include "ui/gfx/size.h" + +namespace cc { +class DelegatedFrameData; +class DelegatedFrameResourceCollection; +class DelegatedRendererLayer; + +// Only one observing layer has ownership of the DelegatedFrameProvider. Only +// the active observer should call GetFrameDataAndRefResources(). All frames +// provided by a single DelegatedFrameProvider must have the same size. A new +// provider must be used for frames of a different size. +class CC_EXPORT DelegatedFrameProvider + : public base::RefCounted<DelegatedFrameProvider> { + public: + explicit DelegatedFrameProvider( + const scoped_refptr<DelegatedFrameResourceCollection>& + resource_collection, + scoped_ptr<DelegatedFrameData> frame); + + void AddObserver(DelegatedRendererLayer* layer); + void RemoveObserver(DelegatedRendererLayer* layer); + + void SetFrameData(scoped_ptr<DelegatedFrameData> frame); + + // The DelegatedFrameData returned here must be displayed in order to not + // lose track of damage. + DelegatedFrameData* GetFrameDataAndRefResources( + DelegatedRendererLayer* observer, + gfx::RectF* damage); + + ReturnCallback GetReturnResourcesCallbackForImplThread(); + void UnrefResourcesOnMainThread(const ReturnedResourceArray& unused); + + gfx::Size frame_size() const { return frame_size_; } + + private: + friend class base::RefCounted<DelegatedFrameProvider>; + ~DelegatedFrameProvider(); + + scoped_refptr<DelegatedFrameResourceCollection> resource_collection_; + + scoped_ptr<DelegatedFrameData> frame_; + + struct Observer { + DelegatedRendererLayer* layer; + gfx::RectF damage; + + Observer(DelegatedRendererLayer* layer, const gfx::RectF& damage) + : layer(layer), damage(damage) {} + }; + std::vector<Observer> observers_; + + gfx::Size frame_size_; + + DISALLOW_COPY_AND_ASSIGN(DelegatedFrameProvider); +}; + +} // namespace cc + +#endif // CC_LAYERS_DELEGATED_FRAME_PROVIDER_H_ |