Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2003, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2008-2009 Torch Mobile, Inc. | 3 * Copyright (C) 2008-2009 Torch Mobile, Inc. |
| 4 * Copyright (C) 2013 Google Inc. All rights reserved. | 4 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 | 27 |
| 28 #ifndef GraphicsContext_h | 28 #ifndef GraphicsContext_h |
| 29 #define GraphicsContext_h | 29 #define GraphicsContext_h |
| 30 | 30 |
| 31 #include <memory> | 31 #include <memory> |
| 32 #include "platform/PlatformExport.h" | 32 #include "platform/PlatformExport.h" |
| 33 #include "platform/fonts/Font.h" | 33 #include "platform/fonts/Font.h" |
| 34 #include "platform/graphics/DashArray.h" | 34 #include "platform/graphics/DashArray.h" |
| 35 #include "platform/graphics/DrawLooperBuilder.h" | 35 #include "platform/graphics/DrawLooperBuilder.h" |
| 36 #include "platform/graphics/GraphicsContextState.h" | 36 #include "platform/graphics/GraphicsContextState.h" |
| 37 #include "platform/graphics/HighContrast.h" | |
| 37 #include "platform/graphics/ImageOrientation.h" | 38 #include "platform/graphics/ImageOrientation.h" |
| 38 #include "platform/graphics/paint/PaintRecord.h" | 39 #include "platform/graphics/paint/PaintRecord.h" |
| 39 #include "platform/graphics/paint/PaintRecorder.h" | 40 #include "platform/graphics/paint/PaintRecorder.h" |
| 40 #include "platform/graphics/skia/SkiaUtils.h" | 41 #include "platform/graphics/skia/SkiaUtils.h" |
| 41 #include "platform/wtf/Allocator.h" | 42 #include "platform/wtf/Allocator.h" |
| 42 #include "platform/wtf/Forward.h" | 43 #include "platform/wtf/Forward.h" |
| 43 #include "platform/wtf/Noncopyable.h" | 44 #include "platform/wtf/Noncopyable.h" |
| 44 #include "third_party/skia/include/core/SkClipOp.h" | 45 #include "third_party/skia/include/core/SkClipOp.h" |
| 45 #include "third_party/skia/include/core/SkImageFilter.h" | 46 #include "third_party/skia/include/core/SkImageFilter.h" |
| 46 #include "third_party/skia/include/core/SkMetaData.h" | 47 #include "third_party/skia/include/core/SkMetaData.h" |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 63 USING_FAST_MALLOC(GraphicsContext); | 64 USING_FAST_MALLOC(GraphicsContext); |
| 64 | 65 |
| 65 public: | 66 public: |
| 66 enum DisabledMode { | 67 enum DisabledMode { |
| 67 kNothingDisabled = 0, // Run as normal. | 68 kNothingDisabled = 0, // Run as normal. |
| 68 kFullyDisabled = 1 // Do absolutely minimal work to remove the cost of | 69 kFullyDisabled = 1 // Do absolutely minimal work to remove the cost of |
| 69 // the context from performance tests. | 70 // the context from performance tests. |
| 70 }; | 71 }; |
| 71 | 72 |
| 72 explicit GraphicsContext(PaintController&, | 73 explicit GraphicsContext(PaintController&, |
| 74 const HighContrastSettings* = nullptr, | |
|
chrishtr
2017/06/05 16:35:18
Hmm. It seems that the constructor is not used at
dmazzoni
2017/06/06 05:23:24
Done.
| |
| 73 DisabledMode = kNothingDisabled, | 75 DisabledMode = kNothingDisabled, |
| 74 SkMetaData* = 0); | 76 SkMetaData* = 0); |
| 75 | 77 |
| 76 ~GraphicsContext(); | 78 ~GraphicsContext(); |
| 77 | 79 |
| 78 PaintCanvas* Canvas() { return canvas_; } | 80 PaintCanvas* Canvas() { return canvas_; } |
| 79 const PaintCanvas* Canvas() const { return canvas_; } | 81 const PaintCanvas* Canvas() const { return canvas_; } |
| 80 | 82 |
| 81 PaintController& GetPaintController() { return paint_controller_; } | 83 PaintController& GetPaintController() { return paint_controller_; } |
| 82 | 84 |
| 83 bool ContextDisabled() const { return disabled_state_; } | 85 bool ContextDisabled() const { return disabled_state_; } |
| 84 | 86 |
| 87 const HighContrastSettings& high_contrast_settings() { | |
| 88 return high_contrast_settings_; | |
| 89 } | |
| 90 | |
| 85 // ---------- State management methods ----------------- | 91 // ---------- State management methods ----------------- |
| 86 void Save(); | 92 void Save(); |
| 87 void Restore(); | 93 void Restore(); |
| 88 | 94 |
| 89 #if DCHECK_IS_ON() | 95 #if DCHECK_IS_ON() |
| 90 unsigned SaveCount() const; | 96 unsigned SaveCount() const; |
| 91 #endif | 97 #endif |
| 92 | 98 |
| 99 void SetHighContrast(const HighContrastSettings&); | |
| 100 | |
| 93 float StrokeThickness() const { | 101 float StrokeThickness() const { |
| 94 return ImmutableState()->GetStrokeData().Thickness(); | 102 return ImmutableState()->GetStrokeData().Thickness(); |
| 95 } | 103 } |
| 96 void SetStrokeThickness(float thickness) { | 104 void SetStrokeThickness(float thickness) { |
| 97 MutableState()->SetStrokeThickness(thickness); | 105 MutableState()->SetStrokeThickness(thickness); |
| 98 } | 106 } |
| 99 | 107 |
| 100 StrokeStyle GetStrokeStyle() const { | 108 StrokeStyle GetStrokeStyle() const { |
| 101 return ImmutableState()->GetStrokeData().Style(); | 109 return ImmutableState()->GetStrokeData().Style(); |
| 102 } | 110 } |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 424 } | 432 } |
| 425 } | 433 } |
| 426 } | 434 } |
| 427 | 435 |
| 428 void FillRectWithRoundedHole(const FloatRect&, | 436 void FillRectWithRoundedHole(const FloatRect&, |
| 429 const FloatRoundedRect& rounded_hole_rect, | 437 const FloatRoundedRect& rounded_hole_rect, |
| 430 const Color&); | 438 const Color&); |
| 431 | 439 |
| 432 const SkMetaData& MetaData() const { return meta_data_; } | 440 const SkMetaData& MetaData() const { return meta_data_; } |
| 433 | 441 |
| 442 void UpdateHighContrastFilterFromSettings(); | |
| 443 Color ApplyHighContrastFilter(const Color& input) const; | |
| 444 PaintFlags ApplyHighContrastFilter(const PaintFlags* input) const; | |
| 445 | |
| 434 // null indicates painting is contextDisabled. Never delete this object. | 446 // null indicates painting is contextDisabled. Never delete this object. |
| 435 PaintCanvas* canvas_; | 447 PaintCanvas* canvas_; |
| 436 | 448 |
| 437 PaintController& paint_controller_; | 449 PaintController& paint_controller_; |
| 438 | 450 |
| 439 // Paint states stack. The state controls the appearance of drawn content, so | 451 // Paint states stack. The state controls the appearance of drawn content, so |
| 440 // this stack enables local drawing state changes with save()/restore() calls. | 452 // this stack enables local drawing state changes with save()/restore() calls. |
| 441 // We do not delete from this stack to avoid memory churn. | 453 // We do not delete from this stack to avoid memory churn. |
| 442 Vector<std::unique_ptr<GraphicsContextState>> paint_state_stack_; | 454 Vector<std::unique_ptr<GraphicsContextState>> paint_state_stack_; |
| 443 | 455 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 454 #if DCHECK_IS_ON() | 466 #if DCHECK_IS_ON() |
| 455 int layer_count_; | 467 int layer_count_; |
| 456 bool disable_destruction_checks_; | 468 bool disable_destruction_checks_; |
| 457 bool in_drawing_recorder_; | 469 bool in_drawing_recorder_; |
| 458 #endif | 470 #endif |
| 459 | 471 |
| 460 const DisabledMode disabled_state_; | 472 const DisabledMode disabled_state_; |
| 461 | 473 |
| 462 float device_scale_factor_; | 474 float device_scale_factor_; |
| 463 | 475 |
| 476 HighContrastSettings high_contrast_settings_; | |
| 477 sk_sp<SkColorFilter> high_contrast_filter_; | |
| 478 | |
| 464 unsigned printing_ : 1; | 479 unsigned printing_ : 1; |
| 465 unsigned has_meta_data_ : 1; | 480 unsigned has_meta_data_ : 1; |
| 466 }; | 481 }; |
| 467 | 482 |
| 468 } // namespace blink | 483 } // namespace blink |
| 469 | 484 |
| 470 #endif // GraphicsContext_h | 485 #endif // GraphicsContext_h |
| OLD | NEW |