| 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/render_pass_draw_quad.h" | 9 #include "cc/render_pass_draw_quad.h" |
| 10 #include "cc/solid_color_draw_quad.h" | 10 #include "cc/solid_color_draw_quad.h" |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 } | 161 } |
| 162 | 162 |
| 163 LOG(FATAL) << "Invalid resource type."; | 163 LOG(FATAL) << "Invalid resource type."; |
| 164 return false; | 164 return false; |
| 165 } | 165 } |
| 166 | 166 |
| 167 void SoftwareRenderer::drawQuad(DrawingFrame& frame, const DrawQuad* quad) | 167 void SoftwareRenderer::drawQuad(DrawingFrame& frame, const DrawQuad* quad) |
| 168 { | 168 { |
| 169 TRACE_EVENT0("cc", "SoftwareRenderer::drawQuad"); | 169 TRACE_EVENT0("cc", "SoftwareRenderer::drawQuad"); |
| 170 WebTransformationMatrix quadRectMatrix; | 170 WebTransformationMatrix quadRectMatrix; |
| 171 quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->rect()); | 171 quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->rect); |
| 172 WebTransformationMatrix contentsDeviceTransform = (frame.windowMatrix * fram
e.projectionMatrix * quadRectMatrix).to2dTransform(); | 172 WebTransformationMatrix contentsDeviceTransform = (frame.windowMatrix * fram
e.projectionMatrix * quadRectMatrix).to2dTransform(); |
| 173 SkMatrix skDeviceMatrix; | 173 SkMatrix skDeviceMatrix; |
| 174 toSkMatrix(&skDeviceMatrix, contentsDeviceTransform); | 174 toSkMatrix(&skDeviceMatrix, contentsDeviceTransform); |
| 175 m_skCurrentCanvas->setMatrix(skDeviceMatrix); | 175 m_skCurrentCanvas->setMatrix(skDeviceMatrix); |
| 176 | 176 |
| 177 m_skCurrentPaint.reset(); | 177 m_skCurrentPaint.reset(); |
| 178 if (!isScaleAndTranslate(skDeviceMatrix)) { | 178 if (!isScaleAndTranslate(skDeviceMatrix)) { |
| 179 m_skCurrentPaint.setAntiAlias(true); | 179 m_skCurrentPaint.setAntiAlias(true); |
| 180 m_skCurrentPaint.setFilterBitmap(true); | 180 m_skCurrentPaint.setFilterBitmap(true); |
| 181 } | 181 } |
| 182 | 182 |
| 183 if (quad->ShouldDrawWithBlending()) { | 183 if (quad->ShouldDrawWithBlending()) { |
| 184 m_skCurrentPaint.setAlpha(quad->opacity() * 255); | 184 m_skCurrentPaint.setAlpha(quad->opacity() * 255); |
| 185 m_skCurrentPaint.setXfermodeMode(SkXfermode::kSrcOver_Mode); | 185 m_skCurrentPaint.setXfermodeMode(SkXfermode::kSrcOver_Mode); |
| 186 } else { | 186 } else { |
| 187 m_skCurrentPaint.setXfermodeMode(SkXfermode::kSrc_Mode); | 187 m_skCurrentPaint.setXfermodeMode(SkXfermode::kSrc_Mode); |
| 188 } | 188 } |
| 189 | 189 |
| 190 switch (quad->material()) { | 190 switch (quad->material) { |
| 191 case DrawQuad::DEBUG_BORDER: | 191 case DrawQuad::DEBUG_BORDER: |
| 192 drawDebugBorderQuad(frame, DebugBorderDrawQuad::materialCast(quad)); | 192 drawDebugBorderQuad(frame, DebugBorderDrawQuad::materialCast(quad)); |
| 193 break; | 193 break; |
| 194 case DrawQuad::SOLID_COLOR: | 194 case DrawQuad::SOLID_COLOR: |
| 195 drawSolidColorQuad(frame, SolidColorDrawQuad::materialCast(quad)); | 195 drawSolidColorQuad(frame, SolidColorDrawQuad::materialCast(quad)); |
| 196 break; | 196 break; |
| 197 case DrawQuad::TEXTURE_CONTENT: | 197 case DrawQuad::TEXTURE_CONTENT: |
| 198 drawTextureQuad(frame, TextureDrawQuad::materialCast(quad)); | 198 drawTextureQuad(frame, TextureDrawQuad::materialCast(quad)); |
| 199 break; | 199 break; |
| 200 case DrawQuad::TILED_CONTENT: | 200 case DrawQuad::TILED_CONTENT: |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 &m_skCurrentPaint); | 253 &m_skCurrentPaint); |
| 254 } | 254 } |
| 255 | 255 |
| 256 void SoftwareRenderer::drawTileQuad(const DrawingFrame& frame, const TileDrawQua
d* quad) | 256 void SoftwareRenderer::drawTileQuad(const DrawingFrame& frame, const TileDrawQua
d* quad) |
| 257 { | 257 { |
| 258 DCHECK(isSoftwareResource(quad->resourceId())); | 258 DCHECK(isSoftwareResource(quad->resourceId())); |
| 259 ResourceProvider::ScopedReadLockSoftware lock(m_resourceProvider, quad->reso
urceId()); | 259 ResourceProvider::ScopedReadLockSoftware lock(m_resourceProvider, quad->reso
urceId()); |
| 260 | 260 |
| 261 SkRect uvRect = SkRect::MakeXYWH( | 261 SkRect uvRect = SkRect::MakeXYWH( |
| 262 quad->textureOffset().x(), quad->textureOffset().y(), | 262 quad->textureOffset().x(), quad->textureOffset().y(), |
| 263 quad->rect().width(), quad->rect().height()); | 263 quad->rect.width(), quad->rect.height()); |
| 264 m_skCurrentPaint.setFilterBitmap(true); | 264 m_skCurrentPaint.setFilterBitmap(true); |
| 265 m_skCurrentCanvas->drawBitmapRectToRect(*lock.skBitmap(), &uvRect, | 265 m_skCurrentCanvas->drawBitmapRectToRect(*lock.skBitmap(), &uvRect, |
| 266 gfx::RectFToSkRect(quadVertexRect())
, | 266 gfx::RectFToSkRect(quadVertexRect())
, |
| 267 &m_skCurrentPaint); | 267 &m_skCurrentPaint); |
| 268 } | 268 } |
| 269 | 269 |
| 270 void SoftwareRenderer::drawRenderPassQuad(const DrawingFrame& frame, const Rende
rPassDrawQuad* quad) | 270 void SoftwareRenderer::drawRenderPassQuad(const DrawingFrame& frame, const Rende
rPassDrawQuad* quad) |
| 271 { | 271 { |
| 272 CachedResource* contentTexture = m_renderPassTextures.get(quad->renderPassId
()); | 272 CachedResource* contentTexture = m_renderPassTextures.get(quad->renderPassId
()); |
| 273 if (!contentTexture || !contentTexture->id()) | 273 if (!contentTexture || !contentTexture->id()) |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 } | 360 } |
| 361 | 361 |
| 362 void SoftwareRenderer::setVisible(bool visible) | 362 void SoftwareRenderer::setVisible(bool visible) |
| 363 { | 363 { |
| 364 if (m_visible == visible) | 364 if (m_visible == visible) |
| 365 return; | 365 return; |
| 366 m_visible = visible; | 366 m_visible = visible; |
| 367 } | 367 } |
| 368 | 368 |
| 369 } // namespace cc | 369 } // namespace cc |
| OLD | NEW |