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/opacity_draw_filter.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 1583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1633 DrawQuadGeometry(frame, | 1634 DrawQuadGeometry(frame, |
1634 quad->quadTransform(), | 1635 quad->quadTransform(), |
1635 quad->rect, | 1636 quad->rect, |
1636 program->vertex_shader().matrix_location()); | 1637 program->vertex_shader().matrix_location()); |
1637 } | 1638 } |
1638 | 1639 |
1639 void GLRenderer::DrawPictureQuadDirectToBackbuffer( | 1640 void GLRenderer::DrawPictureQuadDirectToBackbuffer( |
1640 const DrawingFrame* frame, | 1641 const DrawingFrame* frame, |
1641 const PictureDrawQuad* quad) { | 1642 const PictureDrawQuad* quad) { |
1642 DCHECK(CanUseSkiaGPUBackend()); | 1643 DCHECK(CanUseSkiaGPUBackend()); |
1643 DCHECK_EQ(quad->opacity(), 1.f) << "Need to composite to a bitmap or a " | |
1644 "render surface for non-1 opacity quads"; | |
1645 | 1644 |
1646 // TODO(enne): This should be done more lazily / efficiently. | 1645 // TODO(enne): This should be done more lazily / efficiently. |
1647 gr_context_->resetContext(); | 1646 gr_context_->resetContext(); |
1648 | 1647 |
1649 // Reset the canvas matrix to identity because the clip rect is in target | 1648 // Reset the canvas matrix to identity because the clip rect is in target |
1650 // space. | 1649 // space. |
1651 SkMatrix sk_identity; | 1650 SkMatrix sk_identity; |
1652 sk_identity.setIdentity(); | 1651 sk_identity.setIdentity(); |
1653 sk_canvas_->setMatrix(sk_identity); | 1652 sk_canvas_->setMatrix(sk_identity); |
1654 | 1653 |
1655 if (is_scissor_enabled_) { | 1654 if (is_scissor_enabled_) { |
1656 sk_canvas_->clipRect(gfx::RectToSkRect(scissor_rect_), | 1655 sk_canvas_->clipRect(gfx::RectToSkRect(scissor_rect_), |
1657 SkRegion::kReplace_Op); | 1656 SkRegion::kReplace_Op); |
1658 } else { | 1657 } else { |
1659 sk_canvas_->clipRect(gfx::RectToSkRect(client_->DeviceViewport()), | 1658 sk_canvas_->clipRect(gfx::RectToSkRect(client_->DeviceViewport()), |
1660 SkRegion::kReplace_Op); | 1659 SkRegion::kReplace_Op); |
1661 } | 1660 } |
1662 | 1661 |
1663 gfx::Transform contents_device_transform = frame->window_matrix * | 1662 gfx::Transform contents_device_transform = frame->window_matrix * |
1664 frame->projection_matrix * quad->quadTransform(); | 1663 frame->projection_matrix * quad->quadTransform(); |
1665 contents_device_transform.Translate(quad->rect.x(), | 1664 contents_device_transform.Translate(quad->rect.x(), |
1666 quad->rect.y()); | 1665 quad->rect.y()); |
1667 contents_device_transform.FlattenTo2d(); | 1666 contents_device_transform.FlattenTo2d(); |
1668 SkMatrix sk_device_matrix; | 1667 SkMatrix sk_device_matrix; |
1669 gfx::TransformToFlattenedSkMatrix(contents_device_transform, | 1668 gfx::TransformToFlattenedSkMatrix(contents_device_transform, |
1670 &sk_device_matrix); | 1669 &sk_device_matrix); |
1671 sk_canvas_->setMatrix(sk_device_matrix); | 1670 sk_canvas_->setMatrix(sk_device_matrix); |
1672 | 1671 |
1672 if (quad->opacity() != 1.0f) | |
tomhudson
2013/08/28 14:55:18
Do you want to debug assert that sk_canvas_->getDr
aelias_OOO_until_Jul13
2013/08/28 18:50:35
Done.
| |
1673 sk_canvas_->setDrawFilter( | |
1674 new skia::OpacityDrawFilter(quad->opacity(), false)); | |
1675 | |
1673 quad->picture_pile->RasterDirect( | 1676 quad->picture_pile->RasterDirect( |
1674 sk_canvas_.get(), quad->content_rect, quad->contents_scale, NULL); | 1677 sk_canvas_.get(), quad->content_rect, quad->contents_scale, NULL); |
1675 | 1678 |
1676 // Flush any drawing buffers that have been deferred. | 1679 // Flush any drawing buffers that have been deferred. |
1677 sk_canvas_->flush(); | 1680 sk_canvas_->flush(); |
1678 | 1681 |
1682 sk_canvas_->setDrawFilter(NULL); | |
1683 | |
1679 // TODO(enne): This should be done more lazily / efficiently. | 1684 // TODO(enne): This should be done more lazily / efficiently. |
1680 ReinitializeGLState(); | 1685 ReinitializeGLState(); |
1681 } | 1686 } |
1682 | 1687 |
1683 void GLRenderer::DrawPictureQuad(const DrawingFrame* frame, | 1688 void GLRenderer::DrawPictureQuad(const DrawingFrame* frame, |
1684 const PictureDrawQuad* quad) { | 1689 const PictureDrawQuad* quad) { |
1685 if (quad->can_draw_direct_to_backbuffer && CanUseSkiaGPUBackend()) { | 1690 if (quad->can_draw_direct_to_backbuffer && CanUseSkiaGPUBackend()) { |
1686 DrawPictureQuadDirectToBackbuffer(frame, quad); | 1691 DrawPictureQuadDirectToBackbuffer(frame, quad); |
1687 return; | 1692 return; |
1688 } | 1693 } |
(...skipping 1467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3156 std::string unique_context_name = base::StringPrintf( | 3161 std::string unique_context_name = base::StringPrintf( |
3157 "%s-Offscreen-%p", | 3162 "%s-Offscreen-%p", |
3158 Settings().compositor_name.c_str(), | 3163 Settings().compositor_name.c_str(), |
3159 context_); | 3164 context_); |
3160 resource_provider()->offscreen_context_provider()->Context3d()-> | 3165 resource_provider()->offscreen_context_provider()->Context3d()-> |
3161 pushGroupMarkerEXT(unique_context_name.c_str()); | 3166 pushGroupMarkerEXT(unique_context_name.c_str()); |
3162 } | 3167 } |
3163 | 3168 |
3164 | 3169 |
3165 } // namespace cc | 3170 } // namespace cc |
OLD | NEW |