Skip to content

Commit 40a6dda

Browse files
committed
#2696 Viewer crashes on gestures : use setDimensions for mFullWidth/mFullHeight
1 parent f9e2413 commit 40a6dda

10 files changed

+73
-86
lines changed

indra/llrender/llgltexture.cpp

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,9 @@ LLGLTexture::LLGLTexture(bool usemipmaps)
3636
LLGLTexture::LLGLTexture(const U32 width, const U32 height, const U8 components, bool usemipmaps)
3737
{
3838
init();
39-
mFullWidth = width ;
40-
mFullHeight = height ;
39+
setDimensions(width, height);
4140
mUseMipMaps = usemipmaps;
42-
mComponents = components ;
43-
setTexelsPerImage();
41+
mComponents = components;
4442
}
4543

4644
LLGLTexture::LLGLTexture(const LLImageRaw* raw, bool usemipmaps)
@@ -49,10 +47,8 @@ LLGLTexture::LLGLTexture(const LLImageRaw* raw, bool usemipmaps)
4947
mUseMipMaps = usemipmaps ;
5048
// Create an empty image of the specified size and width
5149
mGLTexturep = new LLImageGL(raw, usemipmaps) ;
52-
mFullWidth = mGLTexturep->getWidth();
53-
mFullHeight = mGLTexturep->getHeight();
50+
setDimensions(mGLTexturep->getWidth(), mGLTexturep->getHeight());
5451
mComponents = mGLTexturep->getComponents();
55-
setTexelsPerImage();
5652
}
5753

5854
LLGLTexture::~LLGLTexture()
@@ -130,7 +126,7 @@ void LLGLTexture::generateGLTexture()
130126
{
131127
if(mGLTexturep.isNull())
132128
{
133-
mGLTexturep = new LLImageGL(mFullWidth, mFullHeight, mComponents, mUseMipMaps) ;
129+
mGLTexturep = new LLImageGL(getFullWidth(), getFullHeight(), mComponents, mUseMipMaps) ;
134130
}
135131
}
136132

@@ -159,10 +155,8 @@ bool LLGLTexture::createGLTexture(S32 discard_level, const LLImageRaw* imageraw,
159155

160156
if(ret)
161157
{
162-
mFullWidth = mGLTexturep->getCurrentWidth() ;
163-
mFullHeight = mGLTexturep->getCurrentHeight() ;
164-
mComponents = mGLTexturep->getComponents() ;
165-
setTexelsPerImage();
158+
setDimensions(mGLTexturep->getCurrentWidth(), mGLTexturep->getCurrentHeight());
159+
mComponents = mGLTexturep->getComponents();
166160
}
167161

168162
return ret ;
@@ -447,11 +441,11 @@ void LLGLTexture::destroyGLTexture()
447441
}
448442
}
449443

450-
void LLGLTexture::setTexelsPerImage()
444+
void LLGLTexture::setDimensions(U32 width, U32 height)
451445
{
452-
U32 fullwidth = llmin(mFullWidth,U32(MAX_IMAGE_SIZE_DEFAULT));
453-
U32 fullheight = llmin(mFullHeight,U32(MAX_IMAGE_SIZE_DEFAULT));
454-
mTexelsPerImage = (U32)fullwidth * fullheight;
446+
mFullWidth = width;
447+
mFullHeight = height;
448+
mTexelsPerImage = llmin(width, MAX_IMAGE_SIZE_DEFAULT) * llmin(height, MAX_IMAGE_SIZE_DEFAULT);
455449
}
456450

457451
static LLUUID sStubUUID;

