diff options
author | powei@chromium.org <powei@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-13 07:15:45 +0000 |
---|---|---|
committer | powei@chromium.org <powei@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-13 07:15:45 +0000 |
commit | 4825cbfd9d1ffe09f93172893e73819ab9347546 (patch) | |
tree | 0f1394483574c1711acd8e32f62a6ff098521f9b /content/public | |
parent | 993c38816404ba88b532bbaef4aaf232cdcf1dea (diff) | |
download | chromium_src-4825cbfd9d1ffe09f93172893e73819ab9347546.zip chromium_src-4825cbfd9d1ffe09f93172893e73819ab9347546.tar.gz chromium_src-4825cbfd9d1ffe09f93172893e73819ab9347546.tar.bz2 |
android: content::UIResourceProvider and content::UIResourceClientAndroid
We abstract out the allocation of UI resources into the UIResourceProvider.
We add a client class that allows for callback from the provider when
resources are invalidated (due to change in LayerTreeHost).
android= https://chrome-internal-review.googlesource.com/#/c/164986
BUG=
TBR=jam@chromium.org
Review URL: https://codereview.chromium.org/287593002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276955 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/public')
4 files changed, 61 insertions, 21 deletions
diff --git a/content/public/browser/android/compositor.h b/content/public/browser/android/compositor.h index 2d8126b..a8f734c 100644 --- a/content/public/browser/android/compositor.h +++ b/content/public/browser/android/compositor.h @@ -7,8 +7,8 @@ #include "base/callback.h" #include "cc/resources/ui_resource_bitmap.h" -#include "cc/resources/ui_resource_client.h" #include "content/common/content_export.h" +#include "content/public/browser/android/ui_resource_provider.h" #include "ui/gfx/native_widget_types.h" #include "ui/gfx/rect.h" #include "ui/gfx/size.h" @@ -25,6 +25,7 @@ class JavaBitmap; namespace content { class CompositorClient; +class UIResourceProvider; // An interface to the browser-side compositor. class CONTENT_EXPORT Compositor { @@ -68,20 +69,8 @@ class CONTENT_EXPORT Compositor { // Composite *without* having modified the layer tree. virtual void SetNeedsComposite() = 0; - // Generates a UIResource and returns a UIResourceId. |is_transient| - // indicates whether or not to release the resource once the bitmap - // has been uploaded. May return 0. - virtual cc::UIResourceId GenerateUIResource(const SkBitmap& bitmap, - bool is_transient) = 0; - - // Generates an ETC1 compressed UIResource. See above for |is_transient|. - // May return 0. - virtual cc::UIResourceId GenerateCompressedUIResource(const gfx::Size& size, - void* pixels, - bool is_transient) = 0; - - // Deletes a UIResource. - virtual void DeleteUIResource(cc::UIResourceId resource_id) = 0; + // Returns the UI resource provider associated with the compositor. + virtual UIResourceProvider& GetUIResourceProvider() = 0; protected: Compositor() {} diff --git a/content/public/browser/android/compositor_client.h b/content/public/browser/android/compositor_client.h index 09a12e5..84a263e 100644 --- a/content/public/browser/android/compositor_client.h +++ b/content/public/browser/android/compositor_client.h @@ -20,12 +20,6 @@ class CONTENT_EXPORT CompositorClient { // Tells the client that GL resources were lost and need to be reinitialized. virtual void DidLoseResources() {} - // Tells the client that UI resources were lost and need to be reinitialized. - virtual void DidLoseUIResources() {} - - // Mark the UI Resources as being invalid for use. - virtual void UIResourcesAreInvalid() {} - protected: CompositorClient() {} virtual ~CompositorClient() {} diff --git a/content/public/browser/android/ui_resource_client_android.h b/content/public/browser/android/ui_resource_client_android.h new file mode 100644 index 0000000..83228bd --- /dev/null +++ b/content/public/browser/android/ui_resource_client_android.h @@ -0,0 +1,30 @@ +// Copyright 2014 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 CONTENT_PUBLIC_BROWSER_ANDROID_UI_RESOURCE_CLIENT_ANDROID_H_ +#define CONTENT_PUBLIC_BROWSER_ANDROID_UI_RESOURCE_CLIENT_ANDROID_H_ + +#include "cc/resources/ui_resource_client.h" +#include "content/common/content_export.h" + +namespace content { + +class UIResourceProvider; + +// Android's UIResourceClient has one extra callback (UIResourceIsInvalid). +// This signal is intended for the case when the LayerTreeHost is cleared and +// the user needs to recreate their resources. +// TODO(powei): This interface can be removed once crbug.com/374906 has been +// addressed. +class CONTENT_EXPORT UIResourceClientAndroid : public cc::UIResourceClient { + public: + // This method indicates that the UI resource the user holds is no longer + // valid. The user should not call DeleteUIResource on any resource generated + // before this signal. + virtual void UIResourceIsInvalid() = 0; +}; + +} // namespace content + +#endif // CONTENT_PUBLIC_BROWSER_ANDROID_UI_RESOURCE_CLIENT_ANDROID_H_ diff --git a/content/public/browser/android/ui_resource_provider.h b/content/public/browser/android/ui_resource_provider.h new file mode 100644 index 0000000..38511e1 --- /dev/null +++ b/content/public/browser/android/ui_resource_provider.h @@ -0,0 +1,27 @@ +// Copyright 2014 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 CONTENT_PUBLIC_BROWSER_ANDROID_UI_RESOURCE_PROVIDER_H_ +#define CONTENT_PUBLIC_BROWSER_ANDROID_UI_RESOURCE_PROVIDER_H_ + +#include "cc/resources/ui_resource_client.h" +#include "content/common/content_export.h" + +namespace content { + +class UIResourceClientAndroid; + +class CONTENT_EXPORT UIResourceProvider { + public: + virtual ~UIResourceProvider() {} + + virtual cc::UIResourceId CreateUIResource( + UIResourceClientAndroid* client) = 0; + + virtual void DeleteUIResource(cc::UIResourceId resource_id) = 0; +}; + +} // namespace content + +#endif // CONTENT_PUBLIC_BROWSER_ANDROID_UI_RESOURCE_PROVIDER_H_ |