• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 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.
4 
5 #include "webkit/renderer/compositor_bindings/web_nine_patch_layer_impl.h"
6 
7 #include "base/command_line.h"
8 #include "cc/base/switches.h"
9 #include "cc/layers/nine_patch_layer.h"
10 #include "cc/layers/picture_image_layer.h"
11 #include "webkit/renderer/compositor_bindings/web_layer_impl.h"
12 #include "webkit/renderer/compositor_bindings/web_layer_impl_fixed_bounds.h"
13 
14 namespace webkit {
15 
WebNinePatchLayerImpl()16 WebNinePatchLayerImpl::WebNinePatchLayerImpl() {
17   layer_.reset(new WebLayerImpl(cc::NinePatchLayer::Create()));
18 }
19 
~WebNinePatchLayerImpl()20 WebNinePatchLayerImpl::~WebNinePatchLayerImpl() {}
21 
layer()22 blink::WebLayer* WebNinePatchLayerImpl::layer() { return layer_.get(); }
23 
setBitmap(SkBitmap bitmap,const blink::WebRect & aperture)24 void WebNinePatchLayerImpl::setBitmap(SkBitmap bitmap,
25                                       const blink::WebRect& aperture) {
26   setBitmap(bitmap);
27   setAperture(aperture);
28   setBorder(blink::WebRect(aperture.x, aperture.y,
29                             bitmap.width() - aperture.width,
30                             bitmap.height() - aperture.height));
31 }
32 
setBitmap(SkBitmap bitmap)33 void WebNinePatchLayerImpl::setBitmap(SkBitmap bitmap) {
34   cc::NinePatchLayer* nine_patch =
35       static_cast<cc::NinePatchLayer*>(layer_->layer());
36   nine_patch->SetBitmap(bitmap);
37 }
38 
setAperture(const blink::WebRect & aperture)39 void WebNinePatchLayerImpl::setAperture(const blink::WebRect& aperture) {
40   cc::NinePatchLayer* nine_patch =
41       static_cast<cc::NinePatchLayer*>(layer_->layer());
42   nine_patch->SetAperture(gfx::Rect(aperture));
43 }
44 
setBorder(const blink::WebRect & border)45 void WebNinePatchLayerImpl::setBorder(const blink::WebRect& border) {
46   cc::NinePatchLayer* nine_patch =
47       static_cast<cc::NinePatchLayer*>(layer_->layer());
48   nine_patch->SetBorder(gfx::Rect(border));
49 }
50 
setFillCenter(bool fill_center)51 void WebNinePatchLayerImpl::setFillCenter(bool fill_center) {
52   cc::NinePatchLayer* nine_patch =
53       static_cast<cc::NinePatchLayer*>(layer_->layer());
54   nine_patch->SetFillCenter(fill_center);
55 }
56 
57 }  // namespace webkit
58