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

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

Issue 1974163003: Expose GpuMemoryBufferId through glGetImageivCHROMIUM. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 MailboxInfo& info = m_mailboxes.first(); 210 MailboxInfo& info = m_mailboxes.first();
211 info.m_mailbox.textureTarget = GC3D_TEXTURE_RECTANGLE_ARB; 211 info.m_mailbox.textureTarget = GC3D_TEXTURE_RECTANGLE_ARB;
212 gl->GenMailboxCHROMIUM(info.m_mailbox.name); 212 gl->GenMailboxCHROMIUM(info.m_mailbox.name);
213 gl->ProduceTextureDirectCHROMIUM(imageInfo.m_textureId, info.m_mailbox.textu reTarget, info.m_mailbox.name); 213 gl->ProduceTextureDirectCHROMIUM(imageInfo.m_textureId, info.m_mailbox.textu reTarget, info.m_mailbox.name);
214 info.m_mailbox.allowOverlay = true; 214 info.m_mailbox.allowOverlay = true;
215 215
216 const GLuint64 fenceSync = gl->InsertFenceSyncCHROMIUM(); 216 const GLuint64 fenceSync = gl->InsertFenceSyncCHROMIUM();
217 gl->Flush(); 217 gl->Flush();
218 gl->GenSyncTokenCHROMIUM(fenceSync, info.m_mailbox.syncToken); 218 gl->GenSyncTokenCHROMIUM(fenceSync, info.m_mailbox.syncToken);
219 info.m_mailbox.validSyncToken = true; 219 info.m_mailbox.validSyncToken = true;
220 info.m_mailbox.gpuMemoryBufferId = imageInfo.m_gpuMemoryBufferId;
220 221
221 info.m_imageInfo = imageInfo; 222 info.m_imageInfo = imageInfo;
222 *outMailbox = info.m_mailbox; 223 *outMailbox = info.m_mailbox;
223 224
224 gl->BindTexture(GC3D_TEXTURE_RECTANGLE_ARB, 0); 225 gl->BindTexture(GC3D_TEXTURE_RECTANGLE_ARB, 0);
225 226
226 // Because we are changing the texture binding without going through skia, 227 // Because we are changing the texture binding without going through skia,
227 // we must dirty the context. 228 // we must dirty the context.
228 grContext->resetContext(kTextureBinding_GrGLBackendState); 229 grContext->resetContext(kTextureBinding_GrGLBackendState);
229 230
(...skipping 19 matching lines...) Expand all
249 GLuint textureId; 250 GLuint textureId;
250 gl->GenTextures(1, &textureId); 251 gl->GenTextures(1, &textureId);
251 GLenum target = GC3D_TEXTURE_RECTANGLE_ARB; 252 GLenum target = GC3D_TEXTURE_RECTANGLE_ARB;
252 gl->BindTexture(target, textureId); 253 gl->BindTexture(target, textureId);
253 gl->TexParameteri(target, GL_TEXTURE_MAG_FILTER, getGLFilter()); 254 gl->TexParameteri(target, GL_TEXTURE_MAG_FILTER, getGLFilter());
254 gl->TexParameteri(target, GL_TEXTURE_MIN_FILTER, getGLFilter()); 255 gl->TexParameteri(target, GL_TEXTURE_MIN_FILTER, getGLFilter());
255 gl->TexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 256 gl->TexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
256 gl->TexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 257 gl->TexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
257 gl->BindTexImage2DCHROMIUM(target, imageId); 258 gl->BindTexImage2DCHROMIUM(target, imageId);
258 259
259 return Canvas2DLayerBridge::ImageInfo(imageId, textureId); 260 GLint gpuMemoryBufferId = gl->GetImageivCHROMIUM(imageId, GC3D_GPU_MEMORY_BU FFER_ID);
261 DCHECK_NE(-1, gpuMemoryBufferId);
262
263 return Canvas2DLayerBridge::ImageInfo(imageId, textureId, gpuMemoryBufferId) ;
260 } 264 }
261 265
262 void Canvas2DLayerBridge::deleteCHROMIUMImage(ImageInfo info) 266 void Canvas2DLayerBridge::deleteCHROMIUMImage(ImageInfo info)
263 { 267 {
264 gpu::gles2::GLES2Interface* gl = contextGL(); 268 gpu::gles2::GLES2Interface* gl = contextGL();
265 if (!gl) 269 if (!gl)
266 return; 270 return;
267 271
268 GLenum target = GC3D_TEXTURE_RECTANGLE_ARB; 272 GLenum target = GC3D_TEXTURE_RECTANGLE_ARB;
269 gl->BindTexture(target, info.m_textureId); 273 gl->BindTexture(target, info.m_textureId);
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 getOrCreateSurface()->notifyContentWillChange(SkSurface::kRetain_ContentChan geMode); 958 getOrCreateSurface()->notifyContentWillChange(SkSurface::kRetain_ContentChan geMode);
955 return adoptRef(m_surface->newImageSnapshot()); 959 return adoptRef(m_surface->newImageSnapshot());
956 } 960 }
957 961
958 void Canvas2DLayerBridge::willOverwriteCanvas() 962 void Canvas2DLayerBridge::willOverwriteCanvas()
959 { 963 {
960 skipQueuedDrawCommands(); 964 skipQueuedDrawCommands();
961 } 965 }
962 966
963 #if USE_IOSURFACE_FOR_2D_CANVAS 967 #if USE_IOSURFACE_FOR_2D_CANVAS
964 Canvas2DLayerBridge::ImageInfo::ImageInfo(GLuint imageId, GLuint textureId) : m_ imageId(imageId), m_textureId(textureId) 968 Canvas2DLayerBridge::ImageInfo::ImageInfo(GLuint imageId, GLuint textureId, GLin t gpuMemoryBufferId)
969 : m_imageId(imageId)
970 , m_textureId(textureId)
971 , m_gpuMemoryBufferId(gpuMemoryBufferId)
965 { 972 {
966 ASSERT(imageId); 973 ASSERT(imageId);
967 ASSERT(textureId); 974 ASSERT(textureId);
975 DCHECK_NE(-1, gpuMemoryBufferId);
968 } 976 }
969 977
970 bool Canvas2DLayerBridge::ImageInfo::empty() 978 bool Canvas2DLayerBridge::ImageInfo::empty()
971 { 979 {
972 return m_imageId == 0; 980 return m_imageId == 0;
973 } 981 }
974 #endif // USE_IOSURFACE_FOR_2D_CANVAS 982 #endif // USE_IOSURFACE_FOR_2D_CANVAS
975 983
976 Canvas2DLayerBridge::MailboxInfo::MailboxInfo(const MailboxInfo& other) 984 Canvas2DLayerBridge::MailboxInfo::MailboxInfo(const MailboxInfo& other)
977 { 985 {
978 memcpy(&m_mailbox, &other.m_mailbox, sizeof(m_mailbox)); 986 memcpy(&m_mailbox, &other.m_mailbox, sizeof(m_mailbox));
979 m_image = other.m_image; 987 m_image = other.m_image;
980 m_parentLayerBridge = other.m_parentLayerBridge; 988 m_parentLayerBridge = other.m_parentLayerBridge;
981 #if USE_IOSURFACE_FOR_2D_CANVAS 989 #if USE_IOSURFACE_FOR_2D_CANVAS
982 m_imageInfo = other.m_imageInfo; 990 m_imageInfo = other.m_imageInfo;
983 #endif // USE_IOSURFACE_FOR_2D_CANVAS 991 #endif // USE_IOSURFACE_FOR_2D_CANVAS
984 } 992 }
985 993
986 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event) 994 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event)
987 { 995 {
988 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, ("Canvas.Hib ernationEvents", HibernationEventCount)); 996 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, ("Canvas.Hib ernationEvents", HibernationEventCount));
989 hibernationHistogram.count(event); 997 hibernationHistogram.count(event);
990 } 998 }
991 999
992 } // namespace blink 1000 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698