Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 1395134

Browse files
null77Commit Bot
authored andcommitted
Remove more uses of gl::ErrorOrResult.
Only gl::LinkResult remains. Bug: angleproject:2753 Change-Id: I5e9c68c11453e8ab9db4908451957d7b3db0b110 Reviewed-on: https://chromium-review.googlesource.com/c/1254044 Reviewed-by: Geoff Lang <[email protected]> Reviewed-by: Frank Henigman <[email protected]> Commit-Queue: Jamie Madill <[email protected]>
1 parent 4d422c2 commit 1395134

File tree

10 files changed

+144
-137
lines changed

10 files changed

+144
-137
lines changed

src/libANGLE/Context.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -753,15 +753,16 @@ GLuint Context::createRenderbuffer()
753753
return mState.mRenderbuffers->createRenderbuffer();
754754
}
755755

756+
void Context::tryGenPaths(GLsizei range, GLuint *createdOut)
757+
{
758+
ANGLE_CONTEXT_TRY(mState.mPaths->createPaths(mImplementation.get(), range, createdOut));
759+
}
760+
756761
GLuint Context::genPaths(GLsizei range)
757762
{
758-
auto resultOrError = mState.mPaths->createPaths(mImplementation.get(), range);
759-
if (resultOrError.isError())
760-
{
761-
handleError(resultOrError.getError());
762-
return 0;
763-
}
764-
return resultOrError.getResult();
763+
GLuint created = 0;
764+
tryGenPaths(range, &created);
765+
return created;
765766
}
766767

767768
// Returns an unused framebuffer name

src/libANGLE/Context.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1656,6 +1656,9 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
16561656
void detachSampler(GLuint sampler);
16571657
void detachProgramPipeline(GLuint pipeline);
16581658

1659+
// A small helper method to facilitate using the ANGLE_CONTEXT_TRY macro.
1660+
void tryGenPaths(GLsizei range, GLuint *createdOut);
1661+
16591662
void initRendererString();
16601663
void initVersionStrings();
16611664
void initExtensionStrings();

src/libANGLE/ResourceManager.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,10 @@ PathManager::PathManager()
345345
{
346346
}
347347

348-
ErrorOrResult<GLuint> PathManager::createPaths(rx::GLImplFactory *factory, GLsizei range)
348+
Error PathManager::createPaths(rx::GLImplFactory *factory, GLsizei range, GLuint *createdOut)
349349
{
350+
*createdOut = 0;
351+
350352
// Allocate client side handles.
351353
const GLuint client = mHandleAllocator.allocateRange(static_cast<GLuint>(range));
352354
if (client == HandleRangeAllocator::kInvalidHandle)
@@ -365,7 +367,8 @@ ErrorOrResult<GLuint> PathManager::createPaths(rx::GLImplFactory *factory, GLsiz
365367
const auto id = client + i;
366368
mPaths.assign(id, new Path(impl));
367369
}
368-
return client;
370+
*createdOut = client;
371+
return NoError();
369372
}
370373

371374
void PathManager::deletePaths(GLuint first, GLsizei range)

src/libANGLE/ResourceManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ class PathManager : public ResourceManagerBase<HandleRangeAllocator>
243243
public:
244244
PathManager();
245245

246-
ErrorOrResult<GLuint> createPaths(rx::GLImplFactory *factory, GLsizei range);
246+
Error createPaths(rx::GLImplFactory *factory, GLsizei range, GLuint *numCreated);
247247
void deletePaths(GLuint first, GLsizei range);
248248
Path *getPath(GLuint handle) const;
249249
bool hasPath(GLuint handle) const;

src/libANGLE/renderer/gl/BlitGL.cpp

Lines changed: 46 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -468,22 +468,23 @@ gl::Error BlitGL::blitColorBufferWithShader(const gl::Framebuffer *source,
468468
return gl::NoError();
469469
}
470470

