errscreen.go (813B)
1 // Copyright 2015 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Package errscreen provides a stub Screen implementation. 6 package errscreen // import "golang.org/x/exp/shiny/driver/internal/errscreen" 7 8 import ( 9 "image" 10 11 "golang.org/x/exp/shiny/screen" 12 ) 13 14 // Stub returns a Screen whose methods all return the given error. 15 func Stub(err error) screen.Screen { 16 return stub{err} 17 } 18 19 type stub struct { 20 err error 21 } 22 23 func (s stub) NewBuffer(size image.Point) (screen.Buffer, error) { return nil, s.err } 24 func (s stub) NewTexture(size image.Point) (screen.Texture, error) { return nil, s.err } 25 func (s stub) NewWindow(opts *screen.NewWindowOptions) (screen.Window, error) { return nil, s.err }