Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion apps/paper/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1969,7 +1969,7 @@ SPEC CHECKSUMS:
RNScreens: 19719a9c326e925498ac3b2d35c4e50fe87afc06
RNSVG: 5da7a24f31968ec74f0b091e3440080f347e279b
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
Yoga: 2a45d7e59592db061217551fd3bbe2dd993817ae
Yoga: a1d7895431387402a674fd0d1c04ec85e87909b8

PODFILE CHECKSUM: debc09f5cfcbea21f946ca0be3faa5351e907125

Expand Down
2 changes: 1 addition & 1 deletion apps/paper/src/Examples/Breathe/Breathe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const Breathe = () => {

return (
<View style={{ flex: 1 }}>
<Canvas style={styles.container}>
<Canvas style={styles.container} opaque>
<Fill color="rgb(36,43,56)" />
<Group origin={center} transform={transform} blendMode="screen">
<BlurMask style="solid" blur={40} />
Expand Down
2 changes: 1 addition & 1 deletion apps/paper/src/Examples/Glassmorphism/Glassmorphism.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const Glassmorphism = () => {
);

return (
<Canvas style={{ flex: 1 }}>
<Canvas style={{ flex: 1 }} opaque>
<Fill color="black" />
<Circle c={c} r={radius}>
<LinearGradient
Expand Down
2 changes: 1 addition & 1 deletion apps/paper/src/Examples/Matrix/Matrix.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const Matrix = () => {
}
const symbols = font.getGlyphIDs("abcdefghijklmnopqrstuvwxyz");
return (
<Canvas style={{ flex: 1 }}>
<Canvas style={{ flex: 1 }} opaque>
<Fill color="black" />
<Group>
<BlurMask blur={8} style="solid" />
Expand Down
4 changes: 2 additions & 2 deletions apps/paper/src/Examples/Matrix/Symbol.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { interpolateColors, vec, Glyphs } from "@shopify/react-native-skia";
import type { SharedValue } from "react-native-reanimated";
import { useDerivedValue } from "react-native-reanimated";

export const COLS = 15;
export const ROWS = 30;
export const COLS = 8;
export const ROWS = 15;
const pos = vec(0, 0);

interface SymbolProps {
Expand Down
2 changes: 1 addition & 1 deletion apps/paper/src/Examples/Severance/Severance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const Severance = () => {
return (
<View style={{ flex: 1 }}>
<GestureDetector gesture={gesture}>
<Canvas style={{ flex: 1 }}>
<Canvas style={{ flex: 1 }} opaque>
<CRT>
<Group>
<Fill color={BG} />
Expand Down
2 changes: 1 addition & 1 deletion apps/paper/src/Examples/Stickers/Stickers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const Stickers = () => {
}
return (
<View>
<Canvas style={{ width, height }}>
<Canvas style={{ width, height }} opaque>
<Picture matrix={pictureMatrix} image={image} />
<HelloSticker matrix={helloMatrix} />
<LocationSticker font={font} matrix={locationMatrix} />
Expand Down
4 changes: 2 additions & 2 deletions apps/paper/src/Examples/Video/Video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const Video = () => {
style={{ flex: 1 }}
onPress={() => (paused.value = !paused.value)}
>
<Canvas style={{ flex: 1 }}>
<Canvas style={{ flex: 1 }} opaque>
<Fill>
<ImageShader
image={currentFrame}
Expand All @@ -62,7 +62,7 @@ export const Video = () => {
/>
</Canvas>
</Pressable>
<View style={{ height: 200 }}>
<View style={{ height: 200, backgroundColor: "white" }}>
<Slider
style={{ width, height: 40 }}
minimumValue={0}
Expand Down
2 changes: 1 addition & 1 deletion externals/depot_tools
Submodule depot_tools updated from beb48f to 728e70
14 changes: 10 additions & 4 deletions packages/skia/android/cpp/jni/include/JniSkiaBaseView.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,18 @@ class JniSkiaBaseView {
}

protected:
virtual void surfaceAvailable(jobject surface, int width, int height) {
_skiaAndroidView->surfaceAvailable(surface, width, height);
virtual void drawBitmap(jobject bitmap, int width, int height) {
_skiaAndroidView->drawBitmap(bitmap, width, height);
}

virtual void surfaceSizeChanged(jobject surface, int width, int height) {
_skiaAndroidView->surfaceSizeChanged(surface, width, height);
virtual void surfaceAvailable(jobject surface, int width, int height,
bool opaque) {
_skiaAndroidView->surfaceAvailable(surface, width, height, opaque);
}

virtual void surfaceSizeChanged(jobject surface, int width, int height,
bool opaque) {
_skiaAndroidView->surfaceSizeChanged(surface, width, height, opaque);
}

virtual void surfaceDestroyed() { _skiaAndroidView->surfaceDestroyed(); }
Expand Down
15 changes: 11 additions & 4 deletions packages/skia/android/cpp/jni/include/JniSkiaDomView.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class JniSkiaDomView : public jni::HybridClass<JniSkiaDomView>,
static void registerNatives() {
registerHybrid(
{makeNativeMethod("initHybrid", JniSkiaDomView::initHybrid),
makeNativeMethod("drawBitmap", JniSkiaDomView::drawBitmap),
makeNativeMethod("surfaceAvailable", JniSkiaDomView::surfaceAvailable),
makeNativeMethod("surfaceDestroyed", JniSkiaDomView::surfaceDestroyed),
makeNativeMethod("surfaceSizeChanged",
Expand All @@ -46,12 +47,18 @@ class JniSkiaDomView : public jni::HybridClass<JniSkiaDomView>,
}

protected:
void surfaceAvailable(jobject surface, int width, int height) override {
JniSkiaBaseView::surfaceAvailable(surface, width, height);
void drawBitmap(jobject bitmap, int width, int height) override {
JniSkiaBaseView::drawBitmap(bitmap, width, height);
}

void surfaceSizeChanged(jobject surface, int width, int height) override {
JniSkiaBaseView::surfaceSizeChanged(surface, width, height);
void surfaceAvailable(jobject surface, int width, int height,
bool opaque) override {
JniSkiaBaseView::surfaceAvailable(surface, width, height, opaque);
}

void surfaceSizeChanged(jobject surface, int width, int height,
bool opaque) override {
JniSkiaBaseView::surfaceSizeChanged(surface, width, height, opaque);
}

void surfaceDestroyed() override { JniSkiaBaseView::surfaceDestroyed(); }
Expand Down
15 changes: 11 additions & 4 deletions packages/skia/android/cpp/jni/include/JniSkiaPictureView.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class JniSkiaPictureView : public jni::HybridClass<JniSkiaPictureView>,
static void registerNatives() {
registerHybrid(
{makeNativeMethod("initHybrid", JniSkiaPictureView::initHybrid),
makeNativeMethod("drawBitmap", JniSkiaPictureView::drawBitmap),
makeNativeMethod("surfaceAvailable",
JniSkiaPictureView::surfaceAvailable),
makeNativeMethod("surfaceDestroyed",
Expand All @@ -48,12 +49,18 @@ class JniSkiaPictureView : public jni::HybridClass<JniSkiaPictureView>,
}

protected:
void surfaceAvailable(jobject surface, int width, int height) override {
JniSkiaBaseView::surfaceAvailable(surface, width, height);
void drawBitmap(jobject bitmap, int width, int height) override {
JniSkiaBaseView::drawBitmap(bitmap, width, height);
}

void surfaceSizeChanged(jobject surface, int width, int height) override {
JniSkiaBaseView::surfaceSizeChanged(surface, width, height);
void surfaceAvailable(jobject surface, int width, int height,
bool opaque) override {
JniSkiaBaseView::surfaceAvailable(surface, width, height, opaque);
}

void surfaceSizeChanged(jobject surface, int width, int height,
bool opaque) override {
JniSkiaBaseView::surfaceSizeChanged(surface, width, height, opaque);
}

void surfaceDestroyed() override { JniSkiaBaseView::surfaceDestroyed(); }
Expand Down
8 changes: 8 additions & 0 deletions packages/skia/android/cpp/rnskia-android/OpenGLContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class OpenGLContext {
// TODO: remove width, height
std::unique_ptr<WindowContext> MakeWindow(ANativeWindow *window, int width,
int height) {

return std::make_unique<OpenGLWindowContext>(
_directContext.get(), _glDisplay.get(), _glContext.get(), window);
}
Expand All @@ -154,6 +155,13 @@ class OpenGLContext {
throw std::runtime_error("GrDirectContexts::MakeGL failed");
}
}

~OpenGLContext() {
_glDisplay->clearContext();
_glSurface = nullptr;
_glContext = nullptr;
_directContext = nullptr;
}
};

} // namespace RNSkia
25 changes: 17 additions & 8 deletions packages/skia/android/cpp/rnskia-android/RNSkAndroidView.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ namespace RNSkia {

class RNSkBaseAndroidView {
public:
virtual void surfaceAvailable(jobject surface, int width, int height) = 0;
virtual void drawBitmap(jobject bitmap, int width, int height) = 0;

virtual void surfaceAvailable(jobject surface, int width, int height,
bool opaque) = 0;

virtual void surfaceDestroyed() = 0;

virtual void surfaceSizeChanged(jobject surface, int width, int height) = 0;
virtual void surfaceSizeChanged(jobject surface, int width, int height,
bool opaque) = 0;

virtual float getPixelDensity() = 0;

Expand All @@ -34,12 +38,16 @@ class RNSkAndroidView : public T, public RNSkBaseAndroidView {
std::make_shared<RNSkOpenGLCanvasProvider>(
std::bind(&RNSkia::RNSkView::requestRedraw, this), context)) {}

void surfaceAvailable(jobject surface, int width, int height) override {
virtual void drawBitmap(jobject bitmap, int width, int height) override {
std::static_pointer_cast<RNSkOpenGLCanvasProvider>(T::getCanvasProvider())
->surfaceAvailable(surface, width, height);
->drawBitmap(bitmap, width, height);
RNSkView::redraw();
}

// Try to render directly when the surface has been set so that
// we don't have to wait until the draw loop returns.
void surfaceAvailable(jobject surface, int width, int height,
bool opaque) override {
std::static_pointer_cast<RNSkOpenGLCanvasProvider>(T::getCanvasProvider())
->surfaceAvailable(surface, width, height, opaque);
RNSkView::redraw();
}

Expand All @@ -48,9 +56,10 @@ class RNSkAndroidView : public T, public RNSkBaseAndroidView {
->surfaceDestroyed();
}

void surfaceSizeChanged(jobject surface, int width, int height) override {
void surfaceSizeChanged(jobject surface, int width, int height,
bool opaque) override {
std::static_pointer_cast<RNSkOpenGLCanvasProvider>(T::getCanvasProvider())
->surfaceSizeChanged(surface, width, height);
->surfaceSizeChanged(surface, width, height, opaque);
// This is only need for the first time to frame, this renderImmediate call
// will invoke updateTexImage for the previous frame
RNSkView::redraw();
Expand Down
Loading
Loading