Skip to content

Commit

Permalink
Remove unnecessary Skia modifications (#2568)
Browse files Browse the repository at this point in the history
Reduce upstream diff more.

b/304784019

Test-On-Device: true
  • Loading branch information
kaidokert authored Mar 11, 2024
1 parent 03b925b commit da74c31
Show file tree
Hide file tree
Showing 16 changed files with 66 additions and 628 deletions.
2 changes: 1 addition & 1 deletion cobalt/renderer/rasterizer/skia/skia/skia_template.gni
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ template("skia_common") {

# Use scalar portable implementations instead of Clang/GCC vector extensions
# in SkVx.h, as this causes an internal compiler error for raspi-2.
"SKNX_NO_SIMD",
# "SKNX_NO_SIMD",
]

configs += [ ":skia_common_config_$target_name" ]
Expand Down
32 changes: 16 additions & 16 deletions cobalt/renderer/rasterizer/skia/skia/src/ports/SkOSFile_cobalt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@

namespace {

SbFile ToSbFile(SkFile* sk_file) {
SbFile ToSbFile(FILE* sk_file) {
// PlatformFile is a pointer type in Starboard, so we cannot use static_cast
// from intptr_t.
return reinterpret_cast<SbFile>(sk_file);
}

SkFile* ToFILE(SbFile starboard_file) {
return reinterpret_cast<SkFile*>(starboard_file);
FILE* ToFILE(SbFile starboard_file) {
return reinterpret_cast<FILE*>(starboard_file);
}

int ToSbFileFlags(SkFILE_Flags sk_flags) {
Expand All @@ -48,7 +48,7 @@ int ToSbFileFlags(SkFILE_Flags sk_flags) {

} // namespace

SkFile* sk_fopen(const char path[], SkFILE_Flags sk_flags) {
FILE* sk_fopen(const char path[], SkFILE_Flags sk_flags) {
SbFile starboard_file = SbFileOpen(path, ToSbFileFlags(sk_flags), NULL, NULL);
if (starboard_file == base::kInvalidPlatformFile) {
return nullptr;
Expand All @@ -57,12 +57,12 @@ SkFile* sk_fopen(const char path[], SkFILE_Flags sk_flags) {
return ToFILE(starboard_file);
}

void sk_fclose(SkFile* sk_file) {
void sk_fclose(FILE* sk_file) {
SkASSERT(sk_file);
SbFileClose(ToSbFile(sk_file));
}

size_t sk_fgetsize(SkFile* sk_file) {
size_t sk_fgetsize(FILE* sk_file) {
SkASSERT(sk_file);
SbFile file = ToSbFile(sk_file);

Expand All @@ -83,7 +83,7 @@ size_t sk_fgetsize(SkFile* sk_file) {
return size;
}

size_t sk_fwrite(const void* buffer, size_t byteCount, SkFile* sk_file) {
size_t sk_fwrite(const void* buffer, size_t byteCount, FILE* sk_file) {
SkASSERT(sk_file);
SbFile file = ToSbFile(sk_file);
int result =
Expand All @@ -92,26 +92,26 @@ size_t sk_fwrite(const void* buffer, size_t byteCount, SkFile* sk_file) {
return result;
}

void sk_fflush(SkFile* sk_file) {
void sk_fflush(FILE* sk_file) {
SkASSERT(sk_file);
SbFile file = ToSbFile(sk_file);
SbFileFlush(file);
}

bool sk_fseek(SkFile* sk_file, size_t position) {
bool sk_fseek(FILE* sk_file, size_t position) {
SkASSERT(sk_file);
SbFile file = ToSbFile(sk_file);
int64_t new_position = SbFileSeek(file, kSbFileFromBegin, position);
return new_position == position;
}

size_t sk_ftell(SkFile* sk_file) {
size_t sk_ftell(FILE* sk_file) {
SkASSERT(sk_file);
SbFile file = ToSbFile(sk_file);
return SbFileSeek(file, kSbFileFromCurrent, 0);
}

void* sk_fmmap(SkFile* sk_file, size_t* length) {
void* sk_fmmap(FILE* sk_file, size_t* length) {
// Not supported, but clients may try to call to see if it is supported.
return NULL;
}
Expand All @@ -125,12 +125,12 @@ void sk_fmunmap(const void* addr, size_t length) {
NOTREACHED() << __FUNCTION__;
}

bool sk_fidentical(SkFile* sk_file_a, SkFile* sk_file_b) {
bool sk_fidentical(FILE* sk_file_a, FILE* sk_file_b) {
NOTREACHED() << __FUNCTION__;
return false;
}

int sk_fileno(SkFile* sk_file_a) {
int sk_fileno(FILE* sk_file_a) {
NOTREACHED() << __FUNCTION__;
return -1;
}
Expand All @@ -150,15 +150,15 @@ bool sk_mkdir(const char* path) {
return false;
}

void sk_fsync(SkFile* f) {
void sk_fsync(FILE* f) {
SkASSERT(f);
SbFile file = ToSbFile(f);
// Technically, flush doesn't have to call sync... but this is the best
// effort we can make.
SbFileFlush(file);
}

size_t sk_qread(SkFile* file, void* buffer, size_t count, size_t offset) {
size_t sk_qread(FILE* file, void* buffer, size_t count, size_t offset) {
SkASSERT(file);
SbFile starboard_file = ToSbFile(file);

Expand All @@ -181,7 +181,7 @@ size_t sk_qread(SkFile* file, void* buffer, size_t count, size_t offset) {
}
}

size_t sk_fread(void* buffer, size_t byteCount, SkFile* file) {
size_t sk_fread(void* buffer, size_t byteCount, FILE* file) {
SkASSERT(file);
SbFile starboard_file = ToSbFile(file);
return SbFileReadAll(starboard_file, reinterpret_cast<char*>(buffer),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#include "third_party/skia/src/core/SkOSFile.h"

// Read |byteCount| bytes from current file cursor position.
size_t sk_fread(void* buffer, size_t byteCount, SkFile* file);
size_t sk_fread(void* buffer, size_t byteCount, FILE* file);
// Seek to |offset| bytes within the file.
bool sk_fseek(SkFile* file, size_t offset);
bool sk_fseek(FILE* file, size_t offset);

#endif // COBALT_RENDERER_RASTERIZER_SKIA_SKIA_SRC_PORTS_SKOSFILE_COBALT_H_
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class SkFileMemoryChunkStream : public SkStreamAsset {

SkFileMemoryChunkStreamProvider* const stream_provider_;

SkFile* const file_;
FILE* const file_;
size_t file_length_;
size_t file_position_;

Expand Down
3 changes: 1 addition & 2 deletions third_party/skia/include/core/SkData.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <stdio.h>

#include "include/core/SkRefCnt.h"
#include "src/core/SkOSFile.h" // Included for SkFile.

class SkStream;

Expand Down Expand Up @@ -134,7 +133,7 @@ class SK_API SkData final : public SkNVRefCnt<SkData> {
* The FILE must be open for reading only.
* Returns NULL on failure.
*/
static sk_sp<SkData> MakeFromFILE(SkFile* f);
static sk_sp<SkData> MakeFromFILE(FILE* f);

/**
* Create a new dataref from a file descriptor.
Expand Down
Loading

0 comments on commit da74c31

Please sign in to comment.