indra/llrender/llgltexture.h

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,8 @@ class LLImageRaw;
4040
class LLGLTexture : public LLTexture
4141
{
4242
public:
43-
enum
44-
{
45-
MAX_IMAGE_SIZE_DEFAULT = 2048,
46-
INVALID_DISCARD_LEVEL = 0x7fff
47-
};
43+
static const U32 MAX_IMAGE_SIZE_DEFAULT = 2048;
44+
static const U32 INVALID_DISCARD_LEVEL = 0x7fff;
4845

4946
enum EBoostLevel
5047
{
@@ -104,6 +101,7 @@ class LLGLTexture : public LLTexture
104101

105102
S32 getFullWidth() const { return mFullWidth; }
106103
S32 getFullHeight() const { return mFullHeight; }
104+
U32 getTexelsPerImage() const { return mTexelsPerImage; }
107105

108106
void generateGLTexture() ;
109107
void destroyGLTexture() ;
@@ -176,28 +174,27 @@ class LLGLTexture : public LLTexture
176174
void init();
177175

178176
protected:
179-
void setTexelsPerImage();
177+
void setDimensions(U32 width, U32 height);
178+
void setTexelsPerImage(U32 tpi) { mTexelsPerImage = tpi; }
180179

181180
public:
182181
/*virtual*/ LLImageGL* getGLTexture() const ;
183182

184183
protected:
185184
S32 mBoostLevel; // enum describing priority level
186-
U32 mFullWidth;
187-
U32 mFullHeight;
188185
bool mUseMipMaps;
189186
S8 mComponents;
190-
U32 mTexelsPerImage; // Texels per image.
191187
mutable S8 mNeedsGLTexture;
192188

193189
//GL texture
194190
LLPointer<LLImageGL> mGLTexturep ;
195191
S8 mDontDiscard; // Keep full res version of this image (for UI, etc)
196-
197-
protected:
198192
LLGLTextureState mTextureState ;
199193

200-
194+
private:
195+
U32 mFullWidth;
196+
U32 mFullHeight;
197+
U32 mTexelsPerImage;
201198
};
202199

203200
#endif // LL_GL_TEXTURE_H

indra/newview/lldynamictexture.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void LLViewerDynamicTexture::generateGLTexture(LLGLint internal_format, LLGLenum
9595
LL_ERRS() << "Bad number of components in dynamic texture: " << mComponents << LL_ENDL;
9696
}
9797

98-
LLPointer<LLImageRaw> raw_image = new LLImageRaw(mFullWidth, mFullHeight, mComponents);
98+
LLPointer<LLImageRaw> raw_image = new LLImageRaw(getFullWidth(), getFullHeight(), mComponents);
9999
if (internal_format >= 0)
100100
{
101101
setExplicitFormat(internal_format, primary_format, type_format, swap_bytes);
@@ -132,7 +132,7 @@ void LLViewerDynamicTexture::preRender(bool clear_depth)
132132
mCamera.setView(camera->getView());
133133
mCamera.setNear(camera->getNear());
134134

135-
glViewport(mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight);
135+
glViewport(mOrigin.mX, mOrigin.mY, getFullWidth(), getFullHeight());
136136
if (clear_depth)
137137
{
138138
glClear(GL_DEPTH_BUFFER_BIT);
@@ -160,7 +160,7 @@ void LLViewerDynamicTexture::postRender(bool success)
160160
generateGLTexture() ;
161161
}
162162

163-
success = mGLTexturep->setSubImageFromFrameBuffer(0, 0, mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight);
163+
success = mGLTexturep->setSubImageFromFrameBuffer(0, 0, mOrigin.mX, mOrigin.mY, getFullWidth(), getFullHeight());
164164
}
165165
}
166166

indra/newview/lldynamictexture.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class LLViewerDynamicTexture : public LLViewerTexture
6767
S32 getOriginX() const { return mOrigin.mX; }
6868
S32 getOriginY() const { return mOrigin.mY; }
6969

70-
S32 getSize() { return mFullWidth * mFullHeight * mComponents; }
70+
S32 getSize() { return getFullWidth() * getFullHeight() * mComponents; }
7171

7272
virtual bool needsRender() { return true; }
7373
virtual void preRender(bool clear_depth = true);

indra/newview/llfloaterbvhpreview.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ bool LLPreviewAnimation::render()
11011101
gGL.matrixMode(LLRender::MM_PROJECTION);
11021102
gGL.pushMatrix();
11031103
gGL.loadIdentity();
1104-
gGL.ortho(0.0f, (F32)mFullWidth, 0.0f, (F32)mFullHeight, -1.0f, 1.0f);
1104+
gGL.ortho(0.0f, (F32)getFullWidth(), 0.0f, (F32)getFullHeight(), -1.0f, 1.0f);
11051105

11061106
gGL.matrixMode(LLRender::MM_MODELVIEW);
11071107
gGL.pushMatrix();
@@ -1113,7 +1113,7 @@ bool LLPreviewAnimation::render()
11131113
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
11141114
gGL.color4f(0.15f, 0.2f, 0.3f, 1.f);
11151115

1116-
gl_rect_2d_simple( mFullWidth, mFullHeight );
1116+
gl_rect_2d_simple(getFullWidth(), getFullHeight());
11171117

