Wrap ImageShader::sk_image_ with a SkiaGPUObject (flutter/engine#28698)
This commit is contained in:
@@ -45,7 +45,7 @@ void ImageShader::initWithImage(CanvasImage* image,
|
||||
ToDart("ImageShader constructor called with non-genuine Image."));
|
||||
return;
|
||||
}
|
||||
sk_image_ = image->image();
|
||||
sk_image_ = UIDartState::CreateGPUObject(image->image());
|
||||
tmx_ = tmx;
|
||||
tmy_ = tmy;
|
||||
local_matrix_ = ToSkMatrix(matrix4);
|
||||
@@ -63,8 +63,9 @@ sk_sp<SkShader> ImageShader::shader(SkSamplingOptions sampling) {
|
||||
}
|
||||
if (!cached_shader_.skia_object() || cached_sampling_ != sampling) {
|
||||
cached_sampling_ = sampling;
|
||||
cached_shader_ = UIDartState::CreateGPUObject(
|
||||
sk_image_->makeShader(tmx_, tmy_, sampling, &local_matrix_));
|
||||
cached_shader_ =
|
||||
UIDartState::CreateGPUObject(sk_image_.skia_object()->makeShader(
|
||||
tmx_, tmy_, sampling, &local_matrix_));
|
||||
}
|
||||
return cached_shader_.skia_object();
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ class ImageShader : public Shader {
|
||||
private:
|
||||
ImageShader();
|
||||
|
||||
sk_sp<SkImage> sk_image_;
|
||||
flutter::SkiaGPUObject<SkImage> sk_image_;
|
||||
SkTileMode tmx_;
|
||||
SkTileMode tmy_;
|
||||
SkMatrix local_matrix_;
|
||||
|
||||
@@ -23,6 +23,7 @@ tests = [
|
||||
"image_dispose_test.dart",
|
||||
"image_filter_test.dart",
|
||||
"image_resize_test.dart",
|
||||
"image_shader_test.dart",
|
||||
"isolate_name_server_test.dart",
|
||||
"isolate_test.dart",
|
||||
"lerp_test.dart",
|
||||
|
||||
20
engine/src/flutter/testing/dart/image_shader_test.dart
Normal file
20
engine/src/flutter/testing/dart/image_shader_test.dart
Normal file
@@ -0,0 +1,20 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:typed_data';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:litetest/litetest.dart';
|
||||
import 'canvas_test.dart' show createImage, testCanvas;
|
||||
|
||||
void main() {
|
||||
test('Construct an ImageShader', () async {
|
||||
final Image image = await createImage(50, 50);
|
||||
final ImageShader shader = ImageShader(image, TileMode.clamp, TileMode.clamp, Float64List(16));
|
||||
final Paint paint = Paint()..shader=shader;
|
||||
final Rect rect = Rect.fromLTRB(0, 0, 100, 100);
|
||||
testCanvas((Canvas canvas) => canvas.drawRect(rect, paint));
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user