| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "cc/software_renderer.h" | 5 #include "cc/software_renderer.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "cc/debug_border_draw_quad.h" | 8 #include "cc/debug_border_draw_quad.h" |
| 9 #include "cc/math_util.h" | 9 #include "cc/math_util.h" |
| 10 #include "cc/render_pass_draw_quad.h" | 10 #include "cc/render_pass_draw_quad.h" |
| 11 #include "cc/software_output_device.h" | 11 #include "cc/software_output_device.h" |
| 12 #include "cc/solid_color_draw_quad.h" | 12 #include "cc/solid_color_draw_quad.h" |
| 13 #include "cc/texture_draw_quad.h" | 13 #include "cc/texture_draw_quad.h" |
| 14 #include "cc/tile_draw_quad.h" | 14 #include "cc/tile_draw_quad.h" |
| 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebImage.h" | 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebImage.h" |
| 16 #include "third_party/skia/include/core/SkCanvas.h" | 16 #include "third_party/skia/include/core/SkCanvas.h" |
| 17 #include "third_party/skia/include/core/SkColor.h" | 17 #include "third_party/skia/include/core/SkColor.h" |
| 18 #include "third_party/skia/include/core/SkMatrix.h" | 18 #include "third_party/skia/include/core/SkMatrix.h" |
| 19 #include "third_party/skia/include/core/SkShader.h" | 19 #include "third_party/skia/include/core/SkShader.h" |
| 20 #include "third_party/skia/include/effects/SkLayerRasterizer.h" | 20 #include "third_party/skia/include/effects/SkLayerRasterizer.h" |
| 21 #include "ui/gfx/rect_conversions.h" | 21 #include "ui/gfx/rect_conversions.h" |
| 22 #include "ui/gfx/skia_util.h" | 22 #include "ui/gfx/skia_util.h" |
| 23 #include "ui/gfx/transform.h" | 23 #include "ui/gfx/transform.h" |
| 24 #include "ui/gfx/transform_util.h" |
| 24 | 25 |
| 25 namespace cc { | 26 namespace cc { |
| 26 | 27 |
| 27 namespace { | 28 namespace { |
| 28 | 29 |
| 29 void toSkMatrix(SkMatrix* flattened, const gfx::Transform& m) | 30 void toSkMatrix(SkMatrix* flattened, const gfx::Transform& m) |
| 30 { | 31 { |
| 31 // Convert from 4x4 to 3x3 by dropping the third row and column. | 32 // Convert from 4x4 to 3x3 by dropping the third row and column. |
| 32 flattened->set(0, SkDoubleToScalar(m.matrix().getDouble(0, 0))); | 33 flattened->set(0, SkDoubleToScalar(m.matrix().getDouble(0, 0))); |
| 33 flattened->set(1, SkDoubleToScalar(m.matrix().getDouble(0, 1))); | 34 flattened->set(1, SkDoubleToScalar(m.matrix().getDouble(0, 1))); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 | 177 |
| 177 LOG(FATAL) << "Invalid resource type."; | 178 LOG(FATAL) << "Invalid resource type."; |
| 178 return false; | 179 return false; |
| 179 } | 180 } |
| 180 | 181 |
| 181 void SoftwareRenderer::drawQuad(DrawingFrame& frame, const DrawQuad* quad) | 182 void SoftwareRenderer::drawQuad(DrawingFrame& frame, const DrawQuad* quad) |
| 182 { | 183 { |
| 183 TRACE_EVENT0("cc", "SoftwareRenderer::drawQuad"); | 184 TRACE_EVENT0("cc", "SoftwareRenderer::drawQuad"); |
| 184 gfx::Transform quadRectMatrix; | 185 gfx::Transform quadRectMatrix; |
| 185 quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->rect); | 186 quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->rect); |
| 186 gfx::Transform contentsDeviceTransform = MathUtil::to2dTransform(frame.windo
wMatrix * frame.projectionMatrix * quadRectMatrix); | 187 gfx::Transform contentsDeviceTransform = gfx::CreateFlattenedTransform(frame
.windowMatrix * frame.projectionMatrix * quadRectMatrix); |
| 187 SkMatrix skDeviceMatrix; | 188 SkMatrix skDeviceMatrix; |
| 188 toSkMatrix(&skDeviceMatrix, contentsDeviceTransform); | 189 toSkMatrix(&skDeviceMatrix, contentsDeviceTransform); |
| 189 m_skCurrentCanvas->setMatrix(skDeviceMatrix); | 190 m_skCurrentCanvas->setMatrix(skDeviceMatrix); |
| 190 | 191 |
| 191 m_skCurrentPaint.reset(); | 192 m_skCurrentPaint.reset(); |
| 192 if (!isScaleAndTranslate(skDeviceMatrix)) { | 193 if (!isScaleAndTranslate(skDeviceMatrix)) { |
| 193 m_skCurrentPaint.setAntiAlias(true); | 194 m_skCurrentPaint.setAntiAlias(true); |
| 194 m_skCurrentPaint.setFilterBitmap(true); | 195 m_skCurrentPaint.setFilterBitmap(true); |
| 195 } | 196 } |
| 196 | 197 |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 } | 370 } |
| 370 | 371 |
| 371 void SoftwareRenderer::setVisible(bool visible) | 372 void SoftwareRenderer::setVisible(bool visible) |
| 372 { | 373 { |
| 373 if (m_visible == visible) | 374 if (m_visible == visible) |
| 374 return; | 375 return; |
| 375 m_visible = visible; | 376 m_visible = visible; |
| 376 } | 377 } |
| 377 | 378 |
| 378 } // namespace cc | 379 } // namespace cc |
| OLD | NEW |