mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Merge pull request #1069 from vlidholt/master
Adds bindings for ImageShader to SkShader::CreateBitmapShader
This commit is contained in:
commit
d60244d4ee
@ -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",
|
||||
|
||||
36
sky/engine/core/painting/ImageShader.cpp
Normal file
36
sky/engine/core/painting/ImageShader.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
// 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
|
||||
20
sky/engine/core/painting/ImageShader.dart
Normal file
20
sky/engine/core/painting/ImageShader.dart
Normal file
@ -0,0 +1,20 @@
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
38
sky/engine/core/painting/ImageShader.h
Normal file
38
sky/engine/core/painting/ImageShader.h
Normal file
@ -0,0 +1,38 @@
|
||||
// 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_
|
||||
10
sky/engine/core/painting/ImageShader.idl
Normal file
10
sky/engine/core/painting/ImageShader.idl
Normal file
@ -0,0 +1,10 @@
|
||||
// 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);
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user