11181118
gGL.matrixMode(LLRender::MM_PROJECTION);
11191119
gGL.popMatrix();
@@ -1137,8 +1137,8 @@ bool LLPreviewAnimation::render()
11371137
target_pos + (mCameraOffset * av_rot) ); // point of interest
11381138

11391139
camera->setViewNoBroadcast(LLViewerCamera::getInstance()->getDefaultFOV() / mCameraZoom);
1140-
camera->setAspect((F32) mFullWidth / (F32) mFullHeight);
1141-
camera->setPerspective(false, mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight, false);
1140+
camera->setAspect((F32)getFullWidth() / (F32)getFullHeight());
1141+
camera->setPerspective(false, mOrigin.mX, mOrigin.mY, getFullWidth(), getFullHeight(), false);
11421142

11431143
//SJB: Animation is updated in LLVOAvatar::updateCharacter
11441144

indra/newview/llfloaterimagepreview.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ bool LLImagePreviewAvatar::render()
681681
gGL.matrixMode(LLRender::MM_PROJECTION);
682682
gGL.pushMatrix();
683683
gGL.loadIdentity();
684-
gGL.ortho(0.0f, (F32)mFullWidth, 0.0f, (F32)mFullHeight, -1.0f, 1.0f);
684+
gGL.ortho(0.0f, (F32)getFullWidth(), 0.0f, (F32)getFullHeight(), -1.0f, 1.0f);
685685

686686
gGL.matrixMode(LLRender::MM_MODELVIEW);
687687
gGL.pushMatrix();
@@ -693,7 +693,7 @@ bool LLImagePreviewAvatar::render()
693693

694694
gUIProgram.bind();
695695

696-
gl_rect_2d_simple( mFullWidth, mFullHeight );
696+
gl_rect_2d_simple(getFullWidth(), getFullHeight());
697697

698698
gGL.matrixMode(LLRender::MM_PROJECTION);
699699
gGL.popMatrix();
@@ -715,9 +715,9 @@ bool LLImagePreviewAvatar::render()
715715

716716
stop_glerror();
717717

718-
LLViewerCamera::getInstance()->setAspect((F32)mFullWidth / mFullHeight);
718+
LLViewerCamera::getInstance()->setAspect((F32)getFullWidth() / getFullHeight());
719719
LLViewerCamera::getInstance()->setView(LLViewerCamera::getInstance()->getDefaultFOV() / mCameraZoom);
720-
LLViewerCamera::getInstance()->setPerspective(false, mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight, false);
720+
LLViewerCamera::getInstance()->setPerspective(false, mOrigin.mX, mOrigin.mY, getFullWidth(), getFullHeight(), false);
721721

722722
LLVertexBuffer::unbind();
723723
avatarp->updateLOD();
@@ -885,7 +885,7 @@ bool LLImagePreviewSculpted::render()
885885
gGL.matrixMode(LLRender::MM_PROJECTION);
886886
gGL.pushMatrix();
887887
gGL.loadIdentity();
888-
gGL.ortho(0.0f, (F32)mFullWidth, 0.0f, (F32)mFullHeight, -1.0f, 1.0f);
888+
gGL.ortho(0.0f, (F32)getFullWidth(), 0.0f, (F32)getFullHeight(), -1.0f, 1.0f);
889889

890890
gGL.matrixMode(LLRender::MM_MODELVIEW);
891891
gGL.pushMatrix();
@@ -895,7 +895,7 @@ bool LLImagePreviewSculpted::render()
895895

896896
gUIProgram.bind();
897897

898-
gl_rect_2d_simple( mFullWidth, mFullHeight );
898+
gl_rect_2d_simple(getFullWidth(), getFullHeight());
899899

900900
gGL.matrixMode(LLRender::MM_PROJECTION);
901901
gGL.popMatrix();
@@ -918,9 +918,9 @@ bool LLImagePreviewSculpted::render()
918918

919919
stop_glerror();
920920

921-
LLViewerCamera::getInstance()->setAspect((F32) mFullWidth / mFullHeight);
921+
LLViewerCamera::getInstance()->setAspect((F32)getFullWidth() / getFullHeight());
922922
LLViewerCamera::getInstance()->setView(LLViewerCamera::getInstance()->getDefaultFOV() / mCameraZoom);
923-
LLViewerCamera::getInstance()->setPerspective(false, mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight, false);
923+
LLViewerCamera::getInstance()->setPerspective(false, mOrigin.mX, mOrigin.mY, getFullWidth(), getFullHeight(), false);
924924