471-
gl::ErrorOrResult<bool> BlitGL::copySubTexture(const gl::Context *context,
472-
TextureGL *source,
473-
size_t sourceLevel,
474-
GLenum sourceComponentType,
475-
TextureGL *dest,
476-
gl::TextureTarget destTarget,
477-
size_t destLevel,
478-
GLenum destComponentType,
479-
const gl::Extents &sourceSize,
480-
const gl::Rectangle &sourceArea,
481-
const gl::Offset &destOffset,
482-
bool needsLumaWorkaround,
483-
GLenum lumaFormat,
484-
bool unpackFlipY,
485-
bool unpackPremultiplyAlpha,
486-
bool unpackUnmultiplyAlpha)
471+
gl::Error BlitGL::copySubTexture(const gl::Context *context,
472+
TextureGL *source,
473+
size_t sourceLevel,
474+
GLenum sourceComponentType,
475+
TextureGL *dest,
476+
gl::TextureTarget destTarget,
477+
size_t destLevel,
478+
GLenum destComponentType,
479+
const gl::Extents &sourceSize,
480+
const gl::Rectangle &sourceArea,
481+
const gl::Offset &destOffset,
482+
bool needsLumaWorkaround,
483+
GLenum lumaFormat,
484+
bool unpackFlipY,
485+
bool unpackPremultiplyAlpha,
486+
bool unpackUnmultiplyAlpha,
487+
bool *copySucceededOut)
487488
{
488489
ASSERT(source->getType() == gl::TextureType::_2D);
489490
ANGLE_TRY(initializeResources());
@@ -496,7 +497,8 @@ gl::ErrorOrResult<bool> BlitGL::copySubTexture(const gl::Context *context,
496497
GLenum status = mFunctions->checkFramebufferStatus(GL_FRAMEBUFFER);
497498
if (status != GL_FRAMEBUFFER_COMPLETE)
498499
{
499-
return false;
500+
*copySucceededOut = false;
501+
return gl::NoError();
500502
}
501503

502504
BlitProgramType blitProgramType = getBlitProgramType(sourceComponentType, destComponentType);
@@ -566,7 +568,8 @@ gl::ErrorOrResult<bool> BlitGL::copySubTexture(const gl::Context *context,
566568
mStateManager->bindVertexArray(mVAO, 0);
567569
mFunctions->drawArrays(GL_TRIANGLES, 0, 3);
568570

569-
return true;
571+
*copySucceededOut = true;
572+
return gl::NoError();
570573
}
571574

572575
gl::Error BlitGL::copySubTextureCPUReadback(const gl::Context *context,
@@ -653,13 +656,14 @@ gl::Error BlitGL::copySubTextureCPUReadback(const gl::Context *context,
653656
return gl::NoError();
654657
}
655658

656-
gl::ErrorOrResult<bool> BlitGL::copyTexSubImage(TextureGL *source,
657-
size_t sourceLevel,
658-
TextureGL *dest,
659-
gl::TextureTarget destTarget,
660-
size_t destLevel,
661-
const gl::Rectangle &sourceArea,
662-
const gl::Offset &destOffset)
659+
gl::Error BlitGL::copyTexSubImage(TextureGL *source,
660+
size_t sourceLevel,
661+
TextureGL *dest,
662+
gl::TextureTarget destTarget,
663+
size_t destLevel,
664+
const gl::Rectangle &sourceArea,
665+
const gl::Offset &destOffset,
666+
bool *copySucceededOut)
663667
{
664668
ANGLE_TRY(initializeResources());
665669

@@ -670,7 +674,8 @@ gl::ErrorOrResult<bool> BlitGL::copyTexSubImage(TextureGL *source,
670674
GLenum status = mFunctions->checkFramebufferStatus(GL_FRAMEBUFFER);
671675
if (status != GL_FRAMEBUFFER_COMPLETE)
672676
{
673-
return false;
677+
*copySucceededOut = false;
678+
return gl::NoError();
674679
}
675680

676681
mStateManager->bindTexture(dest->getType(), dest->getTextureID());
@@ -679,13 +684,15 @@ gl::ErrorOrResult<bool> BlitGL::copyTexSubImage(TextureGL *source,
679684
destOffset.y, sourceArea.x, sourceArea.y, sourceArea.width,
680685
sourceArea.height);
681686

682-
return true;
687+
*copySucceededOut = true;
688+
return gl::NoError();
683689
}
684690

685-
gl::ErrorOrResult<bool> BlitGL::clearRenderableTexture(TextureGL *source,
686-
GLenum sizedInternalFormat,
687-
int numTextureLayers,
688-
const gl::ImageIndex &imageIndex)
691+
gl::Error BlitGL::clearRenderableTexture(TextureGL *source,
692+
GLenum sizedInternalFormat,
693+
int numTextureLayers,
694+
const gl::ImageIndex &imageIndex,
695+
bool *clearSucceededOut)
689696
{
690697
ANGLE_TRY(initializeResources());
691698

@@ -713,7 +720,8 @@ gl::ErrorOrResult<bool> BlitGL::clearRenderableTexture(TextureGL *source,
713720
else
714721
{
715722
UnbindAttachments(mFunctions, GL_FRAMEBUFFER, bindTargets);
716-
return false;
723+
*clearSucceededOut = false;
724+
return gl::NoError();
717725
}
718726
}
719727
else
@@ -737,7 +745,8 @@ gl::ErrorOrResult<bool> BlitGL::clearRenderableTexture(TextureGL *source,
737745
else
738746
{
739747
UnbindAttachments(mFunctions, GL_FRAMEBUFFER, bindTargets);
740-
return false;
748+
*clearSucceededOut = false;
749+
return gl::NoError();
741750
}
742751
}
743752
else
@@ -767,14 +776,16 @@ gl::ErrorOrResult<bool> BlitGL::clearRenderableTexture(TextureGL *source,
767776
else
768777
{
769778
UnbindAttachments(mFunctions, GL_FRAMEBUFFER, bindTargets);
770-
return false;
779+
*clearSucceededOut = false;
780+
return gl::NoError();
771781
}
772782
}
773783
}
774784
}
775785

776786
UnbindAttachments(mFunctions, GL_FRAMEBUFFER, bindTargets);
777-
return true;
787+
*clearSucceededOut = true;
788+
return gl::NoError();
778789
}
779790

780791
gl::Error BlitGL::clearRenderbuffer(RenderbufferGL *source, GLenum sizedInternalFormat)

src/libANGLE/renderer/gl/BlitGL.h

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,23 @@ class BlitGL : angle::NonCopyable
6666
const gl::Rectangle &destArea,
6767
GLenum filter);
6868

69-
gl::ErrorOrResult<bool> copySubTexture(const gl::Context *context,
70-
TextureGL *source,
71-
size_t sourceLevel,
72-
GLenum sourceComponentType,
73-
TextureGL *dest,
74-
gl::TextureTarget destTarget,
75-
size_t destLevel,
76-
GLenum destComponentType,
77-
const gl::Extents &sourceSize,
78-
const gl::Rectangle &sourceArea,
79-
const gl::Offset &destOffset,
80-
bool needsLumaWorkaround,
81-
GLenum lumaFormat,
82-
bool unpackFlipY,
83-
bool unpackPremultiplyAlpha,
84-
bool unpackUnmultiplyAlpha);
69+
gl::Error copySubTexture(const gl::Context *context,
70+
TextureGL *source,
71+
size_t sourceLevel,
72+
GLenum sourceComponentType,
73+
TextureGL *dest,
74+
gl::TextureTarget destTarget,
75+
size_t destLevel,
76+
GLenum destComponentType,
77+
const gl::Extents &sourceSize,
78+
const gl::Rectangle &sourceArea,
79+
const gl::Offset &destOffset,
80+
bool needsLumaWorkaround,
81+
GLenum lumaFormat,
82+
bool unpackFlipY,
83+
bool unpackPremultiplyAlpha,
84+
bool unpackUnmultiplyAlpha,
85+
bool *copySucceededOut);
8586

8687
gl::Error copySubTextureCPUReadback(const gl::Context *context,
8788
TextureGL *source,
@@ -98,18 +99,20 @@ class BlitGL : angle::NonCopyable
9899
bool unpackPremultiplyAlpha,
99100
bool unpackUnmultiplyAlpha);
100101

101-
gl::ErrorOrResult<bool> copyTexSubImage(TextureGL *source,
102-
size_t sourceLevel,
103-
TextureGL *dest,
104-
gl::TextureTarget destTarget,
105-
size_t destLevel,
106-
const gl::Rectangle &sourceArea,
107-
const gl::Offset &destOffset);
108-
109-
gl::ErrorOrResult<bool> clearRenderableTexture(TextureGL *source,
110-
GLenum sizedInternalFormat,
111-
int numTextureLayers,
112-
const gl::ImageIndex &imageIndex);
102+
gl::Error copyTexSubImage(TextureGL *source,
103+
size_t sourceLevel,
104+
TextureGL *dest,
105+
gl::TextureTarget destTarget,
106+
size_t destLevel,
107+
const gl::Rectangle &sourceArea,
108+
const gl::Offset &destOffset,
109+
bool *copySucceededOut);
110+
111+
gl::Error clearRenderableTexture(TextureGL *source,
112+
GLenum sizedInternalFormat,
113+
int numTextureLayers,
114+
const gl::ImageIndex &imageIndex,
115+
bool *clearSucceededOut);
113116

114117
gl::Error clearRenderbuffer(RenderbufferGL *source, GLenum sizedInternalFormat);
115118

src/libANGLE/renderer/gl/FramebufferGL.cpp

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -482,33 +482,21 @@ Error FramebufferGL::readPixels(const gl::Context *context,
482482
bool cannotSetDesiredRowLength =
483483
packState.rowLength && !GetImplAs<ContextGL>(context)->getNativeExtensions().packSubimage;
484484

485-
gl::Error retVal = gl::NoError();
486485
if (cannotSetDesiredRowLength || useOverlappingRowsWorkaround)
487486
{
488-
retVal = readPixelsRowByRow(context, area, readFormat, readType, packState, pixels);
487+
return readPixelsRowByRow(context, area, readFormat, readType, packState, pixels);
489488
}
490-
else
491-
{
492-
gl::ErrorOrResult<bool> useLastRowPaddingWorkaround = false;
493-
if (workarounds.packLastRowSeparatelyForPaddingInclusion)
494-
{
495-
useLastRowPaddingWorkaround = ShouldApplyLastRowPaddingWorkaround(
496-
gl::Extents(area.width, area.height, 1), packState, packBuffer, readFormat,
497-
readType, false, pixels);
498-
}
499489

500-
if (useLastRowPaddingWorkaround.isError())
501-
{
502-
retVal = useLastRowPaddingWorkaround.getError();
503-
}
504-
else
505-
{
506-
retVal = readPixelsAllAtOnce(context, area, readFormat, readType, packState, pixels,
507-
useLastRowPaddingWorkaround.getResult());
508-
}
490+
bool useLastRowPaddingWorkaround = false;
491+
if (workarounds.packLastRowSeparatelyForPaddingInclusion)
492+
{
493+
ANGLE_TRY(ShouldApplyLastRowPaddingWorkaround(gl::Extents(area.width, area.height, 1),
494+
packState, packBuffer, readFormat, readType,
495+
false, pixels, &useLastRowPaddingWorkaround));
509496
}
510497

511-
return retVal;
498+
return readPixelsAllAtOnce(context, area, readFormat, readType, packState, pixels,
499+
useLastRowPaddingWorkaround);
512500
}
513501

514502
Error FramebufferGL::blit(const gl::Context *context,

0 commit comments

Comments
 (0)