OLD | NEW |
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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 "cc/output/gl_renderer.h" | 5 #include "cc/output/gl_renderer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "cc/quads/render_pass.h" | 30 #include "cc/quads/render_pass.h" |
31 #include "cc/quads/stream_video_draw_quad.h" | 31 #include "cc/quads/stream_video_draw_quad.h" |
32 #include "cc/quads/texture_draw_quad.h" | 32 #include "cc/quads/texture_draw_quad.h" |
33 #include "cc/resources/layer_quad.h" | 33 #include "cc/resources/layer_quad.h" |
34 #include "cc/resources/scoped_resource.h" | 34 #include "cc/resources/scoped_resource.h" |
35 #include "cc/resources/sync_point_helper.h" | 35 #include "cc/resources/sync_point_helper.h" |
36 #include "cc/trees/damage_tracker.h" | 36 #include "cc/trees/damage_tracker.h" |
37 #include "cc/trees/proxy.h" | 37 #include "cc/trees/proxy.h" |
38 #include "cc/trees/single_thread_proxy.h" | 38 #include "cc/trees/single_thread_proxy.h" |
39 #include "gpu/GLES2/gl2extchromium.h" | 39 #include "gpu/GLES2/gl2extchromium.h" |
| 40 #include "skia/ext/alpha_proxy_canvas.h" |
40 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 41 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
41 #include "third_party/khronos/GLES2/gl2.h" | 42 #include "third_party/khronos/GLES2/gl2.h" |
42 #include "third_party/khronos/GLES2/gl2ext.h" | 43 #include "third_party/khronos/GLES2/gl2ext.h" |
43 #include "third_party/skia/include/core/SkBitmap.h" | 44 #include "third_party/skia/include/core/SkBitmap.h" |
44 #include "third_party/skia/include/core/SkColor.h" | 45 #include "third_party/skia/include/core/SkColor.h" |
45 #include "third_party/skia/include/core/SkColorFilter.h" | 46 #include "third_party/skia/include/core/SkColorFilter.h" |
46 #include "third_party/skia/include/core/SkSurface.h" | 47 #include "third_party/skia/include/core/SkSurface.h" |
47 #include "third_party/skia/include/gpu/GrContext.h" | 48 #include "third_party/skia/include/gpu/GrContext.h" |
48 #include "third_party/skia/include/gpu/GrTexture.h" | 49 #include "third_party/skia/include/gpu/GrTexture.h" |
49 #include "third_party/skia/include/gpu/SkGpuDevice.h" | 50 #include "third_party/skia/include/gpu/SkGpuDevice.h" |
(...skipping 1584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1634 DrawQuadGeometry(frame, | 1635 DrawQuadGeometry(frame, |
1635 quad->quadTransform(), | 1636 quad->quadTransform(), |
1636 quad->rect, | 1637 quad->rect, |
1637 program->vertex_shader().matrix_location()); | 1638 program->vertex_shader().matrix_location()); |
1638 } | 1639 } |
1639 | 1640 |
1640 void GLRenderer::DrawPictureQuadDirectToBackbuffer( | 1641 void GLRenderer::DrawPictureQuadDirectToBackbuffer( |
1641 const DrawingFrame* frame, | 1642 const DrawingFrame* frame, |
1642 const PictureDrawQuad* quad) { | 1643 const PictureDrawQuad* quad) { |
1643 DCHECK(CanUseSkiaGPUBackend()); | 1644 DCHECK(CanUseSkiaGPUBackend()); |
1644 DCHECK_EQ(quad->opacity(), 1.f) << "Need to composite to a bitmap or a " | |
1645 "render surface for non-1 opacity quads"; | |
1646 | 1645 |
1647 // TODO(enne): This should be done more lazily / efficiently. | 1646 // TODO(enne): This should be done more lazily / efficiently. |
1648 gr_context_->resetContext(); | 1647 gr_context_->resetContext(); |
1649 | 1648 |
1650 // Reset the canvas matrix to identity because the clip rect is in target | 1649 // Reset the canvas matrix to identity because the clip rect is in target |
1651 // space. | 1650 // space. |
1652 SkMatrix sk_identity; | 1651 SkMatrix sk_identity; |
1653 sk_identity.setIdentity(); | 1652 sk_identity.setIdentity(); |
1654 sk_canvas_->setMatrix(sk_identity); | 1653 sk_canvas_->setMatrix(sk_identity); |
1655 | 1654 |
1656 if (is_scissor_enabled_) { | 1655 if (is_scissor_enabled_) { |
1657 sk_canvas_->clipRect(gfx::RectToSkRect(scissor_rect_), | 1656 sk_canvas_->clipRect(gfx::RectToSkRect(scissor_rect_), |
1658 SkRegion::kReplace_Op); | 1657 SkRegion::kReplace_Op); |
1659 } else { | 1658 } else { |
1660 sk_canvas_->clipRect(gfx::RectToSkRect(client_->DeviceViewport()), | 1659 sk_canvas_->clipRect(gfx::RectToSkRect(client_->DeviceViewport()), |
1661 SkRegion::kReplace_Op); | 1660 SkRegion::kReplace_Op); |
1662 } | 1661 } |
1663 | 1662 |
1664 gfx::Transform contents_device_transform = frame->window_matrix * | 1663 gfx::Transform contents_device_transform = frame->window_matrix * |
1665 frame->projection_matrix * quad->quadTransform(); | 1664 frame->projection_matrix * quad->quadTransform(); |
1666 contents_device_transform.Translate(quad->rect.x(), | 1665 contents_device_transform.Translate(quad->rect.x(), |
1667 quad->rect.y()); | 1666 quad->rect.y()); |
1668 contents_device_transform.FlattenTo2d(); | 1667 contents_device_transform.FlattenTo2d(); |
1669 SkMatrix sk_device_matrix; | 1668 SkMatrix sk_device_matrix; |
1670 gfx::TransformToFlattenedSkMatrix(contents_device_transform, | 1669 gfx::TransformToFlattenedSkMatrix(contents_device_transform, |
1671 &sk_device_matrix); | 1670 &sk_device_matrix); |
1672 sk_canvas_->setMatrix(sk_device_matrix); | 1671 sk_canvas_->setMatrix(sk_device_matrix); |
1673 | 1672 |
| 1673 skia::AlphaProxyCanvas proxy_canvas(sk_canvas_.get(), quad->opacity(), true); |
1674 quad->picture_pile->RasterDirect( | 1674 quad->picture_pile->RasterDirect( |
1675 sk_canvas_.get(), quad->content_rect, quad->contents_scale, NULL); | 1675 &proxy_canvas, quad->content_rect, quad->contents_scale, NULL); |
1676 | 1676 |
1677 // Flush any drawing buffers that have been deferred. | 1677 // Flush any drawing buffers that have been deferred. |
1678 sk_canvas_->flush(); | 1678 sk_canvas_->flush(); |
1679 | 1679 |
1680 // TODO(enne): This should be done more lazily / efficiently. | 1680 // TODO(enne): This should be done more lazily / efficiently. |
1681 ReinitializeGLState(); | 1681 ReinitializeGLState(); |
1682 } | 1682 } |
1683 | 1683 |
1684 void GLRenderer::DrawPictureQuad(const DrawingFrame* frame, | 1684 void GLRenderer::DrawPictureQuad(const DrawingFrame* frame, |
1685 const PictureDrawQuad* quad) { | 1685 const PictureDrawQuad* quad) { |
(...skipping 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3156 std::string unique_context_name = base::StringPrintf( | 3156 std::string unique_context_name = base::StringPrintf( |
3157 "%s-Offscreen-%p", | 3157 "%s-Offscreen-%p", |
3158 Settings().compositor_name.c_str(), | 3158 Settings().compositor_name.c_str(), |
3159 context_); | 3159 context_); |
3160 resource_provider()->offscreen_context_provider()->Context3d()-> | 3160 resource_provider()->offscreen_context_provider()->Context3d()-> |
3161 pushGroupMarkerEXT(unique_context_name.c_str()); | 3161 pushGroupMarkerEXT(unique_context_name.c_str()); |
3162 } | 3162 } |
3163 | 3163 |
3164 | 3164 |
3165 } // namespace cc | 3165 } // namespace cc |
OLD | NEW |