Commit f814f45c authored by vivek.vg's avatar vivek.vg Committed by Commit bot

[chromium] Pass SkBitmap by reference in WebNinePatchLayer::setBitmap and refactor

Although passing SkBitmap by value doesn't copy the underlying pixels, it indeed
involves memcpy (~64 bytes to be precise) to replicate the settings from the
other bitmap in the copy constructor.

This overhead, albeit minor, can be avoided by passing SkBitmap as reference.

R=jamesr@chromium.org

Review URL: https://codereview.chromium.org/597553002

Cr-Commit-Position: refs/heads/master@{#296330}
parent 376e975a
...@@ -34,7 +34,7 @@ void WebNinePatchLayerImpl::setBitmap(SkBitmap bitmap, ...@@ -34,7 +34,7 @@ void WebNinePatchLayerImpl::setBitmap(SkBitmap bitmap,
bitmap.height() - aperture.height)); bitmap.height() - aperture.height));
} }
void WebNinePatchLayerImpl::setBitmap(SkBitmap bitmap) { void WebNinePatchLayerImpl::setBitmap(const SkBitmap& bitmap) {
cc::NinePatchLayer* nine_patch = cc::NinePatchLayer* nine_patch =
static_cast<cc::NinePatchLayer*>(layer_->layer()); static_cast<cc::NinePatchLayer*>(layer_->layer());
nine_patch->SetBitmap(bitmap); nine_patch->SetBitmap(bitmap);
...@@ -52,10 +52,4 @@ void WebNinePatchLayerImpl::setBorder(const blink::WebRect& border) { ...@@ -52,10 +52,4 @@ void WebNinePatchLayerImpl::setBorder(const blink::WebRect& border) {
nine_patch->SetBorder(gfx::Rect(border)); nine_patch->SetBorder(gfx::Rect(border));
} }
void WebNinePatchLayerImpl::setFillCenter(bool fill_center) {
cc::NinePatchLayer* nine_patch =
static_cast<cc::NinePatchLayer*>(layer_->layer());
nine_patch->SetFillCenter(fill_center);
}
} // namespace cc_blink } // namespace cc_blink
...@@ -22,13 +22,12 @@ class WebNinePatchLayerImpl : public blink::WebNinePatchLayer { ...@@ -22,13 +22,12 @@ class WebNinePatchLayerImpl : public blink::WebNinePatchLayer {
// blink::WebNinePatchLayer implementation. // blink::WebNinePatchLayer implementation.
virtual blink::WebLayer* layer(); virtual blink::WebLayer* layer();
// TODO(ccameron): Remove setBitmap(SkBitmap, blink::WebRect) in favor of // TODO(vivekg): Remove setBitmap(SkBitmap, blink::WebRect) once blink side
// setBitmap(), setAperture(), and setBorder(); // CL, http://crrev.com/594193002 lands
virtual void setBitmap(SkBitmap bitmap, const blink::WebRect& aperture); virtual void setBitmap(SkBitmap bitmap, const blink::WebRect& aperture);
virtual void setBitmap(SkBitmap bitmap); virtual void setBitmap(const SkBitmap& bitmap);
virtual void setAperture(const blink::WebRect& aperture); virtual void setAperture(const blink::WebRect& aperture);
virtual void setBorder(const blink::WebRect& border); virtual void setBorder(const blink::WebRect& border);
virtual void setFillCenter(bool fill_center);
private: private:
scoped_ptr<WebLayerImpl> layer_; scoped_ptr<WebLayerImpl> layer_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment