| 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/output/software_renderer.h" | 5 #include "cc/output/software_renderer.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "cc/base/math_util.h" | 8 #include "cc/base/math_util.h" |
| 9 #include "cc/output/compositor_frame.h" | 9 #include "cc/output/compositor_frame.h" |
| 10 #include "cc/output/compositor_frame_ack.h" | 10 #include "cc/output/compositor_frame_ack.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "third_party/skia/include/core/SkShader.h" | 28 #include "third_party/skia/include/core/SkShader.h" |
| 29 #include "third_party/skia/include/effects/SkLayerRasterizer.h" | 29 #include "third_party/skia/include/effects/SkLayerRasterizer.h" |
| 30 #include "ui/gfx/rect_conversions.h" | 30 #include "ui/gfx/rect_conversions.h" |
| 31 #include "ui/gfx/skia_util.h" | 31 #include "ui/gfx/skia_util.h" |
| 32 #include "ui/gfx/transform.h" | 32 #include "ui/gfx/transform.h" |
| 33 | 33 |
| 34 namespace cc { | 34 namespace cc { |
| 35 | 35 |
| 36 namespace { | 36 namespace { |
| 37 | 37 |
| 38 class OnDemandRasterTaskImpl : public internal::Task { |
| 39 public: |
| 40 OnDemandRasterTaskImpl(PicturePileImpl* picture_pile, |
| 41 SkCanvas* canvas, |
| 42 gfx::Rect content_rect, |
| 43 float contents_scale) |
| 44 : picture_pile_(picture_pile), |
| 45 canvas_(canvas), |
| 46 content_rect_(content_rect), |
| 47 contents_scale_(contents_scale) { |
| 48 DCHECK(picture_pile_); |
| 49 DCHECK(canvas_); |
| 50 } |
| 51 |
| 52 // Overridden from internal::Task: |
| 53 virtual void RunOnWorkerThread(unsigned thread_index) OVERRIDE { |
| 54 TRACE_EVENT0("cc", "OnDemandRasterTaskImpl::RunOnWorkerThread"); |
| 55 picture_pile_->RasterDirect(canvas_, content_rect_, contents_scale_, NULL); |
| 56 } |
| 57 |
| 58 protected: |
| 59 virtual ~OnDemandRasterTaskImpl() {} |
| 60 |
| 61 private: |
| 62 PicturePileImpl* picture_pile_; |
| 63 SkCanvas* canvas_; |
| 64 const gfx::Rect content_rect_; |
| 65 const float contents_scale_; |
| 66 |
| 67 DISALLOW_COPY_AND_ASSIGN(OnDemandRasterTaskImpl); |
| 68 }; |
| 69 |
| 38 static inline bool IsScalarNearlyInteger(SkScalar scalar) { | 70 static inline bool IsScalarNearlyInteger(SkScalar scalar) { |
| 39 return SkScalarNearlyZero(scalar - SkScalarRoundToScalar(scalar)); | 71 return SkScalarNearlyZero(scalar - SkScalarRoundToScalar(scalar)); |
| 40 } | 72 } |
| 41 | 73 |
| 42 bool IsScaleAndIntegerTranslate(const SkMatrix& matrix) { | 74 bool IsScaleAndIntegerTranslate(const SkMatrix& matrix) { |
| 43 return IsScalarNearlyInteger(matrix[SkMatrix::kMTransX]) && | 75 return IsScalarNearlyInteger(matrix[SkMatrix::kMTransX]) && |
| 44 IsScalarNearlyInteger(matrix[SkMatrix::kMTransY]) && | 76 IsScalarNearlyInteger(matrix[SkMatrix::kMTransY]) && |
| 45 SkScalarNearlyZero(matrix[SkMatrix::kMSkewX]) && | 77 SkScalarNearlyZero(matrix[SkMatrix::kMSkewX]) && |
| 46 SkScalarNearlyZero(matrix[SkMatrix::kMSkewY]) && | 78 SkScalarNearlyZero(matrix[SkMatrix::kMSkewY]) && |
| 47 SkScalarNearlyZero(matrix[SkMatrix::kMPersp0]) && | 79 SkScalarNearlyZero(matrix[SkMatrix::kMPersp0]) && |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 // cases and fall back to a persistent bitmap backing | 374 // cases and fall back to a persistent bitmap backing |
| 343 // (http://crbug.com/280374). | 375 // (http://crbug.com/280374). |
| 344 skia::RefPtr<SkDrawFilter> opacity_filter = | 376 skia::RefPtr<SkDrawFilter> opacity_filter = |
| 345 skia::AdoptRef(new skia::OpacityDrawFilter( | 377 skia::AdoptRef(new skia::OpacityDrawFilter( |
| 346 quad->opacity(), frame->disable_picture_quad_image_filtering)); | 378 quad->opacity(), frame->disable_picture_quad_image_filtering)); |
| 347 DCHECK(!current_canvas_->getDrawFilter()); | 379 DCHECK(!current_canvas_->getDrawFilter()); |
| 348 current_canvas_->setDrawFilter(opacity_filter.get()); | 380 current_canvas_->setDrawFilter(opacity_filter.get()); |
| 349 | 381 |
| 350 TRACE_EVENT0("cc", | 382 TRACE_EVENT0("cc", |
| 351 "SoftwareRenderer::DrawPictureQuad"); | 383 "SoftwareRenderer::DrawPictureQuad"); |
| 352 quad->picture_pile->RasterDirect( | 384 |
| 353 current_canvas_, quad->content_rect, quad->contents_scale, NULL); | 385 // Create and run on-demand raster task for tile. |
| 386 scoped_refptr<internal::Task> on_demand_raster_task( |
| 387 new OnDemandRasterTaskImpl(quad->picture_pile, |
| 388 current_canvas_, |
| 389 quad->content_rect, |
| 390 quad->contents_scale)); |
| 391 RunOnDemandRasterTask(on_demand_raster_task.get()); |
| 354 | 392 |
| 355 current_canvas_->setDrawFilter(NULL); | 393 current_canvas_->setDrawFilter(NULL); |
| 356 } | 394 } |
| 357 | 395 |
| 358 void SoftwareRenderer::DrawSolidColorQuad(const DrawingFrame* frame, | 396 void SoftwareRenderer::DrawSolidColorQuad(const DrawingFrame* frame, |
| 359 const SolidColorDrawQuad* quad) { | 397 const SolidColorDrawQuad* quad) { |
| 360 gfx::RectF visible_quad_vertex_rect = MathUtil::ScaleRectProportional( | 398 gfx::RectF visible_quad_vertex_rect = MathUtil::ScaleRectProportional( |
| 361 QuadVertexRect(), quad->rect, quad->visible_rect); | 399 QuadVertexRect(), quad->rect, quad->visible_rect); |
| 362 current_paint_.setColor(quad->color); | 400 current_paint_.setColor(quad->color); |
| 363 current_paint_.setAlpha(quad->opacity() * SkColorGetA(quad->color)); | 401 current_paint_.setAlpha(quad->opacity() * SkColorGetA(quad->color)); |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 return; | 658 return; |
| 621 visible_ = visible; | 659 visible_ = visible; |
| 622 | 660 |
| 623 if (visible_) | 661 if (visible_) |
| 624 EnsureBackbuffer(); | 662 EnsureBackbuffer(); |
| 625 else | 663 else |
| 626 DiscardBackbuffer(); | 664 DiscardBackbuffer(); |
| 627 } | 665 } |
| 628 | 666 |
| 629 } // namespace cc | 667 } // namespace cc |
| OLD | NEW |