diff options
author | zmo@chromium.org <zmo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-13 23:58:04 +0000 |
---|---|---|
committer | zmo@chromium.org <zmo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-13 23:58:04 +0000 |
commit | 20c8fc354c6716440d1f051a84c74f57f473d1e0 (patch) | |
tree | 793e6e9800e3d3704447098a25e73aa7b0fd8b22 /cc/resources | |
parent | 3b6107cf3d5377e793b84ff57ce82cda16ab5d44 (diff) | |
download | chromium_src-20c8fc354c6716440d1f051a84c74f57f473d1e0.zip chromium_src-20c8fc354c6716440d1f051a84c74f57f473d1e0.tar.gz chromium_src-20c8fc354c6716440d1f051a84c74f57f473d1e0.tar.bz2 |
Revert 223162 "Update the nine patch layer to use UI resources"
Breaks GpuMemoryTest.SingleWindowDoesNotExceedLimit on gpu bots.
One example: http://build.chromium.org/p/chromium.gpu/builders/Mac%2010.8%20Debug%20%28Intel%29/builds/11092/steps/content_browsertests/logs/SingleWindowDoesNotExceedLimit
> Update the nine patch layer to use UI resources
>
> The old nine-patch layer used priority resource manager for requesting textures.
> This patch updates the nine-patch layer to use the UI resource manager.
> this patch clarifies the semantics of the aperture in both image and layer
> The new semantics corresponds to existing logic on the android-side.
>
> Changes have been made to UIResourceBitmap to use SkPixelRef as ref-counted
> of the bitmap content.
>
> The android-side changes:
> https://gerrit-int.chromium.org/#/c/43103/
>
> BUG=276482,276487,290215
>
> Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=222732
>
> Review URL: https://chromiumcodereview.appspot.com/22870016
TBR=powei@chromium.org
Review URL: https://codereview.chromium.org/23740010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@223180 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/resources')
-rw-r--r-- | cc/resources/scoped_ui_resource.cc | 15 | ||||
-rw-r--r-- | cc/resources/scoped_ui_resource.h | 25 | ||||
-rw-r--r-- | cc/resources/ui_resource_bitmap.cc | 46 | ||||
-rw-r--r-- | cc/resources/ui_resource_bitmap.h | 40 | ||||
-rw-r--r-- | cc/resources/ui_resource_client.h | 4 |
5 files changed, 57 insertions, 73 deletions
diff --git a/cc/resources/scoped_ui_resource.cc b/cc/resources/scoped_ui_resource.cc index e69b4bc..0136a8e 100644 --- a/cc/resources/scoped_ui_resource.cc +++ b/cc/resources/scoped_ui_resource.cc @@ -12,12 +12,12 @@ namespace cc { scoped_ptr<ScopedUIResource> ScopedUIResource::Create( LayerTreeHost* host, - const UIResourceBitmap& bitmap) { + scoped_refptr<UIResourceBitmap> bitmap) { return make_scoped_ptr(new ScopedUIResource(host, bitmap)); } ScopedUIResource::ScopedUIResource(LayerTreeHost* host, - const UIResourceBitmap& bitmap) + scoped_refptr<UIResourceBitmap> bitmap) : bitmap_(bitmap), host_(host) { DCHECK(host_); id_ = host_->CreateUIResource(this); @@ -32,9 +32,16 @@ ScopedUIResource::~ScopedUIResource() { } } -UIResourceBitmap ScopedUIResource::GetBitmap(UIResourceId uid, - bool resource_lost) { +gfx::Size ScopedUIResource::GetSize() const { + return bitmap_->GetSize(); +} + +scoped_refptr<UIResourceBitmap> ScopedUIResource::GetBitmap( + UIResourceId uid, + bool resource_lost) { return bitmap_; } +ScopedUIResource::ScopedUIResource() {} + } // namespace cc diff --git a/cc/resources/scoped_ui_resource.h b/cc/resources/scoped_ui_resource.h index c257e1e..a4525e6 100644 --- a/cc/resources/scoped_ui_resource.h +++ b/cc/resources/scoped_ui_resource.h @@ -15,27 +15,28 @@ namespace cc { class LayerTreeHost; -// ScopedUIResource creates an UIResource from a bitmap and a LayerTreeHost. -// This class holds a pointer to the host so that when the instance goes out of -// scope, the created resource is deleted. On a GetBitmap call from the -// UIResource manager, ScopeUIResource always returns the reference to the -// initially given bitmap regardless of whether the request was due to lost -// resource or not. class CC_EXPORT ScopedUIResource : public UIResourceClient { public: - static scoped_ptr<ScopedUIResource> Create(LayerTreeHost* host, - const UIResourceBitmap& bitmap); + static scoped_ptr<ScopedUIResource> Create( + LayerTreeHost* host, + scoped_refptr<UIResourceBitmap> bitmap); virtual ~ScopedUIResource(); + gfx::Size GetSize() const; + // UIResourceClient implementation. - virtual UIResourceBitmap GetBitmap(UIResourceId uid, - bool resource_lost) OVERRIDE; + virtual scoped_refptr<UIResourceBitmap> GetBitmap( + UIResourceId uid, + bool resource_lost) OVERRIDE; UIResourceId id() { return id_; } protected: - ScopedUIResource(LayerTreeHost* host, const UIResourceBitmap& bitmap); + ScopedUIResource(LayerTreeHost* host, scoped_refptr<UIResourceBitmap> bitmap); + + // An empty default contructor for testing. + ScopedUIResource(); - UIResourceBitmap bitmap_; + scoped_refptr<UIResourceBitmap> bitmap_; LayerTreeHost* host_; UIResourceId id_; diff --git a/cc/resources/ui_resource_bitmap.cc b/cc/resources/ui_resource_bitmap.cc index 2acbd95..1510607d 100644 --- a/cc/resources/ui_resource_bitmap.cc +++ b/cc/resources/ui_resource_bitmap.cc @@ -4,45 +4,25 @@ #include "cc/resources/ui_resource_bitmap.h" -#include "base/logging.h" #include "base/memory/scoped_ptr.h" -#include "third_party/skia/include/core/SkBitmap.h" namespace cc { -uint8_t* UIResourceBitmap::GetPixels() const { - if (!pixel_ref_) - return NULL; - return static_cast<uint8_t*>(pixel_ref_->pixels()); -} - -void UIResourceBitmap::Create(const skia::RefPtr<SkPixelRef>& pixel_ref, - UIResourceFormat format, - UIResourceWrapMode wrap_mode, - gfx::Size size) { - DCHECK(size.width()); - DCHECK(size.height()); - DCHECK(pixel_ref); - DCHECK(pixel_ref->isImmutable()); - format_ = format; - wrap_mode_ = wrap_mode; - size_ = size; - pixel_ref_ = pixel_ref; -} - -UIResourceBitmap::UIResourceBitmap(const SkBitmap& skbitmap, - UIResourceWrapMode wrap_mode) { - DCHECK_EQ(skbitmap.config(), SkBitmap::kARGB_8888_Config); - DCHECK_EQ(skbitmap.width(), skbitmap.rowBytesAsPixels()); - DCHECK(skbitmap.isImmutable()); - - skia::RefPtr<SkPixelRef> pixel_ref = skia::SharePtr(skbitmap.pixelRef()); - Create(pixel_ref, - UIResourceBitmap::RGBA8, - wrap_mode, - gfx::Size(skbitmap.width(), skbitmap.height())); +scoped_refptr<UIResourceBitmap> +UIResourceBitmap::Create(uint8_t* pixels, + UIResourceFormat format, + UIResourceWrapMode wrap_mode, + gfx::Size size) { + scoped_refptr<UIResourceBitmap> ret = new UIResourceBitmap(); + ret->pixels_ = scoped_ptr<uint8_t[]>(pixels); + ret->format_ = format; + ret->wrap_mode_ = wrap_mode; + ret->size_ = size; + + return ret; } +UIResourceBitmap::UIResourceBitmap() {} UIResourceBitmap::~UIResourceBitmap() {} } // namespace cc diff --git a/cc/resources/ui_resource_bitmap.h b/cc/resources/ui_resource_bitmap.h index f10fed9..e1b5aee 100644 --- a/cc/resources/ui_resource_bitmap.h +++ b/cc/resources/ui_resource_bitmap.h @@ -8,20 +8,16 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "cc/base/cc_export.h" -#include "skia/ext/refptr.h" -#include "third_party/skia/include/core/SkPixelRef.h" #include "third_party/skia/include/core/SkTypes.h" #include "ui/gfx/size.h" -class SkBitmap; - namespace cc { -// A bitmap class that contains a ref-counted reference to a SkPixelRef* that -// holds the content of the bitmap (cannot use SkBitmap because of ETC1). -// Thread-safety (by ways of SkPixelRef) ensures that both main and impl threads -// can hold references to the bitmap and that asynchronous uploads are allowed. -class CC_EXPORT UIResourceBitmap { +// Ref-counted bitmap class (can’t use SkBitmap because of ETC1). Thread-safety +// ensures that both main and impl threads can hold references to the bitmap and +// that asynchronous uploads are allowed. +class CC_EXPORT UIResourceBitmap + : public base::RefCountedThreadSafe<UIResourceBitmap> { public: enum UIResourceFormat { RGBA8 @@ -31,29 +27,29 @@ class CC_EXPORT UIResourceBitmap { REPEAT }; + // Takes ownership of “pixels”. + static scoped_refptr<UIResourceBitmap> Create(uint8_t* pixels, + UIResourceFormat format, + UIResourceWrapMode wrap_mode, + gfx::Size size); + gfx::Size GetSize() const { return size_; } UIResourceFormat GetFormat() const { return format_; } UIResourceWrapMode GetWrapMode() const { return wrap_mode_; } - uint8_t* GetPixels() const; + uint8_t* GetPixels() { return pixels_.get(); } - // The constructor for the UIResourceBitmap. User must ensure that |skbitmap| - // is immutable. The SkBitmap format should be in 32-bit RGBA. Wrap mode is - // unnecessary for most UI resources and is defaulted to CLAMP_TO_EDGE. - UIResourceBitmap(const SkBitmap& skbitmap, - UIResourceWrapMode wrap_mode = CLAMP_TO_EDGE); + private: + friend class base::RefCountedThreadSafe<UIResourceBitmap>; + UIResourceBitmap(); ~UIResourceBitmap(); - private: - void Create(const skia::RefPtr<SkPixelRef>& pixel_ref, - UIResourceFormat format, - UIResourceWrapMode wrap_mode, - gfx::Size size); - - skia::RefPtr<SkPixelRef> pixel_ref_; + scoped_ptr<uint8_t[]> pixels_; UIResourceFormat format_; UIResourceWrapMode wrap_mode_; gfx::Size size_; + + DISALLOW_COPY_AND_ASSIGN(UIResourceBitmap); }; } // namespace cc diff --git a/cc/resources/ui_resource_client.h b/cc/resources/ui_resource_client.h index 24309a5..d647936 100644 --- a/cc/resources/ui_resource_client.h +++ b/cc/resources/ui_resource_client.h @@ -24,8 +24,8 @@ class CC_EXPORT UIResourceClient { // delete a UIResourceClient object after DeleteUIResource has been called for // all IDs associated with it. A valid bitmap always must be returned but it // doesn't need to be the same size or format as the original. - virtual UIResourceBitmap GetBitmap(UIResourceId uid, - bool resource_lost) = 0; + virtual scoped_refptr<UIResourceBitmap> GetBitmap(UIResourceId uid, + bool resource_lost) = 0; virtual ~UIResourceClient() {} }; |