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

Side by Side Diff: Source/platform/graphics/ImageBuffer.cpp

Issue 179973004: Share Group plumbing in Blink; Remove WebGL from default share group (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressed Ken's feedback Created 6 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2008, Google Inc. All rights reserved. 2 * Copyright (c) 2008, Google Inc. All rights reserved.
3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> 3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are 7 * modification, are permitted provided that the following conditions are
8 * met: 8 * met:
9 * 9 *
10 * * Redistributions of source code must retain the above copyright 10 * * Redistributions of source code must retain the above copyright
(...skipping 29 matching lines...) Expand all
40 #include "platform/graphics/GraphicsTypes3D.h" 40 #include "platform/graphics/GraphicsTypes3D.h"
41 #include "platform/graphics/UnacceleratedImageBufferSurface.h" 41 #include "platform/graphics/UnacceleratedImageBufferSurface.h"
42 #include "platform/graphics/gpu/DrawingBuffer.h" 42 #include "platform/graphics/gpu/DrawingBuffer.h"
43 #include "platform/graphics/gpu/Extensions3DUtil.h" 43 #include "platform/graphics/gpu/Extensions3DUtil.h"
44 #include "platform/graphics/skia/NativeImageSkia.h" 44 #include "platform/graphics/skia/NativeImageSkia.h"
45 #include "platform/graphics/skia/SkiaUtils.h" 45 #include "platform/graphics/skia/SkiaUtils.h"
46 #include "platform/image-encoders/skia/JPEGImageEncoder.h" 46 #include "platform/image-encoders/skia/JPEGImageEncoder.h"
47 #include "platform/image-encoders/skia/PNGImageEncoder.h" 47 #include "platform/image-encoders/skia/PNGImageEncoder.h"
48 #include "platform/image-encoders/skia/WEBPImageEncoder.h" 48 #include "platform/image-encoders/skia/WEBPImageEncoder.h"
49 #include "public/platform/Platform.h" 49 #include "public/platform/Platform.h"
50 #include "public/platform/WebExternalTextureMailbox.h"
50 #include "public/platform/WebGraphicsContext3D.h" 51 #include "public/platform/WebGraphicsContext3D.h"
51 #include "public/platform/WebGraphicsContext3DProvider.h" 52 #include "public/platform/WebGraphicsContext3DProvider.h"
52 #include "third_party/skia/include/effects/SkTableColorFilter.h" 53 #include "third_party/skia/include/effects/SkTableColorFilter.h"
53 #include "wtf/MathExtras.h" 54 #include "wtf/MathExtras.h"
54 #include "wtf/text/Base64.h" 55 #include "wtf/text/Base64.h"
55 #include "wtf/text/WTFString.h" 56 #include "wtf/text/WTFString.h"
56 57
57 using namespace std; 58 using namespace std;
58 59
59 namespace WebCore { 60 namespace WebCore {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 blink::WebLayer* ImageBuffer::platformLayer() const 132 blink::WebLayer* ImageBuffer::platformLayer() const
132 { 133 {
133 return m_surface->layer(); 134 return m_surface->layer();
134 } 135 }
135 136
136 bool ImageBuffer::copyToPlatformTexture(blink::WebGraphicsContext3D* context, Pl atform3DObject texture, GLenum internalFormat, GLenum destType, GLint level, boo l premultiplyAlpha, bool flipY) 137 bool ImageBuffer::copyToPlatformTexture(blink::WebGraphicsContext3D* context, Pl atform3DObject texture, GLenum internalFormat, GLenum destType, GLint level, boo l premultiplyAlpha, bool flipY)
137 { 138 {
138 if (!m_surface->isAccelerated() || !platformLayer() || !isValid()) 139 if (!m_surface->isAccelerated() || !platformLayer() || !isValid())
139 return false; 140 return false;
140 141
142 if (!Extensions3DUtil::canUseCopyTextureCHROMIUM(internalFormat, destType, l evel))
143 return false;
144
145 OwnPtr<blink::WebGraphicsContext3DProvider> provider = adoptPtr(blink::Platf orm::current()->createSharedOffscreenGraphicsContext3DProvider());
146 if (!provider)
147 return false;
148 blink::WebGraphicsContext3D* sharedContext = provider->context3d();
149 if (!sharedContext || !sharedContext->makeContextCurrent())
150 return false;
151
152 OwnPtr<blink::WebExternalTextureMailbox> mailbox = adoptPtr(new blink::WebEx ternalTextureMailbox);
153
154 // Contexts may be in a different share group. We must transfer the texture through a mailbox first
155 sharedContext->genMailboxCHROMIUM(mailbox->name);
156 sharedContext->bindTexture(GL_TEXTURE_2D, getBackingTexture());
Ken Russell (switch to Gerrit) 2014/03/13 19:35:54 I recall you mentioned that it was always necessar
157 sharedContext->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox->name);
158 sharedContext->flush();
159
160 mailbox->syncPoint = sharedContext->insertSyncPoint();
161
141 if (!context->makeContextCurrent()) 162 if (!context->makeContextCurrent())
142 return false; 163 return false;
143 164
144 if (!Extensions3DUtil::canUseCopyTextureCHROMIUM(internalFormat, destType, l evel)) 165 Platform3DObject sourceTexture = context->createTexture();
145 return false; 166
167 context->bindTexture(GL_TEXTURE_2D, sourceTexture);
168
169 context->waitSyncPoint(mailbox->syncPoint);
170 context->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox->name);
146 171
147 // The canvas is stored in a premultiplied format, so unpremultiply if neces sary. 172 // The canvas is stored in a premultiplied format, so unpremultiply if neces sary.
148 context->pixelStorei(GC3D_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, !premultiplyA lpha); 173 context->pixelStorei(GC3D_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, !premultiplyA lpha);
149 174
150 // The canvas is stored in an inverted position, so the flip semantics are r eversed. 175 // The canvas is stored in an inverted position, so the flip semantics are r eversed.
151 context->pixelStorei(GC3D_UNPACK_FLIP_Y_CHROMIUM, !flipY); 176 context->pixelStorei(GC3D_UNPACK_FLIP_Y_CHROMIUM, !flipY);
152 context->copyTextureCHROMIUM(GL_TEXTURE_2D, getBackingTexture(), texture, le vel, internalFormat, destType); 177 context->copyTextureCHROMIUM(GL_TEXTURE_2D, sourceTexture, texture, level, i nternalFormat, destType);
153 178
154 context->pixelStorei(GC3D_UNPACK_FLIP_Y_CHROMIUM, false); 179 context->pixelStorei(GC3D_UNPACK_FLIP_Y_CHROMIUM, false);
155 context->pixelStorei(GC3D_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, false); 180 context->pixelStorei(GC3D_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, false);
181
182 context->bindTexture(GL_TEXTURE_2D, 0);
dshwang 2014/03/14 21:47:54 If changing context->bindTexture(GL_TEXTURE_2D, te
183 context->deleteTexture(sourceTexture);
184
156 context->flush(); 185 context->flush();
186 sharedContext->waitSyncPoint(context->insertSyncPoint());
187
157 return true; 188 return true;
158 } 189 }
159 190
160 static bool drawNeedsCopy(GraphicsContext* src, GraphicsContext* dst) 191 static bool drawNeedsCopy(GraphicsContext* src, GraphicsContext* dst)
161 { 192 {
162 ASSERT(dst); 193 ASSERT(dst);
163 return (src == dst); 194 return (src == dst);
164 } 195 }
165 196
166 Platform3DObject ImageBuffer::getBackingTexture() 197 Platform3DObject ImageBuffer::getBackingTexture()
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 if (!encodeImage(imageData, mimeType, quality, &encodedImage)) 414 if (!encodeImage(imageData, mimeType, quality, &encodedImage))
384 return "data:,"; 415 return "data:,";
385 416
386 Vector<char> base64Data; 417 Vector<char> base64Data;
387 base64Encode(encodedImage, base64Data); 418 base64Encode(encodedImage, base64Data);
388 419
389 return "data:" + mimeType + ";base64," + base64Data; 420 return "data:" + mimeType + ";base64," + base64Data;
390 } 421 }
391 422
392 } // namespace WebCore 423 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698