Return image address in image info so it can be shown in dropdown.

Note that I don't dereference this pointer, I'm just showing it to the user as it is currently
the only common identifier between the command list and the resource tab.

A longer term fix would be to show the resourse tab's indices in the command list. this is tougher
because it involves replacing UrlDataManager without breaking skiaserve.

Change-Id: Iaa0d60831e96128f19b6358e82b2e89f80444927
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/258800
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Nathaniel Nifong <nifong@google.com>
This commit is contained in:
Nathaniel Nifong 2019-12-09 10:05:42 -05:00 committed by Skia Commit-Bot
parent ab26643258
commit 732c49739f
2 changed files with 22 additions and 4 deletions

View File

@ -39,14 +39,18 @@ struct SimpleImageInfo {
int height;
SkColorType colorType;
SkAlphaType alphaType;
// Shown in the textual description of the image, and used as a common identifier between
// the resources tab and the command list.
// TODO(nifong) make the command list use the resource tab's ids instead of UrlDataManager
uintptr_t imageAddress;
};
SkImageInfo toSkImageInfo(const SimpleImageInfo& sii) {
return SkImageInfo::Make(sii.width, sii.height, sii.colorType, sii.alphaType);
}
SimpleImageInfo toSimpleImageInfo(const SkImageInfo& ii) {
return (SimpleImageInfo){ii.width(), ii.height(), ii.colorType(), ii.alphaType()};
SimpleImageInfo toSimpleImageInfo(const SkImageInfo& ii, const SkImage* addr) {
return (SimpleImageInfo){ii.width(), ii.height(), ii.colorType(), ii.alphaType(), (uintptr_t)addr};
}
class SkpDebugPlayer {
@ -184,7 +188,7 @@ class SkpDebugPlayer {
// Get the image info of one of the resource images.
SimpleImageInfo getImageInfo(int index) {
return toSimpleImageInfo(fImages[index]->imageInfo());
return toSimpleImageInfo(fImages[index]->imageInfo(), fImages[index].get());
}
private:
@ -375,7 +379,8 @@ EMSCRIPTEN_BINDINGS(my_module) {
.field("width", &SimpleImageInfo::width)
.field("height", &SimpleImageInfo::height)
.field("colorType", &SimpleImageInfo::colorType)
.field("alphaType", &SimpleImageInfo::alphaType);
.field("alphaType", &SimpleImageInfo::alphaType)
.field("imageAddress", &SimpleImageInfo::imageAddress);
constant("TRANSPARENT", (JSColor) SK_ColorTRANSPARENT);
function("_getRasterDirectSurface", optional_override([](const SimpleImageInfo ii,
uintptr_t /* uint8_t* */ pPtr,

View File

@ -88,6 +88,7 @@
#define DEBUGCANVAS_ATTRIBUTE_COLORFILTER "colorfilter"
#define DEBUGCANVAS_ATTRIBUTE_IMAGEFILTER "imagefilter"
#define DEBUGCANVAS_ATTRIBUTE_IMAGE "image"
#define DEBUGCANVAS_ATTRIBUTE_IMAGE_ADDRESS "imageAddress"
#define DEBUGCANVAS_ATTRIBUTE_BITMAP "bitmap"
#define DEBUGCANVAS_ATTRIBUTE_SRC "src"
#define DEBUGCANVAS_ATTRIBUTE_DST "dst"
@ -1318,6 +1319,9 @@ void DrawImageCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManag
flatten(*fImage, writer, urlDataManager);
writer.endObject(); // image
writer.appendName(DEBUGCANVAS_ATTRIBUTE_IMAGE_ADDRESS);
writer.appendU64((uint64_t)fImage.get());
writer.appendName(DEBUGCANVAS_ATTRIBUTE_COORDS);
MakeJsonPoint(writer, fLeft, fTop);
if (fPaint.isValid()) {
@ -1374,6 +1378,9 @@ void DrawImageLatticeCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDa
flatten(*fImage, writer, urlDataManager);
writer.endObject(); // image
writer.appendName(DEBUGCANVAS_ATTRIBUTE_IMAGE_ADDRESS);
writer.appendU64((uint64_t)fImage.get());
writer.appendName(DEBUGCANVAS_ATTRIBUTE_LATTICE);
MakeJsonLattice(writer, fLattice);
writer.appendName(DEBUGCANVAS_ATTRIBUTE_DST);
@ -1420,6 +1427,9 @@ void DrawImageRectCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataM
flatten(*fImage, writer, urlDataManager);
writer.endObject(); // image
writer.appendName(DEBUGCANVAS_ATTRIBUTE_IMAGE_ADDRESS);
writer.appendU64((uint64_t)fImage.get());
if (fSrc.isValid()) {
writer.appendName(DEBUGCANVAS_ATTRIBUTE_SRC);
MakeJsonRect(writer, *fSrc);
@ -1468,6 +1478,9 @@ void DrawImageNineCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataM
flatten(*fImage, writer, urlDataManager);
writer.endObject(); // image
writer.appendName(DEBUGCANVAS_ATTRIBUTE_IMAGE_ADDRESS);
writer.appendU64((uint64_t)fImage.get());
writer.appendName(DEBUGCANVAS_ATTRIBUTE_CENTER);
MakeJsonIRect(writer, fCenter);
writer.appendName(DEBUGCANVAS_ATTRIBUTE_DST);