201 {
203
205 VALIDATION_LOG <<
"Incorrect texture usage flags for setting contents on "
206 "this texture object.";
207 return false;
208 }
209
210 if (texture_gles.IsWrapped()) {
211 VALIDATION_LOG <<
"Cannot set the contents of a wrapped texture.";
212 return false;
213 }
214
215 const auto& tex_descriptor = texture_gles.GetTextureDescriptor();
216
217 if (tex_descriptor.size.IsEmpty()) {
218 return true;
219 }
220
221 if (!tex_descriptor.IsValid() ||
225 return false;
226 }
227
229
230 GLenum texture_type;
231 GLenum texture_target;
232 switch (tex_descriptor.type) {
234 texture_type = GL_TEXTURE_2D;
235 texture_target = GL_TEXTURE_2D;
236 break;
238 VALIDATION_LOG <<
"Multisample texture uploading is not supported for "
239 "the OpenGLES backend.";
240 return false;
242 texture_type = GL_TEXTURE_CUBE_MAP;
243 texture_target = GL_TEXTURE_CUBE_MAP_POSITIVE_X +
slice;
244 break;
246 texture_type = GL_TEXTURE_EXTERNAL_OES;
247 texture_target = GL_TEXTURE_EXTERNAL_OES;
248 break;
249 }
250
251 TexImage2DData
data = TexImage2DData(tex_descriptor.format,
source);
252 if (!
data.IsValid()) {
254 return false;
255 }
256
257 auto gl_handle = texture_gles.GetGLHandle();
258 if (!gl_handle.has_value()) {
260 << "Texture was collected before it could be uploaded to the GPU.";
261 return false;
262 }
263 const auto&
gl = reactor.GetProcTable();
264 gl.BindTexture(texture_type, gl_handle.value());
265 const GLvoid* tex_data =
266 data.buffer_view.buffer->OnGetContents() +
data.buffer_view.range.offset;
267
268
269
270 if (!texture_gles.IsSliceInitialized(
slice)) {
271 gl.TexImage2D(texture_target,
272 0u,
273 data.internal_format,
274 tex_descriptor.size.width,
275 tex_descriptor.size.height,
276 0u,
277 data.external_format,
279 nullptr
280 );
281 texture_gles.MarkSliceInitialized(
slice);
282 }
283
284 {
287 gl.PixelStorei(GL_UNPACK_ALIGNMENT, 1);
288 gl.TexSubImage2D(texture_target,
289 0u,
294 data.external_format,
296 tex_data
297
298 );
299 }
300 return true;
301}
const char * c_str() const
static TextureGLES & Cast(Texture &base)
constexpr size_t BytesPerPixelForPixelFormat(PixelFormat format)
static SkString to_string(int n)
std::shared_ptr< Texture > destination
constexpr Type GetY() const
Returns the Y coordinate of the upper left corner, equivalent to |GetOrigin().y|.
constexpr Type GetHeight() const
Returns the height of the rectangle, equivalent to |GetSize().height|.
constexpr T Area() const
Get the area of the rectangle, equivalent to |GetSize().Area()|.
constexpr Type GetX() const
Returns the X coordinate of the upper left corner, equivalent to |GetOrigin().x|.
constexpr Type GetWidth() const
Returns the width of the rectangle, equivalent to |GetSize().width|.
std::shared_ptr< const fml::Mapping > data
#define TRACE_EVENT1(category_group, name, arg1_name, arg1_val)