提交 baabf090 编写于 作者: V Viktor Lidholt

Adds bindings for ImageShader to SkShader::CreateBitmapShader

上级 9aa71b4d
......@@ -408,6 +408,8 @@ sky_core_files = [
"painting/DrawLooperLayerInfo.cpp",
"painting/DrawLooperLayerInfo.h",
"painting/FilterQuality.h",
"painting/ImageShader.cpp",
"painting/ImageShader.h",
"painting/LayerDrawLooperBuilder.cpp",
"painting/LayerDrawLooperBuilder.h",
"painting/LayoutRoot.cpp",
......@@ -649,6 +651,7 @@ core_idl_files = get_path_info([
"painting/DrawLooperLayerInfo.idl",
"painting/Gradient.idl",
"painting/Image.idl",
"painting/ImageShader.idl",
"painting/LayerDrawLooperBuilder.idl",
"painting/LayoutRoot.idl",
"painting/MaskFilter.idl",
......@@ -673,6 +676,7 @@ core_dart_files = get_path_info([
"painting/DrawLooperLayerInfo.dart",
"painting/FilterQuality.dart",
"painting/Gradient.dart",
"painting/ImageShader.dart",
"painting/MaskFilter.dart",
"painting/Offset.dart",
"painting/OffsetBase.dart",
......
// Copyright 2015 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 "sky/engine/core/painting/ImageShader.h"
namespace blink {
PassRefPtr<ImageShader> ImageShader::create() {
return adoptRef(new ImageShader());
}
void ImageShader::initWithImage(CanvasImage* image,
SkShader::TileMode tmx,
SkShader::TileMode tmy,
const Float32List& matrix4,
ExceptionState& es) {
ASSERT(image != NULL);
SkMatrix sk_matrix = toSkMatrix(matrix4, es);
if (es.had_exception())
return;
SkBitmap bitmap;
image->image()->asLegacyBitmap(&bitmap, SkImage::kRO_LegacyBitmapMode);
set_shader(adoptRef(SkShader::CreateBitmapShader(bitmap, tmx, tmy, &sk_matrix)));
}
ImageShader::ImageShader() : Shader(nullptr) {
}
ImageShader::~ImageShader() {
}
} // namespace blink
// Copyright 2015 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.
part of dart.sky;
class ImageShader extends _ImageShader {
ImageShader(Image image, TileMode tmx, TileMode tmy, Float32List matrix4) {
if (image == null)
throw new ArgumentError("[image] argument cannot be null");
if (tmx == null)
throw new ArgumentError("[tmx] argument cannot be null");
if (tmy == null)
throw new ArgumentError("[tmy] argument cannot be null");
if (matrix4 == null)
throw new ArgumentError("[matrix4] argument cannot be null");
this._initWithImage(image, tmx, tmy, matrix4);
}
}
// Copyright 2015 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.
#ifndef SKY_ENGINE_CORE_PAINTING_IMAGESHADER_H_
#define SKY_ENGINE_CORE_PAINTING_IMAGESHADER_H_
#include "sky/engine/bindings/exception_state.h"
#include "sky/engine/core/painting/CanvasGradient.h"
#include "sky/engine/core/painting/CanvasImage.h"
#include "sky/engine/core/painting/Shader.h"
#include "sky/engine/tonic/dart_wrappable.h"
#include "sky/engine/core/painting/Matrix.h"
#include "sky/engine/tonic/float32_list.h"
#include "third_party/skia/include/core/SkShader.h"
#include "third_party/skia/include/core/SkMatrix.h"
namespace blink {
class ImageShader : public Shader {
DEFINE_WRAPPERTYPEINFO();
public:
~ImageShader() override;
static PassRefPtr<ImageShader> create();
void initWithImage(CanvasImage* image,
SkShader::TileMode tmx,
SkShader::TileMode tmy,
const Float32List& matrix4,
ExceptionState& es);
private:
ImageShader();
};
} // namespace blink
#endif // SKY_ENGINE_CORE_PAINTING_IMAGESHADER_H_
// Copyright 2015 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.
[
PrivateDart,
Constructor()
] interface ImageShader : Shader {
[RaisesException] void initWithImage(Image image, TileMode tmx, TileMode tmy, Float32List matrix4);
};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册