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

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

Issue 1817323003: Revert of Remove create/delete methods from WebGraphicsContext3D. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@complex-casts
Patch Set: 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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 m_imageInfoCache.removeLast(); 251 m_imageInfoCache.removeLast();
252 return info; 252 return info;
253 } 253 }
254 254
255 WebGraphicsContext3D* webContext = context(); 255 WebGraphicsContext3D* webContext = context();
256 gpu::gles2::GLES2Interface* gl = contextGL(); 256 gpu::gles2::GLES2Interface* gl = contextGL();
257 GLuint imageId = gl->CreateGpuMemoryBufferImageCHROMIUM(m_size.width(), m_si ze.height(), GL_BGRA_EXT, GC3D_SCANOUT_CHROMIUM); 257 GLuint imageId = gl->CreateGpuMemoryBufferImageCHROMIUM(m_size.width(), m_si ze.height(), GL_BGRA_EXT, GC3D_SCANOUT_CHROMIUM);
258 if (!imageId) 258 if (!imageId)
259 return Canvas2DLayerBridge::ImageInfo(); 259 return Canvas2DLayerBridge::ImageInfo();
260 260
261 GLuint textureId; 261 GLuint textureId= webContext->createTexture();
262 gl->GenTextures(1, &textureId); 262 if (!textureId) {
263 gl->DestroyImageCHROMIUM(imageId);
264 return Canvas2DLayerBridge::ImageInfo();
265 }
266
263 GLenum target = GC3D_TEXTURE_RECTANGLE_ARB; 267 GLenum target = GC3D_TEXTURE_RECTANGLE_ARB;
264 gl->BindTexture(target, textureId); 268 gl->BindTexture(target, textureId);
265 gl->TexParameteri(target, GL_TEXTURE_MAG_FILTER, getGLFilter()); 269 gl->TexParameteri(target, GL_TEXTURE_MAG_FILTER, getGLFilter());
266 gl->TexParameteri(target, GL_TEXTURE_MIN_FILTER, getGLFilter()); 270 gl->TexParameteri(target, GL_TEXTURE_MIN_FILTER, getGLFilter());
267 gl->TexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 271 gl->TexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
268 gl->TexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 272 gl->TexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
269 gl->BindTexImage2DCHROMIUM(target, imageId); 273 gl->BindTexImage2DCHROMIUM(target, imageId);
270 274
271 return Canvas2DLayerBridge::ImageInfo(imageId, textureId); 275 return Canvas2DLayerBridge::ImageInfo(imageId, textureId);
272 } 276 }
273 277
274 void Canvas2DLayerBridge::deleteCHROMIUMImage(ImageInfo info) 278 void Canvas2DLayerBridge::deleteCHROMIUMImage(ImageInfo info)
275 { 279 {
276 WebGraphicsContext3D* webContext = context(); 280 WebGraphicsContext3D* webContext = context();
277 gpu::gles2::GLES2Interface* gl = contextGL(); 281 gpu::gles2::GLES2Interface* gl = contextGL();
278 if (gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) 282 if (gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR)
279 return; 283 return;
280 284
281 GLenum target = GC3D_TEXTURE_RECTANGLE_ARB; 285 GLenum target = GC3D_TEXTURE_RECTANGLE_ARB;
282 gl->BindTexture(target, info.m_textureId); 286 gl->BindTexture(target, info.m_textureId);
283 gl->ReleaseTexImage2DCHROMIUM(target, info.m_imageId); 287 gl->ReleaseTexImage2DCHROMIUM(target, info.m_imageId);
284 gl->DestroyImageCHROMIUM(info.m_imageId); 288 gl->DestroyImageCHROMIUM(info.m_imageId);
285 gl->DeleteTextures(1, &info.m_textureId); 289 webContext->deleteTexture(info.m_textureId);
286 gl->BindTexture(target, 0); 290 gl->BindTexture(target, 0);
287 291
288 resetSkiaTextureBinding(); 292 resetSkiaTextureBinding();
289 } 293 }
290 294
291 void Canvas2DLayerBridge::clearCHROMIUMImageCache() 295 void Canvas2DLayerBridge::clearCHROMIUMImageCache()
292 { 296 {
293 for (const auto& it : m_imageInfoCache) { 297 for (const auto& it : m_imageInfoCache) {
294 deleteCHROMIUMImage(it); 298 deleteCHROMIUMImage(it);
295 } 299 }
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 #endif // USE_IOSURFACE_FOR_2D_CANVAS 1007 #endif // USE_IOSURFACE_FOR_2D_CANVAS
1004 } 1008 }
1005 1009
1006 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event) 1010 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event)
1007 { 1011 {
1008 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, ("Canvas.Hib ernationEvents", HibernationEventCount)); 1012 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, ("Canvas.Hib ernationEvents", HibernationEventCount));
1009 hibernationHistogram.count(event); 1013 hibernationHistogram.count(event);
1010 } 1014 }
1011 1015
1012 } // namespace blink 1016 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698