Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Replace all uses of SkBase64 encoding
  • Loading branch information
kjlubick committed Oct 4, 2023
commit 2681791882763126e1b908ae878cafeaa5f162bd
1 change: 1 addition & 0 deletions flow/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ if (enable_unittests) {
":flow_fixtures",
":flow_testing",
"//flutter/common/graphics",
"//flutter/shell/common:base64",
"//flutter/display_list/testing:display_list_testing",
"//flutter/fml",
"//flutter/testing:skia",
Expand Down
9 changes: 5 additions & 4 deletions flow/layers/performance_overlay_layer_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "flutter/flow/flow_test_utils.h"
#include "flutter/flow/raster_cache.h"
#include "flutter/flow/testing/layer_test.h"
#include "flutter/shell/common/base64.h"
#include "flutter/testing/mock_canvas.h"
#include "third_party/skia/include/core/SkData.h"
#include "third_party/skia/include/core/SkImage.h"
Expand All @@ -18,7 +19,6 @@
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/core/SkTextBlob.h"
#include "third_party/skia/include/encode/SkPngEncoder.h"
#include "third_party/skia/include/utils/SkBase64.h"

namespace flutter {
namespace testing {
Expand Down Expand Up @@ -111,11 +111,12 @@ static void TestPerformanceOverlayLayerGold(int refresh_rate) {
wstream.write(snapshot_data->data(), snapshot_data->size());
wstream.flush();

size_t b64_size =
SkBase64::Encode(snapshot_data->data(), snapshot_data->size(), nullptr);
// TODO(kjlubick) We shouldn't need to call Encode once to pre-flight the
// encode length. It should be ceil(4/3 * sksl.value->size()).
size_t b64_size = Base64::Encode(snapshot_data->data(), snapshot_data->size(), nullptr);
sk_sp<SkData> b64_data = SkData::MakeUninitialized(b64_size + 1);
char* b64_char = static_cast<char*>(b64_data->writable_data());
SkBase64::Encode(snapshot_data->data(), snapshot_data->size(), b64_char);
Base64::Encode(snapshot_data->data(), snapshot_data->size(), b64_char);
b64_char[b64_size] = 0; // make it null terminated for printing

EXPECT_TRUE(golden_data_matches)
Expand Down
1 change: 1 addition & 0 deletions shell/common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ source_set("base64") {
"base64.cc",
"base64.h",
]
deps = ["//flutter/fml"]
}

template("shell_host_executable") {
Expand Down
8 changes: 5 additions & 3 deletions shell/common/rasterizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "flutter/fml/time/time_delta.h"
#include "flutter/fml/time/time_point.h"
#include "flutter/shell/common/serialization_callbacks.h"
#include "flutter/shell/common/base64.h"
#include "fml/make_copyable.h"
#include "third_party/skia/include/core/SkColorSpace.h"
#include "third_party/skia/include/core/SkData.h"
Expand All @@ -32,7 +33,6 @@
#include "third_party/skia/include/gpu/GrDirectContext.h"
#include "third_party/skia/include/gpu/GrTypes.h"
#include "third_party/skia/include/gpu/ganesh/SkSurfaceGanesh.h"
#include "third_party/skia/include/utils/SkBase64.h"

namespace flutter {

Expand Down Expand Up @@ -910,9 +910,11 @@ Rasterizer::Screenshot Rasterizer::ScreenshotLastLayerTree(
}

if (base64_encode) {
size_t b64_size = SkBase64::Encode(data->data(), data->size(), nullptr);
// TODO(kjlubick) We shouldn't need to call Encode once to pre-flight the
// encode length. It should be ceil(4/3 * sksl.value->size()).
size_t b64_size = Base64::Encode(data->data(), data->size(), nullptr);
auto b64_data = SkData::MakeUninitialized(b64_size);
SkBase64::Encode(data->data(), data->size(), b64_data->writable_data());
Base64::Encode(data->data(), data->size(), b64_data->writable_data());
return Rasterizer::Screenshot{b64_data, layer_tree->frame_size(), format};
}

Expand Down
9 changes: 5 additions & 4 deletions shell/common/shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "flutter/fml/trace_event.h"
#include "flutter/runtime/dart_vm.h"
#include "flutter/shell/common/engine.h"
#include "flutter/shell/common/base64.h"
#include "flutter/shell/common/skia_event_tracer_impl.h"
#include "flutter/shell/common/switches.h"
#include "flutter/shell/common/vsync_waiter.h"
Expand All @@ -39,7 +40,6 @@
#include "third_party/skia/include/codec/SkWbmpDecoder.h"
#include "third_party/skia/include/codec/SkWebpDecoder.h"
#include "third_party/skia/include/core/SkGraphics.h"
#include "third_party/skia/include/utils/SkBase64.h"
#include "third_party/tonic/common/log.h"

namespace flutter {
Expand Down Expand Up @@ -1840,11 +1840,12 @@ bool Shell::OnServiceProtocolGetSkSLs(
PersistentCache* persistent_cache = PersistentCache::GetCacheForProcess();
std::vector<PersistentCache::SkSLCache> sksls = persistent_cache->LoadSkSLs();
for (const auto& sksl : sksls) {
size_t b64_size =
SkBase64::Encode(sksl.value->data(), sksl.value->size(), nullptr);
// TODO(kjlubick) We shouldn't need to call Encode once to pre-flight the
// encode length. It should be ceil(4/3 * sksl.value->size()).
size_t b64_size = Base64::Encode(sksl.value->data(), sksl.value->size(), nullptr);
sk_sp<SkData> b64_data = SkData::MakeUninitialized(b64_size + 1);
char* b64_char = static_cast<char*>(b64_data->writable_data());
SkBase64::Encode(sksl.value->data(), sksl.value->size(), b64_char);
Base64::Encode(sksl.value->data(), sksl.value->size(), b64_char);
b64_char[b64_size] = 0; // make it null terminated for printing
rapidjson::Value shader_value(b64_char, response->GetAllocator());
std::string_view key_view(reinterpret_cast<const char*>(sksl.key->data()),
Expand Down