diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-08 02:42:05 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-08 02:42:05 +0000 |
commit | bbb1a2b806226fcadfc8fa648f33f32b98a11085 (patch) | |
tree | 567b0c837fa074f20bb24a5ced6ae2624c97da3e | |
parent | be3925eecc44210e61b47de19858d45c28b3e361 (diff) | |
download | chromium_src-bbb1a2b806226fcadfc8fa648f33f32b98a11085.zip chromium_src-bbb1a2b806226fcadfc8fa648f33f32b98a11085.tar.gz chromium_src-bbb1a2b806226fcadfc8fa648f33f32b98a11085.tar.bz2 |
cc: Chromify the ImageLayer class.
Style-only change. Make the ImageLayer class use chromium style.
R=jamesr
NOTRY=true
Review URL: https://chromiumcodereview.appspot.com/12631009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186865 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | cc/image_layer.cc | 125 | ||||
-rw-r--r-- | cc/image_layer.h | 58 | ||||
-rw-r--r-- | webkit/compositor_bindings/web_image_layer_impl.cc | 4 |
3 files changed, 87 insertions, 100 deletions
diff --git a/cc/image_layer.cc b/cc/image_layer.cc index 06f10ac..aaef6be 100644 --- a/cc/image_layer.cc +++ b/cc/image_layer.cc @@ -13,97 +13,84 @@ namespace cc { -scoped_refptr<ImageLayer> ImageLayer::create() -{ - return make_scoped_refptr(new ImageLayer()); +scoped_refptr<ImageLayer> ImageLayer::Create() { + return make_scoped_refptr(new ImageLayer()); } -ImageLayer::ImageLayer() - : TiledLayer() -{ -} +ImageLayer::ImageLayer() : TiledLayer() {} -ImageLayer::~ImageLayer() -{ -} +ImageLayer::~ImageLayer() {} + +void ImageLayer::SetBitmap(const SkBitmap& bitmap) { + // SetBitmap() currently gets called whenever there is any + // style change that affects the layer even if that change doesn't + // affect the actual contents of the image (e.g. a CSS animation). + // With this check in place we avoid unecessary texture uploads. + if (bitmap.pixelRef() && bitmap.pixelRef() == bitmap_.pixelRef()) + return; -void ImageLayer::setBitmap(const SkBitmap& bitmap) -{ - // setBitmap() currently gets called whenever there is any - // style change that affects the layer even if that change doesn't - // affect the actual contents of the image (e.g. a CSS animation). - // With this check in place we avoid unecessary texture uploads. - if (bitmap.pixelRef() && bitmap.pixelRef() == m_bitmap.pixelRef()) - return; - - m_bitmap = bitmap; - setNeedsDisplay(); + bitmap_ = bitmap; + setNeedsDisplay(); } -void ImageLayer::setTexturePriorities(const PriorityCalculator& priorityCalc) -{ - // Update the tile data before creating all the layer's tiles. - updateTileSizeAndTilingOption(); +void ImageLayer::setTexturePriorities(const PriorityCalculator& priority_calc) { + // Update the tile data before creating all the layer's tiles. + updateTileSizeAndTilingOption(); - TiledLayer::setTexturePriorities(priorityCalc); + TiledLayer::setTexturePriorities(priority_calc); } -void ImageLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats* stats) -{ - createUpdaterIfNeeded(); - if (m_needsDisplay) { - m_updater->setBitmap(m_bitmap); - updateTileSizeAndTilingOption(); - invalidateContentRect(gfx::Rect(gfx::Point(), contentBounds())); - m_needsDisplay = false; - } - TiledLayer::update(queue, occlusion, stats); +void ImageLayer::update(ResourceUpdateQueue& queue, + const OcclusionTracker* occlusion, + RenderingStats* stats) { + createUpdaterIfNeeded(); + if (m_needsDisplay) { + updater_->setBitmap(bitmap_); + updateTileSizeAndTilingOption(); + invalidateContentRect(gfx::Rect(gfx::Point(), contentBounds())); + m_needsDisplay = false; + } + TiledLayer::update(queue, occlusion, stats); } -void ImageLayer::createUpdaterIfNeeded() -{ - if (m_updater) - return; +void ImageLayer::createUpdaterIfNeeded() { + if (updater_) + return; - m_updater = ImageLayerUpdater::create(); - GLenum textureFormat = layerTreeHost()->rendererCapabilities().bestTextureFormat; - setTextureFormat(textureFormat); + updater_ = ImageLayerUpdater::create(); + GLenum texture_format = + layerTreeHost()->rendererCapabilities().bestTextureFormat; + setTextureFormat(texture_format); } -LayerUpdater* ImageLayer::updater() const -{ - return m_updater.get(); +LayerUpdater* ImageLayer::updater() const { + return updater_.get(); } -void ImageLayer::calculateContentsScale( - float ideal_contents_scale, - bool animating_transform_to_screen, - float* contentsScaleX, - float* contentsScaleY, - gfx::Size* contentBounds) -{ - *contentsScaleX = imageContentsScaleX(); - *contentsScaleY = imageContentsScaleY(); - *contentBounds = gfx::Size(m_bitmap.width(), m_bitmap.height()); +void ImageLayer::calculateContentsScale(float ideal_contents_scale, + bool animating_transform_to_screen, + float* contents_scale_x, + float* contents_scale_y, + gfx::Size* contentBounds) { + *contents_scale_x = ImageContentsScaleX(); + *contents_scale_y = ImageContentsScaleY(); + *contentBounds = gfx::Size(bitmap_.width(), bitmap_.height()); } -bool ImageLayer::drawsContent() const -{ - return !m_bitmap.isNull() && TiledLayer::drawsContent(); +bool ImageLayer::drawsContent() const { + return !bitmap_.isNull() && TiledLayer::drawsContent(); } -float ImageLayer::imageContentsScaleX() const -{ - if (bounds().IsEmpty() || m_bitmap.width() == 0) - return 1; - return static_cast<float>(m_bitmap.width()) / bounds().width(); +float ImageLayer::ImageContentsScaleX() const { + if (bounds().IsEmpty() || bitmap_.width() == 0) + return 1; + return static_cast<float>(bitmap_.width()) / bounds().width(); } -float ImageLayer::imageContentsScaleY() const -{ - if (bounds().IsEmpty() || m_bitmap.height() == 0) - return 1; - return static_cast<float>(m_bitmap.height()) / bounds().height(); +float ImageLayer::ImageContentsScaleY() const { + if (bounds().IsEmpty() || bitmap_.height() == 0) + return 1; + return static_cast<float>(bitmap_.height()) / bounds().height(); } } // namespace cc diff --git a/cc/image_layer.h b/cc/image_layer.h index 7b70fcd..cb451e2 100644 --- a/cc/image_layer.h +++ b/cc/image_layer.h @@ -15,35 +15,35 @@ class ImageLayerUpdater; // A Layer that contains only an Image element. class CC_EXPORT ImageLayer : public TiledLayer { -public: - static scoped_refptr<ImageLayer> create(); - - virtual bool drawsContent() const OVERRIDE; - virtual void setTexturePriorities(const PriorityCalculator&) OVERRIDE; - virtual void update(ResourceUpdateQueue&, const OcclusionTracker*, RenderingStats*) OVERRIDE; - virtual void calculateContentsScale( - float idealContentsScale, - bool animating_transform_to_screen, - float* contentsScaleX, - float* contentsScaleY, - gfx::Size* contentBounds) OVERRIDE; - - void setBitmap(const SkBitmap& image); - -private: - ImageLayer(); - virtual ~ImageLayer(); - - void setTilingOption(TilingOption); - - virtual LayerUpdater* updater() const OVERRIDE; - virtual void createUpdaterIfNeeded() OVERRIDE; - float imageContentsScaleX() const; - float imageContentsScaleY() const; - - SkBitmap m_bitmap; - - scoped_refptr<ImageLayerUpdater> m_updater; + public: + static scoped_refptr<ImageLayer> Create(); + + virtual bool drawsContent() const OVERRIDE; + virtual void setTexturePriorities(const PriorityCalculator& priority_calc) + OVERRIDE; + virtual void update(ResourceUpdateQueue& queue, + const OcclusionTracker* occlusion, + RenderingStats* stats) OVERRIDE; + virtual void calculateContentsScale(float ideal_contents_scale, + bool animating_transform_to_screen, + float* contents_scale_x, + float* contents_scale_y, + gfx::Size* contentBounds) OVERRIDE; + + void SetBitmap(const SkBitmap& image); + + private: + ImageLayer(); + virtual ~ImageLayer(); + + virtual LayerUpdater* updater() const OVERRIDE; + virtual void createUpdaterIfNeeded() OVERRIDE; + float ImageContentsScaleX() const; + float ImageContentsScaleY() const; + + SkBitmap bitmap_; + + scoped_refptr<ImageLayerUpdater> updater_; }; } // namespace cc diff --git a/webkit/compositor_bindings/web_image_layer_impl.cc b/webkit/compositor_bindings/web_image_layer_impl.cc index e9af9ba..af307a0 100644 --- a/webkit/compositor_bindings/web_image_layer_impl.cc +++ b/webkit/compositor_bindings/web_image_layer_impl.cc @@ -21,7 +21,7 @@ WebImageLayerImpl::WebImageLayerImpl() { if (usingPictureLayer()) layer_.reset(new WebLayerImplFixedBounds(cc::PictureImageLayer::create())); else - layer_.reset(new WebLayerImpl(cc::ImageLayer::create())); + layer_.reset(new WebLayerImpl(cc::ImageLayer::Create())); } WebImageLayerImpl::~WebImageLayerImpl() {} @@ -33,7 +33,7 @@ void WebImageLayerImpl::setBitmap(SkBitmap bitmap) { static_cast<cc::PictureImageLayer*>(layer_->layer())->setBitmap(bitmap); static_cast<WebLayerImplFixedBounds*>(layer_.get())->SetFixedBounds(gfx::Size(bitmap.width(), bitmap.height())); } else - static_cast<cc::ImageLayer*>(layer_->layer())->setBitmap(bitmap); + static_cast<cc::ImageLayer*>(layer_->layer())->SetBitmap(bitmap); } } // namespace WebKit |