Chromium Code Reviews| 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 1579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1629 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); | 1630 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); |
| 1630 | 1631 |
| 1631 SetShaderOpacity(quad->opacity(), | 1632 SetShaderOpacity(quad->opacity(), |
| 1632 program->fragment_shader().alpha_location()); | 1633 program->fragment_shader().alpha_location()); |
| 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( |
|
enne (OOO)
2013/08/28 20:08:42
Can you not change this path? I'm not sure I want
aelias_OOO_until_Jul13
2013/08/28 20:23:00
OK, reverted. The optimization could be eventuall
| |
| 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) { | |
| 1673 DCHECK(!sk_canvas_->getDrawFilter()); | |
| 1674 sk_canvas_->setDrawFilter( | |
| 1675 new skia::OpacityDrawFilter(quad->opacity(), false)); | |
| 1676 } | |
| 1677 | |
| 1673 quad->picture_pile->RasterDirect( | 1678 quad->picture_pile->RasterDirect( |
| 1674 sk_canvas_.get(), quad->content_rect, quad->contents_scale, NULL); | 1679 sk_canvas_.get(), quad->content_rect, quad->contents_scale, NULL); |
| 1675 | 1680 |
| 1676 // Flush any drawing buffers that have been deferred. | 1681 // Flush any drawing buffers that have been deferred. |
| 1677 sk_canvas_->flush(); | 1682 sk_canvas_->flush(); |
| 1678 | 1683 |
| 1684 sk_canvas_->setDrawFilter(NULL); | |
| 1685 | |
| 1679 // TODO(enne): This should be done more lazily / efficiently. | 1686 // TODO(enne): This should be done more lazily / efficiently. |
| 1680 ReinitializeGLState(); | 1687 ReinitializeGLState(); |
| 1681 } | 1688 } |
| 1682 | 1689 |
| 1683 void GLRenderer::DrawPictureQuad(const DrawingFrame* frame, | 1690 void GLRenderer::DrawPictureQuad(const DrawingFrame* frame, |
| 1684 const PictureDrawQuad* quad) { | 1691 const PictureDrawQuad* quad) { |
| 1685 if (quad->can_draw_direct_to_backbuffer && CanUseSkiaGPUBackend()) { | 1692 if (quad->can_draw_direct_to_backbuffer && CanUseSkiaGPUBackend()) { |
| 1686 DrawPictureQuadDirectToBackbuffer(frame, quad); | 1693 DrawPictureQuadDirectToBackbuffer(frame, quad); |
| 1687 return; | 1694 return; |
| 1688 } | 1695 } |
| (...skipping 1467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3156 std::string unique_context_name = base::StringPrintf( | 3163 std::string unique_context_name = base::StringPrintf( |
| 3157 "%s-Offscreen-%p", | 3164 "%s-Offscreen-%p", |
| 3158 Settings().compositor_name.c_str(), | 3165 Settings().compositor_name.c_str(), |
| 3159 context_); | 3166 context_); |
| 3160 resource_provider()->offscreen_context_provider()->Context3d()-> | 3167 resource_provider()->offscreen_context_provider()->Context3d()-> |
| 3161 pushGroupMarkerEXT(unique_context_name.c_str()); | 3168 pushGroupMarkerEXT(unique_context_name.c_str()); |
| 3162 } | 3169 } |
| 3163 | 3170 |
| 3164 | 3171 |
| 3165 } // namespace cc | 3172 } // namespace cc |
| OLD | NEW |