925925
const LLVolumeFace &vf = mVolume->getVolumeFace(0);
926926
U32 num_indices = vf.mNumIndices;

indra/newview/llgltfmaterialpreviewmgr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,8 @@ bool LLGLTFPreviewTexture::render()
462462
// Set up camera and viewport
463463
const LLVector3 origin(0.0, 0.0, 0.0);
464464
camera.lookAt(origin, object_position);
465-
camera.setAspect((F32)(mFullHeight / mFullWidth));
466-
const LLRect texture_rect(0, mFullHeight, mFullWidth, 0);
465+
camera.setAspect((F32)getFullHeight() / getFullWidth());
466+
const LLRect texture_rect(0, getFullHeight(), getFullWidth(), 0);
467467
camera.setPerspective(NOT_FOR_SELECTION, texture_rect.mLeft, texture_rect.mBottom, texture_rect.getWidth(), texture_rect.getHeight(), false, camera.getNear(), MAX_FAR_CLIP*2.f);
468468

469469
// Generate sphere object on-the-fly. Discard afterwards. (Vertex buffer is

indra/newview/lltoolmorph.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ bool LLVisualParamHint::render()
189189
gGL.matrixMode(LLRender::MM_PROJECTION);
190190
gGL.pushMatrix();
191191
gGL.loadIdentity();
192-
gGL.ortho(0.0f, (F32)mFullWidth, 0.0f, (F32)mFullHeight, -1.0f, 1.0f);
192+
gGL.ortho(0.0f, (F32)getFullWidth(), 0.0f, (F32)getFullHeight(), -1.0f, 1.0f);
193193

194194
gGL.matrixMode(LLRender::MM_MODELVIEW);
195195
gGL.pushMatrix();
@@ -199,7 +199,7 @@ bool LLVisualParamHint::render()
199199

200200
LLGLSUIDefault gls_ui;
201201
//LLGLState::verify(true);
202-
mBackgroundp->draw(0, 0, mFullWidth, mFullHeight);
202+
mBackgroundp->draw(0, 0, getFullWidth(), getFullHeight());
203203

204204
gGL.matrixMode(LLRender::MM_PROJECTION);
205205
gGL.popMatrix();
@@ -238,13 +238,13 @@ bool LLVisualParamHint::render()
238238

239239
gGL.flush();
240240

241-
LLViewerCamera::getInstance()->setAspect((F32)mFullWidth / (F32)mFullHeight);
241+
LLViewerCamera::getInstance()->setAspect((F32)getFullWidth() / (F32)getFullHeight());
242242
LLViewerCamera::getInstance()->setOriginAndLookAt(
243243
camera_pos, // camera
244244
LLVector3::z_axis, // up
245245
target_pos ); // point of interest
246246

247-
LLViewerCamera::getInstance()->setPerspective(false, mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight, false);
247+
LLViewerCamera::getInstance()->setPerspective(false, mOrigin.mX, mOrigin.mY, getFullWidth(), getFullHeight(), false);
248248

249249
if (gAgentAvatarp->mDrawable.notNull())
250250
{
@@ -288,18 +288,18 @@ void LLVisualParamHint::draw(F32 alpha)
288288
gGL.begin(LLRender::TRIANGLES);
289289
{
290290
gGL.texCoord2i(0, 1);
291-
gGL.vertex2i(0, mFullHeight);
291+
gGL.vertex2i(0, getFullHeight());
292292
gGL.texCoord2i(0, 0);
293293
gGL.vertex2i(0, 0);
294294
gGL.texCoord2i(1, 0);
295-
gGL.vertex2i(mFullWidth, 0);
295+
gGL.vertex2i(getFullWidth(), 0);
296296

297297
gGL.texCoord2i(0, 1);
298-
gGL.vertex2i(0, mFullHeight);
298+
gGL.vertex2i(0, getFullHeight());
299299
gGL.texCoord2i(1, 0);
300-
gGL.vertex2i(mFullWidth, 0);
300+
gGL.vertex2i(getFullWidth(), 0);
301301
gGL.texCoord2i(1, 1);
302-
gGL.vertex2i(mFullWidth, mFullHeight);
302+
gGL.vertex2i(getFullWidth(), getFullHeight());
303303
}
304304
gGL.end();
305305

0 commit comments

Comments
 (0)