This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Picture shader #8835
Closed
Closed
Picture shader #8835
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1318,6 +1318,7 @@ class Paint { | |
/// | ||
/// * [Gradient], a shader that paints a color gradient. | ||
/// * [ImageShader], a shader that tiles an [Image]. | ||
/// * [PictureShader], a shader that tiles a [Picture]. | ||
/// * [colorFilter], which overrides [shader]. | ||
/// * [color], which is used if [shader] and [colorFilter] are null. | ||
Shader get shader { | ||
|
@@ -2669,6 +2670,13 @@ class ImageShader extends Shader { | |
super._(); | ||
} | ||
|
||
/// A shader (as used by [Paint.shader]) that tiles a picture. | ||
class PictureShader extends Shader { | ||
/// This class is created by the engine, and should not be instantiated | ||
/// or extended directly. | ||
PictureShader._() : super._(); | ||
} | ||
|
||
/// Defines how a list of points is interpreted when drawing a set of triangles. | ||
/// | ||
/// Used by [Canvas.drawVertices]. | ||
|
@@ -3312,6 +3320,15 @@ class Picture { | |
Future<Image> toImage(int width, int height) { | ||
throw UnimplementedError(); | ||
} | ||
|
||
/// Creates a picture shader from this picture. | ||
/// | ||
/// The shader is returned asynchronously to allow time for the gpu to | ||
/// draw the picture and compile a shader. | ||
Future<PictureShader> toShader(TileMode tmx, TileMode tmy, Float64List matrix4) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In general we prefer to avoid abbreviations, so In https://master-api.flutter.dev/flutter/painting/paintImage.html we use |
||
throw UnimplementedError(); | ||
} | ||
|
||
/// Release the resources used by this object. The object is no longer usable | ||
/// after this method is called. | ||
void dispose() { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// 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. | ||
|
||
#include "flutter/lib/ui/painting/picture_shader.h" | ||
|
||
namespace flutter { | ||
|
||
IMPLEMENT_WRAPPERTYPEINFO(ui, PictureShader); | ||
|
||
fml::RefPtr<PictureShader> PictureShader::Create() { | ||
return fml::MakeRefCounted<PictureShader>(); | ||
} | ||
|
||
PictureShader::PictureShader() = default; | ||
|
||
PictureShader::~PictureShader() = default; | ||
|
||
} // namespace flutter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// 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. | ||
|
||
#ifndef FLUTTER_LIB_UI_PAINTING_PICTURE_SHADER_H_ | ||
#define FLUTTER_LIB_UI_PAINTING_PICTURE_SHADER_H_ | ||
|
||
#include "flutter/lib/ui/dart_wrapper.h" | ||
#include "flutter/lib/ui/painting/shader.h" | ||
|
||
namespace flutter { | ||
|
||
class PictureShader : public Shader { | ||
DEFINE_WRAPPERTYPEINFO(); | ||
FML_FRIEND_MAKE_REF_COUNTED(PictureShader); | ||
|
||
public: | ||
~PictureShader() override; | ||
static fml::RefPtr<PictureShader> Create(); | ||
|
||
private: | ||
PictureShader(); | ||
}; | ||
|
||
} // namespace flutter | ||
|
||
#endif // FLUTTER_LIB_UI_PAINTING_PICTURE_SHADER_H_ |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide additional documentation, e.g. sample code (see https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#provide-sample-code).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(notably, how to create a PictureShader should be documented here, as well as how to use it)