blob: 6b3eacf17c9baeba7c6c3d42a8906b3cffa29d03 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cc/blink/web_nine_patch_layer_impl.h"
#include "base/command_line.h"
#include "cc/base/switches.h"
#include "cc/blink/web_layer_impl.h"
#include "cc/blink/web_layer_impl_fixed_bounds.h"
#include "cc/layers/nine_patch_layer.h"
#include "cc/layers/picture_image_layer.h"
namespace cc_blink {
WebNinePatchLayerImpl::WebNinePatchLayerImpl() {
layer_.reset(new WebLayerImpl(cc::NinePatchLayer::Create()));
}
WebNinePatchLayerImpl::~WebNinePatchLayerImpl() {
}
blink::WebLayer* WebNinePatchLayerImpl::layer() {
return layer_.get();
}
void WebNinePatchLayerImpl::setBitmap(SkBitmap bitmap,
const blink::WebRect& aperture) {
setBitmap(bitmap);
setAperture(aperture);
setBorder(blink::WebRect(aperture.x,
aperture.y,
bitmap.width() - aperture.width,
bitmap.height() - aperture.height));
}
void WebNinePatchLayerImpl::setBitmap(SkBitmap bitmap) {
cc::NinePatchLayer* nine_patch =
static_cast<cc::NinePatchLayer*>(layer_->layer());
nine_patch->SetBitmap(bitmap);
}
void WebNinePatchLayerImpl::setAperture(const blink::WebRect& aperture) {
cc::NinePatchLayer* nine_patch =
static_cast<cc::NinePatchLayer*>(layer_->layer());
nine_patch->SetAperture(gfx::Rect(aperture));
}
void WebNinePatchLayerImpl::setBorder(const blink::WebRect& border) {
cc::NinePatchLayer* nine_patch =
static_cast<cc::NinePatchLayer*>(layer_->layer());
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
|