| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 #include "platform/graphics/OpaqueRectTrackingContentLayerDelegate.h" | 27 #include "platform/graphics/OpaqueRectTrackingContentLayerDelegate.h" |
| 28 | 28 |
| 29 #include "platform/EventTracer.h" | 29 #include "platform/EventTracer.h" |
| 30 #include "platform/geometry/IntRect.h" | 30 #include "platform/geometry/IntRect.h" |
| 31 #include "platform/graphics/GraphicsContext.h" | 31 #include "platform/graphics/GraphicsContext.h" |
| 32 #include "platform/transforms/AffineTransform.h" | 32 #include "platform/transforms/AffineTransform.h" |
| 33 #include "public/platform/WebFloatRect.h" | 33 #include "public/platform/WebFloatRect.h" |
| 34 #include "public/platform/WebRect.h" | 34 #include "public/platform/WebRect.h" |
| 35 | 35 |
| 36 using blink::WebFloatRect; | |
| 37 using blink::WebRect; | |
| 38 | |
| 39 namespace blink { | 36 namespace blink { |
| 40 | 37 |
| 41 OpaqueRectTrackingContentLayerDelegate::OpaqueRectTrackingContentLayerDelegate(G
raphicsContextPainter* painter) | 38 OpaqueRectTrackingContentLayerDelegate::OpaqueRectTrackingContentLayerDelegate(G
raphicsContextPainter* painter) |
| 42 : m_painter(painter) | 39 : m_painter(painter) |
| 43 , m_opaque(false) | 40 , m_opaque(false) |
| 44 { | 41 { |
| 45 } | 42 } |
| 46 | 43 |
| 47 OpaqueRectTrackingContentLayerDelegate::~OpaqueRectTrackingContentLayerDelegate(
) | 44 OpaqueRectTrackingContentLayerDelegate::~OpaqueRectTrackingContentLayerDelegate(
) |
| 48 { | 45 { |
| 49 } | 46 } |
| 50 | 47 |
| 51 void OpaqueRectTrackingContentLayerDelegate::paintContents( | 48 void OpaqueRectTrackingContentLayerDelegate::paintContents( |
| 52 SkCanvas* canvas, const WebRect& clip, bool canPaintLCDText, WebFloatRect& o
paque, | 49 SkCanvas* canvas, const WebRect& clip, bool canPaintLCDText, WebFloatRect& o
paque, |
| 53 blink::WebContentLayerClient::GraphicsContextStatus contextStatus) | 50 WebContentLayerClient::GraphicsContextStatus contextStatus) |
| 54 { | 51 { |
| 55 static const unsigned char* annotationsEnabled = 0; | 52 static const unsigned char* annotationsEnabled = 0; |
| 56 if (UNLIKELY(!annotationsEnabled)) | 53 if (UNLIKELY(!annotationsEnabled)) |
| 57 annotationsEnabled = EventTracer::getTraceCategoryEnabledFlag(TRACE_DISA
BLED_BY_DEFAULT("blink.graphics_context_annotations")); | 54 annotationsEnabled = EventTracer::getTraceCategoryEnabledFlag(TRACE_DISA
BLED_BY_DEFAULT("blink.graphics_context_annotations")); |
| 58 | 55 |
| 59 GraphicsContext context(canvas, | 56 GraphicsContext context(canvas, |
| 60 contextStatus == blink::WebContentLayerClient::GraphicsContextEnabled ?
GraphicsContext::NothingDisabled : GraphicsContext::FullyDisabled); | 57 contextStatus == WebContentLayerClient::GraphicsContextEnabled ? Graphic
sContext::NothingDisabled : GraphicsContext::FullyDisabled); |
| 61 context.setRegionTrackingMode(m_opaque ? GraphicsContext::RegionTrackingDisa
bled : GraphicsContext::RegionTrackingOpaque); | 58 context.setRegionTrackingMode(m_opaque ? GraphicsContext::RegionTrackingDisa
bled : GraphicsContext::RegionTrackingOpaque); |
| 62 context.setCertainlyOpaque(m_opaque); | 59 context.setCertainlyOpaque(m_opaque); |
| 63 context.setShouldSmoothFonts(canPaintLCDText); | 60 context.setShouldSmoothFonts(canPaintLCDText); |
| 64 | 61 |
| 65 if (*annotationsEnabled) | 62 if (*annotationsEnabled) |
| 66 context.setAnnotationMode(AnnotateAll); | 63 context.setAnnotationMode(AnnotateAll); |
| 67 | 64 |
| 68 // Record transform prior to painting, as all opaque tracking will be | 65 // Record transform prior to painting, as all opaque tracking will be |
| 69 // relative to this current value. | 66 // relative to this current value. |
| 70 AffineTransform canvasToContentTransform = context.getCTM().inverse(); | 67 AffineTransform canvasToContentTransform = context.getCTM().inverse(); |
| 71 | 68 |
| 72 m_painter->paint(context, clip); | 69 m_painter->paint(context, clip); |
| 73 | 70 |
| 74 // Transform tracked opaque paints back to our layer's content space. | 71 // Transform tracked opaque paints back to our layer's content space. |
| 75 ASSERT(canvasToContentTransform.isInvertible()); | 72 ASSERT(canvasToContentTransform.isInvertible()); |
| 76 ASSERT(canvasToContentTransform.preservesAxisAlignment()); | 73 ASSERT(canvasToContentTransform.preservesAxisAlignment()); |
| 77 opaque = canvasToContentTransform.mapRect(context.opaqueRegion().asRect()); | 74 opaque = canvasToContentTransform.mapRect(context.opaqueRegion().asRect()); |
| 78 } | 75 } |
| 79 | 76 |
| 80 } | 77 } // namespace blink |
| OLD | NEW |