OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer/gpu/compositor_software_output_device_gl_adapter.h" | 5 #include "content/renderer/gpu/compositor_software_output_device_gl_adapter.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "third_party/skia/include/core/SkBitmap.h" | 9 #include "third_party/skia/include/core/SkBitmap.h" |
10 #include "third_party/skia/include/core/SkPixelRef.h" | 10 #include "third_party/skia/include/core/SkPixelRef.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 framebuffer_texture_id_(0), | 32 framebuffer_texture_id_(0), |
33 context3d_(context3D), | 33 context3d_(context3D), |
34 locked_for_write_(false) { | 34 locked_for_write_(false) { |
35 } | 35 } |
36 | 36 |
37 CompositorSoftwareOutputDeviceGLAdapter:: | 37 CompositorSoftwareOutputDeviceGLAdapter:: |
38 ~CompositorSoftwareOutputDeviceGLAdapter() { | 38 ~CompositorSoftwareOutputDeviceGLAdapter() { |
39 Destroy(); | 39 Destroy(); |
40 } | 40 } |
41 | 41 |
42 WebImage* CompositorSoftwareOutputDeviceGLAdapter::lock(bool forWrite) { | 42 WebImage* CompositorSoftwareOutputDeviceGLAdapter::Lock(bool forWrite) { |
43 locked_for_write_ = forWrite; | 43 locked_for_write_ = forWrite; |
44 image_ = device_->accessBitmap(forWrite); | 44 image_ = device_->accessBitmap(forWrite); |
45 return &image_; | 45 return &image_; |
46 } | 46 } |
47 | 47 |
48 void CompositorSoftwareOutputDeviceGLAdapter::unlock() { | 48 void CompositorSoftwareOutputDeviceGLAdapter::Unlock() { |
49 if (locked_for_write_) | 49 if (locked_for_write_) |
50 Draw(device_->accessBitmap(false).pixelRef()->pixels()); | 50 Draw(device_->accessBitmap(false).pixelRef()->pixels()); |
51 image_.reset(); | 51 image_.reset(); |
52 } | 52 } |
53 | 53 |
54 void CompositorSoftwareOutputDeviceGLAdapter::didChangeViewportSize( | 54 void CompositorSoftwareOutputDeviceGLAdapter::DidChangeViewportSize( |
55 WebSize size) { | 55 gfx::Size size) { |
56 if (!initialized_) | 56 if (!initialized_) |
57 Initialize(); | 57 Initialize(); |
58 | 58 |
59 if (framebuffer_texture_size_ != gfx::Size(size)) | 59 if (framebuffer_texture_size_ != gfx::Size(size)) |
60 Resize(size); | 60 Resize(size); |
61 } | 61 } |
62 | 62 |
63 void CompositorSoftwareOutputDeviceGLAdapter::Initialize() { | 63 void CompositorSoftwareOutputDeviceGLAdapter::Initialize() { |
64 // Vertex shader that flips the y axis. | 64 // Vertex shader that flips the y axis. |
65 static const char g_vertex_shader[] = | 65 static const char g_vertex_shader[] = |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 context3d_->texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, | 175 context3d_->texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, |
176 framebuffer_texture_size_.width(), framebuffer_texture_size_.height(), | 176 framebuffer_texture_size_.width(), framebuffer_texture_size_.height(), |
177 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); | 177 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); |
178 | 178 |
179 context3d_->drawArrays(GL_TRIANGLE_STRIP, 0, 4); | 179 context3d_->drawArrays(GL_TRIANGLE_STRIP, 0, 4); |
180 | 180 |
181 context3d_->prepareTexture(); | 181 context3d_->prepareTexture(); |
182 } | 182 } |
183 | 183 |
184 } // namespace content | 184 } // namespace content |
OLD | NEW |