efce17de5d
This is a reland of commit f60584eb0f
Client changes:
- https://chromium-review.googlesource.com/c/chromium/src/+/3508565
- http://cl/433225409
- http://cl/433450799
Original change's description:
> [includes] Remove link between SkImage.h and SkImageEncoder.h
>
> According to go/chrome-includes [1], this will save about
> 210MB (0.09%) off the Chrome build. http://screen/GVdDaRRneTRuroL
>
> [1] https://commondatastorage.googleapis.com/chromium-browser-clang/include-analysis.html#view=edges&filter=%5Ethird_party%2Fskia%2Finclude%2Fcore%2FSkImage%5C.h%24&sort=asize&reverse=&includer=%5Ethird_party%2Fskia%2Finclude%2Fcore%2FSkImage%5C.h%24&included=&limit=1000
>
> Change-Id: If911ec283a9ce2b07c8509768a6a05446573a215
> Bug: 242216
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/512416
> Reviewed-by: Leon Scroggins <scroggo@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Kevin Lubick <kjlubick@google.com>
Bug: 242216
Change-Id: Ic61e4ac2878e7a51f389312a3a434856e2e32be3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/518277
Reviewed-by: Leon Scroggins <scroggo@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
135 lines
3.9 KiB
C++
135 lines
3.9 KiB
C++
/*
|
|
* Copyright 2020 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "include/core/SkStream.h"
|
|
#include "modules/skottie/include/Skottie.h"
|
|
#include "tests/Test.h"
|
|
|
|
using namespace skottie;
|
|
using namespace skresources;
|
|
|
|
DEF_TEST(Skottie_AudioLayer, r) {
|
|
static constexpr char json[] =
|
|
R"({
|
|
"v": "5.2.1",
|
|
"w": 100,
|
|
"h": 100,
|
|
"fr": 10,
|
|
"ip": 0,
|
|
"op": 100,
|
|
"assets": [
|
|
{
|
|
"id": "audio_0",
|
|
"p" : "audio.mp3",
|
|
"u" : "assets/"
|
|
}
|
|
],
|
|
"layers": [
|
|
{
|
|
"ty" : 6,
|
|
"ind" : 0,
|
|
"ip" : 20,
|
|
"op" : 70,
|
|
"refId": "audio_0"
|
|
},
|
|
{
|
|
"ty" : 6,
|
|
"ind" : 0,
|
|
"ip" : 50,
|
|
"op" : 80,
|
|
"refId": "audio_0"
|
|
},
|
|
{
|
|
"ty": 1,
|
|
"ip": 0,
|
|
"op": 100,
|
|
"sw": 100,
|
|
"sh": 100,
|
|
"sc": "#ffffff"
|
|
}
|
|
]
|
|
})";
|
|
|
|
class MockTracker final : public ExternalTrackAsset {
|
|
public:
|
|
bool isPlaying() const { return fCurrentTime >= 0; }
|
|
float currentTime() const { return fCurrentTime; }
|
|
|
|
private:
|
|
void seek(float t) override {
|
|
fCurrentTime = t;
|
|
}
|
|
|
|
float fCurrentTime = 0;
|
|
};
|
|
|
|
class MockResourceProvider final : public ResourceProvider {
|
|
public:
|
|
explicit MockResourceProvider(skiatest::Reporter* r) : fReporter(r) {}
|
|
|
|
const std::vector<sk_sp<MockTracker>>& tracks() const { return fTracks; }
|
|
|
|
private:
|
|
sk_sp<ExternalTrackAsset> loadAudioAsset(const char path[],
|
|
const char name[],
|
|
const char id[]) override {
|
|
REPORTER_ASSERT(fReporter, !strcmp(path, "assets/"));
|
|
REPORTER_ASSERT(fReporter, !strcmp(name, "audio.mp3"));
|
|
REPORTER_ASSERT(fReporter, !strcmp(id , "audio_0"));
|
|
|
|
fTracks.push_back(sk_make_sp<MockTracker>());
|
|
|
|
return fTracks.back();
|
|
}
|
|
|
|
skiatest::Reporter* fReporter;
|
|
std::vector<sk_sp<MockTracker>> fTracks;
|
|
};
|
|
|
|
SkMemoryStream stream(json, strlen(json));
|
|
auto rp = sk_make_sp<MockResourceProvider>(r);
|
|
|
|
auto skottie = skottie::Animation::Builder()
|
|
.setResourceProvider(rp)
|
|
.make(&stream);
|
|
|
|
const auto& tracks = rp->tracks();
|
|
|
|
REPORTER_ASSERT(r, skottie);
|
|
REPORTER_ASSERT(r, tracks.size() == 2);
|
|
|
|
skottie->seekFrame(0);
|
|
REPORTER_ASSERT(r, !tracks[0]->isPlaying());
|
|
REPORTER_ASSERT(r, !tracks[1]->isPlaying());
|
|
|
|
skottie->seekFrame(20);
|
|
REPORTER_ASSERT(r, tracks[0]->isPlaying());
|
|
REPORTER_ASSERT(r, !tracks[1]->isPlaying());
|
|
REPORTER_ASSERT(r, tracks[0]->currentTime() == 0);
|
|
|
|
skottie->seekFrame(50);
|
|
REPORTER_ASSERT(r, tracks[0]->isPlaying());
|
|
REPORTER_ASSERT(r, tracks[1]->isPlaying());
|
|
REPORTER_ASSERT(r, tracks[0]->currentTime() == 3);
|
|
REPORTER_ASSERT(r, tracks[1]->currentTime() == 0);
|
|
|
|
skottie->seekFrame(70);
|
|
REPORTER_ASSERT(r, tracks[0]->isPlaying());
|
|
REPORTER_ASSERT(r, tracks[1]->isPlaying());
|
|
REPORTER_ASSERT(r, tracks[0]->currentTime() == 5);
|
|
REPORTER_ASSERT(r, tracks[1]->currentTime() == 2);
|
|
|
|
skottie->seekFrame(80);
|
|
REPORTER_ASSERT(r, !tracks[0]->isPlaying());
|
|
REPORTER_ASSERT(r, tracks[1]->isPlaying());
|
|
REPORTER_ASSERT(r, tracks[1]->currentTime() == 3);
|
|
|
|
skottie->seekFrame(100);
|
|
REPORTER_ASSERT(r, !tracks[0]->isPlaying());
|
|
REPORTER_ASSERT(r, !tracks[1]->isPlaying());
|
|
}
|