From efbdb3ac428aa1829161729189604865e606691b Mon Sep 17 00:00:00 2001 From: "clholgat@chromium.org" Date: Fri, 4 Oct 2013 00:35:13 +0000 Subject: Generic UIResourceLayer for shared resources. Separated the UIResource management from the NinePatchLayer because we need it for other things as well. BUG=235290 Review URL: https://codereview.chromium.org/24716003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@226908 0039d316-1c4b-4281-b951-d872f2087c98 --- cc/layers/ui_resource_layer.h | 59 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 cc/layers/ui_resource_layer.h (limited to 'cc/layers/ui_resource_layer.h') diff --git a/cc/layers/ui_resource_layer.h b/cc/layers/ui_resource_layer.h new file mode 100644 index 0000000..173ca44 --- /dev/null +++ b/cc/layers/ui_resource_layer.h @@ -0,0 +1,59 @@ +// 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_UI_RESOURCE_LAYER_H_ +#define CC_LAYERS_UI_RESOURCE_LAYER_H_ + +#include "base/memory/scoped_ptr.h" +#include "cc/base/cc_export.h" +#include "cc/layers/layer.h" +#include "cc/resources/ui_resource_client.h" +#include "ui/gfx/rect.h" + +namespace cc { + +class LayerTreeHost; +class ScopedUIResource; + +class CC_EXPORT UIResourceLayer : public Layer { + public: + static scoped_refptr Create(); + + virtual bool DrawsContent() const OVERRIDE; + + virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; + + virtual void SetLayerTreeHost(LayerTreeHost* host) OVERRIDE; + + void SetBitmap(const SkBitmap& skbitmap); + + // An alternative way of setting the resource to allow for sharing. + void SetUIResourceId(UIResourceId resource_id); + + class UIResourceHolder { + public: + virtual UIResourceId id() = 0; + virtual ~UIResourceHolder(); + }; + + protected: + UIResourceLayer(); + virtual ~UIResourceLayer(); + + scoped_ptr ui_resource_holder_; + SkBitmap bitmap_; + + private: + virtual scoped_ptr CreateLayerImpl(LayerTreeImpl* tree_impl) + OVERRIDE; + void RecreateUIResourceHolder(); + + + + DISALLOW_COPY_AND_ASSIGN(UIResourceLayer); +}; + +} // namespace cc + +#endif // CC_LAYERS_UI_RESOURCE_LAYER_H_ -- cgit v1.1