| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/shell/renderer/test_runner/TestPlugin.h" | 5 #include "content/shell/renderer/test_runner/TestPlugin.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
| 11 #include "content/public/renderer/render_thread.h" | 11 #include "content/public/renderer/render_thread.h" |
| 12 #include "content/shell/renderer/test_runner/TestCommon.h" | 12 #include "content/shell/renderer/test_runner/TestCommon.h" |
| 13 #include "content/shell/renderer/test_runner/WebTestDelegate.h" | 13 #include "content/shell/renderer/test_runner/WebTestDelegate.h" |
| 14 #include "third_party/skia/include/core/SkBitmap.h" | 14 #include "third_party/skia/include/core/SkBitmap.h" |
| 15 #include "third_party/skia/include/core/SkCanvas.h" | 15 #include "third_party/skia/include/core/SkCanvas.h" |
| 16 #include "third_party/skia/include/core/SkColor.h" | 16 #include "third_party/skia/include/core/SkColor.h" |
| 17 #include "third_party/WebKit/public/platform/Platform.h" | 17 #include "third_party/WebKit/public/platform/Platform.h" |
| 18 #include "third_party/WebKit/public/platform/WebCompositorSupport.h" | 18 #include "third_party/WebKit/public/platform/WebCompositorSupport.h" |
| 19 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 19 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
| 20 #include "third_party/WebKit/public/web/WebFrame.h" | 20 #include "third_party/WebKit/public/web/WebFrame.h" |
| 21 #include "third_party/WebKit/public/web/WebInputEvent.h" | 21 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 22 #include "third_party/WebKit/public/web/WebKit.h" | 22 #include "third_party/WebKit/public/web/WebKit.h" |
| 23 #include "third_party/WebKit/public/web/WebPluginParams.h" | 23 #include "third_party/WebKit/public/web/WebPluginParams.h" |
| 24 #include "third_party/WebKit/public/web/WebTouchPoint.h" | 24 #include "third_party/WebKit/public/web/WebTouchPoint.h" |
| 25 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" | 25 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" |
| 26 | 26 |
| 27 using namespace blink; | 27 using namespace blink; |
| 28 using namespace std; | 28 using namespace std; |
| 29 | 29 |
| 30 namespace WebTestRunner { | 30 namespace content { |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| 34 // GLenum values copied from gl2.h. | 34 // GLenum values copied from gl2.h. |
| 35 #define GL_FALSE 0 | 35 #define GL_FALSE 0 |
| 36 #define GL_TRUE 1 | 36 #define GL_TRUE 1 |
| 37 #define GL_ONE 1 | 37 #define GL_ONE 1 |
| 38 #define GL_TRIANGLES 0x0004 | 38 #define GL_TRIANGLES 0x0004 |
| 39 #define GL_ONE_MINUS_SRC_ALPHA 0x0303 | 39 #define GL_ONE_MINUS_SRC_ALPHA 0x0303 |
| 40 #define GL_DEPTH_TEST 0x0B71 | 40 #define GL_DEPTH_TEST 0x0B71 |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 | 289 |
| 290 gpu::Mailbox mailbox; | 290 gpu::Mailbox mailbox; |
| 291 m_context->genMailboxCHROMIUM(mailbox.name); | 291 m_context->genMailboxCHROMIUM(mailbox.name); |
| 292 m_context->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); | 292 m_context->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); |
| 293 m_context->flush(); | 293 m_context->flush(); |
| 294 uint32 syncPoint = m_context->insertSyncPoint(); | 294 uint32 syncPoint = m_context->insertSyncPoint(); |
| 295 m_textureMailbox = cc::TextureMailbox(mailbox, GL_TEXTURE_2D, syncPoint)
; | 295 m_textureMailbox = cc::TextureMailbox(mailbox, GL_TEXTURE_2D, syncPoint)
; |
| 296 } else { | 296 } else { |
| 297 size_t bytes = 4 * m_rect.width * m_rect.height; | 297 size_t bytes = 4 * m_rect.width * m_rect.height; |
| 298 scoped_ptr<base::SharedMemory> bitmap = | 298 scoped_ptr<base::SharedMemory> bitmap = |
| 299 content::RenderThread::Get()->HostAllocateSharedMemoryBuffer(byt
es); | 299 RenderThread::Get()->HostAllocateSharedMemoryBuffer(bytes); |
| 300 if (!bitmap->Map(bytes)) { | 300 if (!bitmap->Map(bytes)) { |
| 301 m_textureMailbox = cc::TextureMailbox(); | 301 m_textureMailbox = cc::TextureMailbox(); |
| 302 } else { | 302 } else { |
| 303 drawSceneSoftware(bitmap->memory(), bytes); | 303 drawSceneSoftware(bitmap->memory(), bytes); |
| 304 m_textureMailbox = cc::TextureMailbox( | 304 m_textureMailbox = cc::TextureMailbox( |
| 305 bitmap.get(), gfx::Size(m_rect.width, m_rect.height)); | 305 bitmap.get(), gfx::Size(m_rect.width, m_rect.height)); |
| 306 m_sharedBitmap = bitmap.Pass(); | 306 m_sharedBitmap = bitmap.Pass(); |
| 307 } | 307 } |
| 308 } | 308 } |
| 309 | 309 |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 return kPluginPersistsMimeType; | 683 return kPluginPersistsMimeType; |
| 684 } | 684 } |
| 685 | 685 |
| 686 bool TestPlugin::isSupportedMimeType(const WebString& mimeType) | 686 bool TestPlugin::isSupportedMimeType(const WebString& mimeType) |
| 687 { | 687 { |
| 688 return mimeType == TestPlugin::mimeType() | 688 return mimeType == TestPlugin::mimeType() |
| 689 || mimeType == pluginPersistsMimeType() | 689 || mimeType == pluginPersistsMimeType() |
| 690 || mimeType == canCreateWithoutRendererMimeType(); | 690 || mimeType == canCreateWithoutRendererMimeType(); |
| 691 } | 691 } |
| 692 | 692 |
| 693 } | 693 } // namespace content |
| OLD | NEW |