OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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_BROWSER_ANDROID_SYSTEM_UI_RESOURCE_H_ |
| 6 #define CONTENT_BROWSER_ANDROID_SYSTEM_UI_RESOURCE_H_ |
| 7 |
| 8 #include "cc/resources/ui_resource_client.h" |
| 9 #include "content/public/browser/android/ui_resource_client_android.h" |
| 10 #include "third_party/skia/include/core/SkBitmap.h" |
| 11 |
| 12 namespace content { |
| 13 |
| 14 class UIResourceProvider; |
| 15 |
| 16 class SystemUIResourceClient { |
| 17 public: |
| 18 // Notifies the user of SystemUIResource that the UIResourceId has changed. |
| 19 // The change can be due to UIResource creation or invalidation. The typical |
| 20 // user might want to forward the changed UIResourceId to the associated |
| 21 // cc::UIResourceLayers. |
| 22 virtual void OnUIResourceIdChanged() = 0; |
| 23 virtual ~SystemUIResourceClient() {} |
| 24 }; |
| 25 |
| 26 // SystemUIResource loads a Android system bitmap into a cc UI resource. |
| 27 // We assume that the given bitmap is immutable and SystemUIResource will keep a |
| 28 // reference to the given bitmap pixels. |
| 29 class SystemUIResource : public UIResourceClientAndroid { |
| 30 public: |
| 31 static scoped_ptr<SystemUIResource> Create(const SkBitmap& bitmap, |
| 32 UIResourceProvider* provider); |
| 33 |
| 34 virtual ~SystemUIResource(); |
| 35 |
| 36 // cc::UIResourceClient implementation. |
| 37 virtual cc::UIResourceBitmap GetBitmap(cc::UIResourceId uid, |
| 38 bool resource_lost) OVERRIDE; |
| 39 |
| 40 // content::UIResourceClientAndroid implementation. |
| 41 virtual void UIResourceIsInvalid() OVERRIDE; |
| 42 |
| 43 // |Load()| is the manual trigger (and the only trigger) to generate a |
| 44 // UIResource from the bitmap. This method is necessary because the |
| 45 // UIResourceId can be invalidated through the UIResourceClientAndroid |
| 46 // callback. It is the responsibility of the owner of SystemUIResource to |
| 47 // call |Load()| to initially generate a UIResource, and to call |Load()| |
| 48 // again whenever the UIResource is invalidated. |
| 49 void Load(); |
| 50 |
| 51 void SetClient(SystemUIResourceClient* client); |
| 52 |
| 53 cc::UIResourceId id() const { return id_; } |
| 54 |
| 55 private: |
| 56 SystemUIResource(const SkBitmap& bitmap, UIResourceProvider* provider); |
| 57 |
| 58 SkBitmap bitmap_; |
| 59 cc::UIResourceId id_; |
| 60 UIResourceProvider* provider_; |
| 61 SystemUIResourceClient* client_; |
| 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(SystemUIResource); |
| 64 }; |
| 65 |
| 66 } // namespace content |
| 67 |
| 68 #endif // CONTENT_BROWSER_ANDROID_SYSTEM_UI_RESOURCE_H_ |
OLD | NEW |