forked from google/skia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove Ganesh and Graphite code from SkImage::subset
This makes both implementations more consistent and easier to decouple if there is no GPU backend compiled in. Graphite images are no longer uploaded as a texture-backed image if a recorder is passed in and Lazy images are turned into a raster image before being subset (instead of a texture-backed image). In practice, this should only impact skp images (which were further cleaned up in [1]). In some cases, we want to be able to directly create a texture- based subset, so a new static function does that SkImages::SubsetTextureFrom. This currently has a trivial implementation, but we might do something smarter, especially with larger textures. [1] https://skia-review.googlesource.com/c/skia/+/678656 Change-Id: I28f06a96fa451272c77a5fd06e97b2a4ad5b77b3 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/671679 Commit-Queue: Kevin Lubick <[email protected]> Reviewed-by: Brian Osman <[email protected]>
- Loading branch information
Showing
42 changed files
with
318 additions
and
167 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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,42 @@ | ||
/* | ||
* Copyright 2023 Google LLC | ||
* | ||
* Use of this source code is governed by a BSD-style license that can be | ||
* found in the LICENSE file. | ||
*/ | ||
|
||
#ifndef skgpu_graphite_Image_DEFINED | ||
#define skgpu_graphite_Image_DEFINED | ||
|
||
#include "include/core/SkImage.h" | ||
#include "include/core/SkRefCnt.h" | ||
|
||
struct SkIRect; | ||
|
||
namespace skgpu::graphite { | ||
class Recorder; | ||
} | ||
|
||
namespace SkImages { | ||
/** Returns subset of this image as a texture-backed image. | ||
Returns nullptr if any of the following are true: | ||
- Subset is empty | ||
- Subset is not contained inside the image's bounds | ||
- Pixels in the source image could not be read or copied | ||
- The source image is texture-backed and context does not match the source image's context. | ||
@param recorder the non-null recorder in which to create the new image. | ||
@param img Source image | ||
@param subset bounds of returned SkImage | ||
@param props properties the returned SkImage must possess (e.g. mipmaps) | ||
@return the subsetted image, uploaded as a texture, or nullptr | ||
*/ | ||
SK_API sk_sp<SkImage> SubsetTextureFrom(skgpu::graphite::Recorder* recorder, | ||
const SkImage* img, | ||
const SkIRect& subset, | ||
SkImage::RequiredImageProperties props = {}); | ||
} // namespace SkImages | ||
|
||
|
||
#endif // skgpu_graphite_Image_DEFINED |
This file contains 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,14 @@ | ||
`SkImage::subset` now takes a `GrDirectContext*` as its first parameter (this can be `nullptr` for | ||
non-gpu backed images. Images which are backed by a codec or picture will not be turned into a GPU | ||
texture before being read. This should only impact picture-backed images, which may not be read | ||
correctly if the picture contain nested texture-backed images itself. To force a conversion to | ||
a texture, clients should call `SkImages::TextureFromImage`, passing in the image, and then call | ||
subset on the result. Documentation has been clarified that `SkImage::subset` will return a raster- | ||
backed image if the source is not backed by a texture, and texture-otherwise. | ||
|
||
`SkImages::SubsetTextureFrom` has been added to subset an image and explicitly return a texture- | ||
backed image. This allows some optimizations, especially for large images that exceed a maximum | ||
texture size of a GPU. | ||
|
||
`SkImage::makeRasterImage` and `SkImage::makeNonTextureImage` now take a `GrDirectContext*` which | ||
clients should supply for reading-back pixels from texture-backed images. |
This file contains 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
Oops, something went wrong.