From 465d8aa2731193ed3071e79bcb35c4d98fd152b5 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 24 May 2020 19:15:18 +0900 Subject: [PATCH] graphicscommand: Add IsShaderAvailable for other packages --- internal/graphicscommand/command.go | 12 ++++++++++++ internal/graphicscommand/export_test.go | 19 ------------------- internal/graphicscommand/image_test.go | 8 ++------ 3 files changed, 14 insertions(+), 25 deletions(-) delete mode 100644 internal/graphicscommand/export_test.go diff --git a/internal/graphicscommand/command.go b/internal/graphicscommand/command.go index 99130a493..8dd54b1ed 100644 --- a/internal/graphicscommand/command.go +++ b/internal/graphicscommand/command.go @@ -22,6 +22,7 @@ import ( "github.com/hajimehoshi/ebiten/internal/driver" "github.com/hajimehoshi/ebiten/internal/graphics" "github.com/hajimehoshi/ebiten/internal/shaderir" + "github.com/hajimehoshi/ebiten/internal/web" ) var theGraphicsDriver driver.Graphics @@ -39,6 +40,17 @@ func NeedsRestoring() bool { return theGraphicsDriver.NeedsRestoring() } +// IsShaderAvailable reports whether shaders are available. This function is only for testing. +func IsShaderAvailable() bool { + if !theGraphicsDriver.IsGL() { + return false + } + if web.IsBrowser() { + return false + } + return true +} + // command represents a drawing command. // // A command for drawing that is created when Image functions are called like DrawTriangles, diff --git a/internal/graphicscommand/export_test.go b/internal/graphicscommand/export_test.go deleted file mode 100644 index 06ebb030d..000000000 --- a/internal/graphicscommand/export_test.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2020 The Ebiten Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package graphicscommand - -func IsGL() bool { - return theGraphicsDriver.IsGL() -} diff --git a/internal/graphicscommand/image_test.go b/internal/graphicscommand/image_test.go index e0ef48942..cbdbadeca 100644 --- a/internal/graphicscommand/image_test.go +++ b/internal/graphicscommand/image_test.go @@ -23,7 +23,6 @@ import ( . "github.com/hajimehoshi/ebiten/internal/graphicscommand" "github.com/hajimehoshi/ebiten/internal/shaderir" t "github.com/hajimehoshi/ebiten/internal/testing" - "github.com/hajimehoshi/ebiten/internal/web" ) func TestMain(m *testing.M) { @@ -82,11 +81,8 @@ func TestReplacePixelsPartAfterDrawTriangles(t *testing.T) { } func TestShader(t *testing.T) { - if !IsGL() { - t.Skip("shader is not implemented on non-GL environment") - } - if web.IsBrowser() { - t.Skip("shader is not implemented on browsers") + if !IsShaderAvailable() { + t.Skip("shader is not implemented on this environment") } const w, h = 16, 16