Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(287)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp

Issue 1814263004: Remove create/delete methods from WebGraphicsContext3D. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@complex-casts
Patch Set: complex-create: rebase Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 } 245 }
246 246
247 Canvas2DLayerBridge::ImageInfo Canvas2DLayerBridge::createIOSurfaceBackedTexture () 247 Canvas2DLayerBridge::ImageInfo Canvas2DLayerBridge::createIOSurfaceBackedTexture ()
248 { 248 {
249 if (!m_imageInfoCache.isEmpty()) { 249 if (!m_imageInfoCache.isEmpty()) {
250 Canvas2DLayerBridge::ImageInfo info = m_imageInfoCache.last(); 250 Canvas2DLayerBridge::ImageInfo info = m_imageInfoCache.last();
251 m_imageInfoCache.removeLast(); 251 m_imageInfoCache.removeLast();
252 return info; 252 return info;
253 } 253 }
254 254
255 WebGraphicsContext3D* webContext = context();
256 gpu::gles2::GLES2Interface* gl = contextGL(); 255 gpu::gles2::GLES2Interface* gl = contextGL();
257 GLuint imageId = gl->CreateGpuMemoryBufferImageCHROMIUM(m_size.width(), m_si ze.height(), GL_BGRA_EXT, GC3D_SCANOUT_CHROMIUM); 256 GLuint imageId = gl->CreateGpuMemoryBufferImageCHROMIUM(m_size.width(), m_si ze.height(), GL_BGRA_EXT, GC3D_SCANOUT_CHROMIUM);
258 if (!imageId) 257 if (!imageId)
259 return Canvas2DLayerBridge::ImageInfo(); 258 return Canvas2DLayerBridge::ImageInfo();
260 259
261 GLuint textureId= webContext->createTexture(); 260 GLuint textureId;
262 if (!textureId) { 261 gl->GenTextures(1, &textureId);
263 gl->DestroyImageCHROMIUM(imageId);
264 return Canvas2DLayerBridge::ImageInfo();
265 }
266
267 GLenum target = GC3D_TEXTURE_RECTANGLE_ARB; 262 GLenum target = GC3D_TEXTURE_RECTANGLE_ARB;
268 gl->BindTexture(target, textureId); 263 gl->BindTexture(target, textureId);
269 gl->TexParameteri(target, GL_TEXTURE_MAG_FILTER, getGLFilter()); 264 gl->TexParameteri(target, GL_TEXTURE_MAG_FILTER, getGLFilter());
270 gl->TexParameteri(target, GL_TEXTURE_MIN_FILTER, getGLFilter()); 265 gl->TexParameteri(target, GL_TEXTURE_MIN_FILTER, getGLFilter());
271 gl->TexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 266 gl->TexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
272 gl->TexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 267 gl->TexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
273 gl->BindTexImage2DCHROMIUM(target, imageId); 268 gl->BindTexImage2DCHROMIUM(target, imageId);
274 269
275 return Canvas2DLayerBridge::ImageInfo(imageId, textureId); 270 return Canvas2DLayerBridge::ImageInfo(imageId, textureId);
276 } 271 }
277 272
278 void Canvas2DLayerBridge::deleteCHROMIUMImage(ImageInfo info) 273 void Canvas2DLayerBridge::deleteCHROMIUMImage(ImageInfo info)
279 { 274 {
280 WebGraphicsContext3D* webContext = context();
281 gpu::gles2::GLES2Interface* gl = contextGL(); 275 gpu::gles2::GLES2Interface* gl = contextGL();
282 if (gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) 276 if (gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR)
283 return; 277 return;
284 278
285 GLenum target = GC3D_TEXTURE_RECTANGLE_ARB; 279 GLenum target = GC3D_TEXTURE_RECTANGLE_ARB;
286 gl->BindTexture(target, info.m_textureId); 280 gl->BindTexture(target, info.m_textureId);
287 gl->ReleaseTexImage2DCHROMIUM(target, info.m_imageId); 281 gl->ReleaseTexImage2DCHROMIUM(target, info.m_imageId);
288 gl->DestroyImageCHROMIUM(info.m_imageId); 282 gl->DestroyImageCHROMIUM(info.m_imageId);
289 webContext->deleteTexture(info.m_textureId); 283 gl->DeleteTextures(1, &info.m_textureId);
290 gl->BindTexture(target, 0); 284 gl->BindTexture(target, 0);
291 285
292 resetSkiaTextureBinding(); 286 resetSkiaTextureBinding();
293 } 287 }
294 288
295 void Canvas2DLayerBridge::clearCHROMIUMImageCache() 289 void Canvas2DLayerBridge::clearCHROMIUMImageCache()
296 { 290 {
297 for (const auto& it : m_imageInfoCache) { 291 for (const auto& it : m_imageInfoCache) {
298 deleteCHROMIUMImage(it); 292 deleteCHROMIUMImage(it);
299 } 293 }
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 #endif // USE_IOSURFACE_FOR_2D_CANVAS 1001 #endif // USE_IOSURFACE_FOR_2D_CANVAS
1008 } 1002 }
1009 1003
1010 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event) 1004 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event)
1011 { 1005 {
1012 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, ("Canvas.Hib ernationEvents", HibernationEventCount)); 1006 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, ("Canvas.Hib ernationEvents", HibernationEventCount));
1013 hibernationHistogram.count(event); 1007 hibernationHistogram.count(event);
1014 } 1008 }
1015 1009
1016 } // namespace blink 1010 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698