Commit ff74d224 authored by Rafael Cintron's avatar Rafael Cintron Committed by Commit Bot

Eliminate temporary std::vector in GetNumericHelper and DoGetFramebufferAttachmentParameter

GetNumericHelper and DoGetFramebufferAttachmentParameter were
previously allocating a std::vector of bufsize size and using it
as scratch space before copying the result to the output parameter.

With this change, GetNumericHelper and DoGetFramebufferAttachmentParameter
are modified to write directly into the output parameter.

Bug: 1057747
Change-Id: If19d353a9f7d0bc9aa513deede15afad5c05b67f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2084111Reviewed-by: default avatarGeoff Lang <geofflang@chromium.org>
Commit-Queue: Rafael Cintron <rafael.cintron@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#746805}
parent edb19ed6
......@@ -384,22 +384,15 @@ class GPU_GLES2_EXPORT GLES2DecoderPassthroughImpl : public GLES2Decoder {
GLsizei* length,
T* params,
GLGetFunction get_call) {
// Create a scratch buffer to hold the result of the query
std::vector<T> scratch_params(bufsize);
get_call(pname, bufsize, length, scratch_params.data());
get_call(pname, bufsize, length, params);
// Update the results of the query, if needed
error::Error error =
PatchGetNumericResults(pname, *length, scratch_params.data());
const error::Error error = PatchGetNumericResults(pname, *length, params);
if (error != error::kNoError) {
*length = 0;
return error;
}
// Copy into the destination
DCHECK(*length <= bufsize);
std::copy(scratch_params.data(), scratch_params.data() + *length, params);
return error::kNoError;
}
......
......@@ -1680,11 +1680,8 @@ error::Error GLES2DecoderPassthroughImpl::DoGetFramebufferAttachmentParameteriv(
CheckErrorCallbackState();
// Create a scratch buffer to hold the result of the query
std::vector<GLint> scratch_params(bufsize);
api()->glGetFramebufferAttachmentParameterivRobustANGLEFn(
target, updated_attachment, pname, bufsize, length,
scratch_params.data());
target, updated_attachment, pname, bufsize, length, params);
if (CheckErrorCallbackState()) {
DCHECK(*length == 0);
......@@ -1692,17 +1689,13 @@ error::Error GLES2DecoderPassthroughImpl::DoGetFramebufferAttachmentParameteriv(
}
// Update the results of the query, if needed
error::Error error = PatchGetFramebufferAttachmentParameter(
target, updated_attachment, pname, *length, scratch_params.data());
const error::Error error = PatchGetFramebufferAttachmentParameter(
target, updated_attachment, pname, *length, params);
if (error != error::kNoError) {
*length = 0;
return error;
}
// Copy into the destination
DCHECK(*length < bufsize);
std::copy(scratch_params.data(), scratch_params.data() + *length, params);
return error::kNoError;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment