OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/blink/web_image_layer_impl.h" | 5 #include "cc/blink/web_image_layer_impl.h" |
6 | 6 |
7 #include "cc/blink/web_layer_impl.h" | 7 #include "cc/blink/web_layer_impl.h" |
8 #include "cc/blink/web_layer_impl_fixed_bounds.h" | 8 #include "cc/blink/web_layer_impl_fixed_bounds.h" |
9 #include "cc/layers/image_layer.h" | 9 #include "cc/layers/image_layer.h" |
10 #include "cc/layers/picture_image_layer.h" | 10 #include "cc/layers/picture_image_layer.h" |
11 | 11 |
12 namespace cc_blink { | 12 namespace cc_blink { |
13 | 13 |
14 WebImageLayerImpl::WebImageLayerImpl() { | 14 WebImageLayerImpl::WebImageLayerImpl() { |
15 if (WebLayerImpl::UsingPictureLayer()) | 15 layer_.reset(new WebLayerImplFixedBounds( |
16 layer_.reset(new WebLayerImplFixedBounds( | 16 cc::PictureImageLayer::Create(WebLayerImpl::LayerSettings()))); |
17 cc::PictureImageLayer::Create(WebLayerImpl::LayerSettings()))); | |
18 else | |
19 layer_.reset(new WebLayerImpl( | |
20 cc::ImageLayer::Create(WebLayerImpl::LayerSettings()))); | |
21 } | 17 } |
22 | 18 |
23 WebImageLayerImpl::~WebImageLayerImpl() { | 19 WebImageLayerImpl::~WebImageLayerImpl() { |
24 } | 20 } |
25 | 21 |
26 blink::WebLayer* WebImageLayerImpl::layer() { | 22 blink::WebLayer* WebImageLayerImpl::layer() { |
27 return layer_.get(); | 23 return layer_.get(); |
28 } | 24 } |
29 | 25 |
30 void WebImageLayerImpl::setImageBitmap(const SkBitmap& bitmap) { | 26 void WebImageLayerImpl::setImageBitmap(const SkBitmap& bitmap) { |
31 if (WebLayerImpl::UsingPictureLayer()) { | 27 static_cast<cc::PictureImageLayer*>(layer_->layer())->SetBitmap(bitmap); |
32 static_cast<cc::PictureImageLayer*>(layer_->layer())->SetBitmap(bitmap); | 28 static_cast<WebLayerImplFixedBounds*>(layer_.get()) |
33 static_cast<WebLayerImplFixedBounds*>(layer_.get()) | 29 ->SetFixedBounds(gfx::Size(bitmap.width(), bitmap.height())); |
34 ->SetFixedBounds(gfx::Size(bitmap.width(), bitmap.height())); | |
35 } else { | |
36 static_cast<cc::ImageLayer*>(layer_->layer())->SetBitmap(bitmap); | |
37 } | |
38 } | 30 } |
39 | 31 |
40 void WebImageLayerImpl::setNearestNeighbor(bool nearest_neighbor) { | 32 void WebImageLayerImpl::setNearestNeighbor(bool nearest_neighbor) { |
41 if (WebLayerImpl::UsingPictureLayer()) { | 33 static_cast<cc::PictureImageLayer*>(layer_->layer()) |
42 static_cast<cc::PictureImageLayer*>(layer_->layer()) | 34 ->SetNearestNeighbor(nearest_neighbor); |
43 ->SetNearestNeighbor(nearest_neighbor); | |
44 } | |
45 } | 35 } |
46 | 36 |
47 } // namespace cc_blink | 37 } // namespace cc_blink |
OLD | NEW |