forked from chromium/chromium
-
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.
Enable building Skia's Lottie engine
Making Skottie available for future CrOS UI work. Change-Id: I41946a4f0d09099e15bf4d08a64bb566080ff393 Reviewed-on: https://chromium-review.googlesource.com/1160772 Reviewed-by: Mike Reed <reed@chromium.org> Reviewed-by: Ben Wagner <bungeman@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org> Cr-Commit-Position: refs/heads/master@{#580374}
- Loading branch information
Showing
2 changed files
with
75 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright (c) 2018 The Chromium 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 "testing/gtest/include/gtest/gtest.h" | ||
#include "third_party/skia/include/core/SkPixmap.h" | ||
#include "third_party/skia/include/core/SkStream.h" | ||
#include "third_party/skia/include/core/SkSurface.h" | ||
#include "third_party/skia/modules/skottie/include/Skottie.h" | ||
|
||
TEST(Skottie, Basic) { | ||
// Just a solid green layer. | ||
static constexpr char anim_data[] = | ||
"{" | ||
" \"v\" : \"4.12.0\"," | ||
" \"fr\": 30," | ||
" \"w\" : 400," | ||
" \"h\" : 200," | ||
" \"ip\": 0," | ||
" \"op\": 150," | ||
" \"assets\": []," | ||
|
||
" \"layers\": [" | ||
" {" | ||
" \"ty\": 1," | ||
" \"sw\": 400," | ||
" \"sh\": 200," | ||
" \"sc\": \"#00ff00\"," | ||
" \"ip\": 0," | ||
" \"op\": 150" | ||
" }" | ||
" ]" | ||
"}"; | ||
|
||
SkMemoryStream stream(anim_data, strlen(anim_data)); | ||
auto anim = skottie::Animation::Make(&stream); | ||
|
||
ASSERT_TRUE(anim); | ||
EXPECT_EQ(strcmp(anim->version().c_str(), "4.12.0"), 0); | ||
EXPECT_EQ(anim->size().width(), 400.0f); | ||
EXPECT_EQ(anim->size().height(), 200.0f); | ||
EXPECT_EQ(anim->duration(), 5.0f); | ||
|
||
auto surface = SkSurface::MakeRasterN32Premul(400, 200); | ||
anim->seek(0); | ||
anim->render(surface->getCanvas()); | ||
|
||
SkPixmap pixmap; | ||
ASSERT_TRUE(surface->peekPixels(&pixmap)); | ||
|
||
for (int i = 0; i < pixmap.width(); ++i) { | ||
for (int j = 0; j < pixmap.height(); ++j) { | ||
EXPECT_EQ(pixmap.getColor(i, j), 0xff00ff00); | ||
} | ||
} | ||
} |