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.
5 #ifndef CHROME_BROWSER_ANDROID_COMPOSITOR_LAYER_TITLE_CACHE_H_
6 #define CHROME_BROWSER_ANDROID_COMPOSITOR_LAYER_TITLE_CACHE_H_
10 #include "base/android/jni_android.h"
11 #include "base/android/jni_weak_ref.h"
12 #include "base/bind.h"
13 #include "base/id_map.h"
14 #include "cc/resources/ui_resource_client.h"
15 #include "third_party/skia/include/core/SkBitmap.h"
16 #include "ui/gfx/geometry/size.h"
17 #include "ui/gfx/transform.h"
21 class UIResourceLayer
;
25 class ResourceManager
;
31 class DecorationTitle
;
33 // A native component of the Java LayerTitleCache class. This class
34 // will build and maintain layers that represent the cached titles in
36 class LayerTitleCache
{
38 static LayerTitleCache
* FromJavaObject(jobject jobj
);
40 LayerTitleCache(JNIEnv
* env
,
43 jint favicon_start_padding
,
44 jint favicon_end_padding
,
45 jint spinner_resource_id
,
46 jint spinner_incognito_resource_id
);
47 void Destroy(JNIEnv
* env
, jobject obj
);
49 // Called from Java, updates a native cc::Layer based on the new texture
51 void UpdateLayer(JNIEnv
* env
,
54 jint title_resource_id
,
55 jint favicon_resource_id
,
59 void ClearExcept(JNIEnv
* env
, jobject obj
, jint except_id
);
61 // Returns the layer that represents the title of tab of tab_id.
62 // Returns NULL if no layer can be found.
63 DecorationTitle
* GetTitleLayer(int tab_id
);
65 void SetResourceManager(ui::ResourceManager
* resource_manager
);
68 virtual ~LayerTitleCache();
70 IDMap
<DecorationTitle
, IDMapOwnPointer
> layer_cache_
;
72 JavaObjectWeakGlobalRef weak_java_title_cache_
;
74 int favicon_start_padding_
;
75 int favicon_end_padding_
;
77 int spinner_resource_id_
;
78 int spinner_incognito_resource_id_
;
80 ui::ResourceManager
* resource_manager_
;
82 DISALLOW_COPY_AND_ASSIGN(LayerTitleCache
);
85 bool RegisterLayerTitleCache(JNIEnv
* env
);
87 } // namespace android
90 #endif // CHROME_BROWSER_ANDROID_COMPOSITOR_LAYER_TITLE_CACHE_H_