[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Public WebGL] Behavior of WebGL canvas when it can't make a backbuffer of the requested size?
- To: "Kenneth Russell" <email@example.com>
- Subject: Re: [Public WebGL] Behavior of WebGL canvas when it can't make a backbuffer of the requested size?
- From: firstname.lastname@example.org
- Date: Thu, 4 Nov 2010 09:50:54 -0700
- Cc: "Steve Baker" <email@example.com>, "Gregg Tavares (wrk)" <firstname.lastname@example.org>, "Chris Marrin" <email@example.com>, "Vladimir Vukicevic" <firstname.lastname@example.org>, "public webgl" <email@example.com>
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed; d=sjbaker.org; h=message-id :in-reply-to:references:date:subject:from:to:cc:mime-version :content-type:content-transfer-encoding; s=sjbaker.org; bh=2jWpe PoI1mhvQN8AvVlixL4Fl4c=; b=eoCsQVZD+711PP8zErdDKOgDFujnt+LOP83c/ VS2BSSwMmKjlTMLFx4oMxNeUbWrm/WWu+oKicLBm6YpNxJf2mx6PR+RXb2rb4Uie QbNMw9tZlS3k6n8ZWde96+nX6MsKDjz6xXDs3fhIcKjFwdZx2Yk3MQlXwUbSXy2l 7WT8Y0=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=sjbaker.org; h=message-id :in-reply-to:references:date:subject:from:to:cc:mime-version :content-type:content-transfer-encoding; q=dns; s=sjbaker.org; b=NUfUjNO2Dq1si3SadFLjBXgQ9Fsf1TqyB8hpgMhoMmp/hM3KBYnqXDeSJr0j4 s53Mn0qdFClxgTxbgCbCPWPLVNK3JBQ9OOHM6Y0wCY/v4S38UNMBFfz85Rr4xkGh IVJSAH6Hu1MKxruAzOP6oS06GloHyF4U0v+IHKJgm8LZaY=
- In-reply-to: <AANLkTin+yVhPr8wMYLe_gdvex6rWHCG3doz-9_=1g1SX@mail.gmail.com>
- References: <AANLkTi=rKRNuWGwfD39h5d6Ttu55paWSq9qTNQ19xfC5@mail.gmail.com> <1561074246.1142.1285141436615.JavaMail.firstname.lastname@example.org> <AANLkTin2iu-V1LckEs_YJCUFgwRWX4rPvy+Z8MnaGy5c@mail.gmail.com> <27872E4C-B753-4DAC-8353-BFC3D74739D2@apple.com> <AANLkTim-i8j4LrzDrWyi_djdSxpg0-j5igvRhK9DNSMj@mail.gmail.com> <4C9D395A.email@example.com> <7ED78BBF-6DD3-45B1-978E-0FFDA5856695@apple.com> <AANLkTi=rFt3apXrfwfxtcF47nZS+fKDRCXMmPRUfd0Ja@mail.gmail.com> <29C16266-C657-4CB6-9B01-CFD9B2DD8A61@apple.com> <AANLkTimutLit_273e5pg1e3fg7n-uQyPK1ZxoZenBj59@mail.gmail.com> <AFA5AA20-36D7-4B85-95CA-2BB520C59DEC@apple.com> <AANLkTimi-Zgq62B7GEnYR72qR+kkMgFzagbX=4PWM0Rt@mail.gmail.com> <34C909B2-D7A1-4983-A79F-99D322F2AC17@apple.com> <AANLkTikr5ZDtydmyTn+OLqbuut6uquVW6PW+2tM_btmR@mail.gmail.com> <4CA50820.firstname.lastname@example.org> <AANLkTinPNy0UKgGffNF67xM_8qn9vvq_5M4wUbP3hBmg@mail.gmail.com> <4CD23DDE.email@example.com> <AANLkTin+yVhPr8wMYLe_gdvex6rWHCG3doz-9_=1g1SX@mail.gmail.com>
- Sender: firstname.lastname@example.org
- User-agent: SquirrelMail/1.4.21
> On Wed, Nov 3, 2010 at 10:00 PM, Steve Baker <email@example.com> wrote:
>> On 11/03/2010 09:11 PM, Kenneth Russell wrote:
>>> 1. Make the largest supported backing store, and stretch it to fit the
>>> canvas's area on the web page. Add an API to WebGLRenderingContext,
>>> "long getDrawingBufferSize()", returning the actual width and height
>>> of the backing store.
>>> 2. Set a synchronous error condition on the canvas which can be
>>> checked via a new API such as "boolean isDrawingBufferValid()". Draw
>>> calls either raise an error or are ignored.
>>> 3. Raise a WebGL context lost event when the canvas is resized too
>>> large, and a context restored event when it is shrunk back to a
>>> supported size.
>>> At this point I continue to believe that (1) is the best option for
>>> web developers. Naive developers will get mostly correct results,
>>> which based on discussion with Tab Atkins are better than no results.
>>> I would no longer advocate (3) as it is too complex to handle. Raising
>>> an exception from the setting of canvas.width or canvas.height does
>>> not seem to be a viable option as it changes the semantics of these
>>> I propose that we update the spec to indicate that WebGL
>>> implementations do (1). Please send any comments to the list.
>> Excellent! I agree.
>> This way, you are rendering to a smaller surface than you asked for (and
>> you can query the dimensions that you actually got) - and the resulting
>> image will be stretched as necessary (presumably by the compositing
>> software) to make it cover the area you actually asked for. But please,
>> let's not try to automatically compensate with viewport dimensions and
>> such. It should be up to the application to get that right by using the
>> numbers returned by getDrawingBufferSize()
>> Also, can the specification provide a guarantee that the aspect ratio of
>> the reduced surface will be (to within reasonable hardware limits) the
>> same as the application asked for? Some algorithms behave badly with
>> non-square pixels.
>> eg: If I asked for 512k pixels as a 1024x512 rendering buffer - but
>> there were only 320k pixels of storage available - then I should
>> reasonably expect to get back an 800x400 buffer rather than a 640x512 or
>> a 1024x320.
> How would you define "reasonable hardware limits"? Having one
> dimension be off by no more than one or two pixels from the ideal,
> potentially fractional, value when preserving the aspect ratio? Off by
> no more than a certain percentage? What about pathological cases of
> very wide or very tall canvases?
Well, I thought about saying "accurate to the nearest pixel" - but then I
wondered whether some hardware might have trouble with (say) windows that
are not a multiple of 4 pixels wide. But what I want is "accurate to the
nearest pixel" - and I'd be happy to have the spec say that.
> I think we should keep it simple. No guarantees about preservation of
> aspect ratio. If the app wants to do the right thing, the app should
> query both getDrawingBufferSize and canvas.clientWidth/clientHeight
> depending on the values needed.
But then, we leave ourselves open to bad drivers that when asked for a
1024x512 return you a 1024x32 and stretch it to fill the canvas. Since we
can't tolerate that case, all applications are forced to repeatedly try to
create canvases of god-knows-what random sizes in an effort to get back
something they can live with that won't stretch or squash their data to an
The specification absolutely has to specify some sort of rule as to what
the system will do when there isn't enough memory - and since it's going
to rescale the render buffer to fit the canvas, preserving the aspect
ratio is the rational choice.
You are currently subscribed to firstname.lastname@example.org.
To unsubscribe, send an email to email@example.com with
the following command in the body of your email: