Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: Source/core/platform/graphics/GraphicsContext.h

Issue 14160005: Track the region where text is painted. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fixed build on win and mac Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 class AffineTransform; 62 class AffineTransform;
63 class DrawingBuffer; 63 class DrawingBuffer;
64 class Generator; 64 class Generator;
65 class ImageBuffer; 65 class ImageBuffer;
66 class IntRect; 66 class IntRect;
67 class RoundedRect; 67 class RoundedRect;
68 class KURL; 68 class KURL;
69 class GraphicsContext3D; 69 class GraphicsContext3D;
70 class PlatformContextSkiaState; 70 class PlatformContextSkiaState;
71 class TextRun; 71 class TextRun;
72 struct TextRunPaintInfo;
72 class TransformationMatrix; 73 class TransformationMatrix;
73 74
74 enum TextDrawingMode { 75 enum TextDrawingMode {
75 TextModeFill = 1 << 0, 76 TextModeFill = 1 << 0,
76 TextModeStroke = 1 << 1, 77 TextModeStroke = 1 << 1,
77 }; 78 };
78 typedef unsigned TextDrawingModeFlags; 79 typedef unsigned TextDrawingModeFlags;
79 80
80 enum StrokeStyle { 81 enum StrokeStyle {
81 NoStroke, 82 NoStroke,
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 void setPrinting(bool printing) { m_printing = printing; } 289 void setPrinting(bool printing) { m_printing = printing; }
289 290
290 bool isAccelerated() const { return m_accelerated; } 291 bool isAccelerated() const { return m_accelerated; }
291 void setAccelerated(bool accelerated) { m_accelerated = accelerated; } 292 void setAccelerated(bool accelerated) { m_accelerated = accelerated; }
292 293
293 // The opaque region is empty until tracking is turned on. 294 // The opaque region is empty until tracking is turned on.
294 // It is never clerared by the context. 295 // It is never clerared by the context.
295 void setTrackOpaqueRegion(bool track) { m_trackOpaqueRegion = track; } 296 void setTrackOpaqueRegion(bool track) { m_trackOpaqueRegion = track; }
296 const OpaqueRegionSkia& opaqueRegion() const { return m_opaqueRegion; } 297 const OpaqueRegionSkia& opaqueRegion() const { return m_opaqueRegion; }
297 298
299 // The text region is empty until tracking is turned on.
300 // It is never clerared by the context.
301 void setTrackTextRegion(bool track) { m_trackTextRegion = track; }
302 const SkRect& textRegion() const { return m_textRegion; }
303
298 void setImageInterpolationQuality(InterpolationQuality); 304 void setImageInterpolationQuality(InterpolationQuality);
299 InterpolationQuality imageInterpolationQuality() const; 305 InterpolationQuality imageInterpolationQuality() const;
300 306
301 void save(); 307 void save();
302 void restore(); 308 void restore();
303 309
304 void saveLayer(const SkRect* bounds, const SkPaint*, SkCanvas::SaveFlags = S kCanvas::kARGB_ClipLayer_SaveFlag); 310 void saveLayer(const SkRect* bounds, const SkPaint*, SkCanvas::SaveFlags = S kCanvas::kARGB_ClipLayer_SaveFlag);
305 void restoreLayer(); 311 void restoreLayer();
306 312
307 // Sets up the paint for the current fill style. 313 // Sets up the paint for the current fill style.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 void drawBitmap(const SkBitmap&, SkScalar, SkScalar, const SkPaint* = 0); 372 void drawBitmap(const SkBitmap&, SkScalar, SkScalar, const SkPaint* = 0);
367 void drawBitmapRect(const SkBitmap&, const SkIRect*, const SkRect&, const Sk Paint* = 0); 373 void drawBitmapRect(const SkBitmap&, const SkIRect*, const SkRect&, const Sk Paint* = 0);
368 void drawOval(const SkRect&, const SkPaint&); 374 void drawOval(const SkRect&, const SkPaint&);
369 void drawPath(const SkPath&, const SkPaint&); 375 void drawPath(const SkPath&, const SkPaint&);
370 // After drawing directly to the context's canvas, use this function to noti fy the context so 376 // After drawing directly to the context's canvas, use this function to noti fy the context so
371 // it can track the opaque region. 377 // it can track the opaque region.
372 // FIXME: this is still needed only because ImageSkia::paintSkBitmap() may n eed to notify for a 378 // FIXME: this is still needed only because ImageSkia::paintSkBitmap() may n eed to notify for a
373 // smaller rect than the one drawn to, due to its clipping logic. 379 // smaller rect than the one drawn to, due to its clipping logic.
374 void didDrawRect(const SkRect&, const SkPaint&, const SkBitmap* = 0); 380 void didDrawRect(const SkRect&, const SkPaint&, const SkBitmap* = 0);
375 void drawRect(const SkRect&, const SkPaint&); 381 void drawRect(const SkRect&, const SkPaint&);
376 void drawPosText(const void* text, size_t byteLength, const SkPoint pos[], c onst SkPaint&); 382 void drawPosText(const void* text, size_t byteLength, const SkPoint pos[], c onst SkRect& textRect, const SkPaint&);
377 void drawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[] , SkScalar constY, const SkPaint&); 383 void drawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[] , SkScalar constY, const SkRect& textRect, const SkPaint&);
378 void drawTextOnPath(const void* text, size_t byteLength, const SkPath&, cons t SkMatrix*, const SkPaint&); 384 void drawTextOnPath(const void* text, size_t byteLength, const SkPath&, cons t SkRect& textRect, const SkMatrix*, const SkPaint&);
379 385
380 void clip(const IntRect&); 386 void clip(const IntRect&);
381 void clip(const FloatRect&); 387 void clip(const FloatRect&);
382 void clipRoundedRect(const RoundedRect&); 388 void clipRoundedRect(const RoundedRect&);
383 void clipOut(const IntRect&); 389 void clipOut(const IntRect&);
384 void clipOutRoundedRect(const RoundedRect&); 390 void clipOutRoundedRect(const RoundedRect&);
385 void clipPath(const Path&, WindRule); 391 void clipPath(const Path&, WindRule);
386 void clipConvexPolygon(size_t numPoints, const FloatPoint*, bool antialias = true); 392 void clipConvexPolygon(size_t numPoints, const FloatPoint*, bool antialias = true);
387 void clipToImageBuffer(ImageBuffer*, const FloatRect&); 393 void clipToImageBuffer(ImageBuffer*, const FloatRect&);
388 394
389 TextDrawingModeFlags textDrawingMode() const; 395 TextDrawingModeFlags textDrawingMode() const;
390 void setTextDrawingMode(TextDrawingModeFlags); 396 void setTextDrawingMode(TextDrawingModeFlags);
391 397
392 void drawText(const Font&, const TextRun&, const FloatPoint&, int from = 0, int to = -1); 398 void drawText(const Font&, const TextRunPaintInfo&, const FloatPoint&);
393 void drawEmphasisMarks(const Font&, const TextRun& , const AtomicString& mar k, const FloatPoint&, int from = 0, int to = -1); 399 void drawEmphasisMarks(const Font&, const TextRunPaintInfo&, const AtomicStr ing& mark, const FloatPoint&);
394 void drawBidiText(const Font&, const TextRun&, const FloatPoint&, Font::Cust omFontNotReadyAction = Font::DoNotPaintIfFontNotReady); 400 void drawBidiText(const Font&, const TextRunPaintInfo&, const FloatPoint&, F ont::CustomFontNotReadyAction = Font::DoNotPaintIfFontNotReady);
395 void drawHighlightForText(const Font&, const TextRun&, const FloatPoint&, in t h, const Color& backgroundColor, ColorSpace, int from = 0, int to = -1); 401 void drawHighlightForText(const Font&, const TextRun&, const FloatPoint&, in t h, const Color& backgroundColor, ColorSpace, int from = 0, int to = -1);
396 402
397 void drawLineForText(const FloatPoint&, float width, bool printing); 403 void drawLineForText(const FloatPoint&, float width, bool printing);
398 enum DocumentMarkerLineStyle { 404 enum DocumentMarkerLineStyle {
399 DocumentMarkerSpellingLineStyle, 405 DocumentMarkerSpellingLineStyle,
400 DocumentMarkerGrammarLineStyle, 406 DocumentMarkerGrammarLineStyle,
401 DocumentMarkerAutocorrectionReplacementLineStyle, 407 DocumentMarkerAutocorrectionReplacementLineStyle,
402 DocumentMarkerDictationAlternativesLineStyle 408 DocumentMarkerDictationAlternativesLineStyle
403 }; 409 };
404 void drawLineForDocumentMarker(const FloatPoint&, float width, DocumentMarke rLineStyle); 410 void drawLineForDocumentMarker(const FloatPoint&, float width, DocumentMarke rLineStyle);
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 563
558 // Apply deferred saves 564 // Apply deferred saves
559 void realizeSave(SkCanvas::SaveFlags flags) 565 void realizeSave(SkCanvas::SaveFlags flags)
560 { 566 {
561 if (m_deferredSaveFlags & flags) { 567 if (m_deferredSaveFlags & flags) {
562 m_canvas->save((SkCanvas::SaveFlags)m_deferredSaveFlags); 568 m_canvas->save((SkCanvas::SaveFlags)m_deferredSaveFlags);
563 m_deferredSaveFlags = 0; 569 m_deferredSaveFlags = 0;
564 } 570 }
565 } 571 }
566 572
573 void didDrawTextInRect(const SkRect& textRect);
574
567 // null indicates painting is disabled. Never delete this object. 575 // null indicates painting is disabled. Never delete this object.
568 SkCanvas* m_canvas; 576 SkCanvas* m_canvas;
569 577
570 // The two versions of state will be merged and rationalize in a follow on p atch. 578 // The two versions of state will be merged and rationalize in a follow on p atch.
571 // FIXME: crbug.com/235470 579 // FIXME: crbug.com/235470
572 // Pointer to the current drawing state. This is a cached value of 580 // Pointer to the current drawing state. This is a cached value of
573 // mStateStack.back(). 581 // mStateStack.back().
574 GraphicsContextState m_state; 582 GraphicsContextState m_state;
575 PlatformContextSkiaState* m_skiaState; 583 PlatformContextSkiaState* m_skiaState;
576 // States stack. Enables local drawing state change with save()/restore() ca lls. 584 // States stack. Enables local drawing state change with save()/restore() ca lls.
577 Vector<GraphicsContextState> m_stack; 585 Vector<GraphicsContextState> m_stack;
578 Vector<PlatformContextSkiaState> m_stateStack; 586 Vector<PlatformContextSkiaState> m_stateStack;
579 587
580 // Currently pending save flags. 588 // Currently pending save flags.
581 // FIXME: While defined as a bitmask of SkCanvas::SaveFlags, this is mostly used as a bool. 589 // FIXME: While defined as a bitmask of SkCanvas::SaveFlags, this is mostly used as a bool.
582 // It will come in handy when adding granular save() support (clip vs . matrix vs. paint). 590 // It will come in handy when adding granular save() support (clip vs . matrix vs. paint).
583 // crbug.com/233713 591 // crbug.com/233713
584 struct DeferredSaveState; 592 struct DeferredSaveState;
585 unsigned m_deferredSaveFlags; 593 unsigned m_deferredSaveFlags;
586 Vector<DeferredSaveState> m_saveStateStack; 594 Vector<DeferredSaveState> m_saveStateStack;
587 595
588 #if !ASSERT_DISABLED 596 #if !ASSERT_DISABLED
589 unsigned m_transparencyCount; 597 unsigned m_transparencyCount;
590 #endif 598 #endif
591 // Tracks the region painted opaque via the GraphicsContext. 599 // Tracks the region painted opaque via the GraphicsContext.
592 OpaqueRegionSkia m_opaqueRegion; 600 OpaqueRegionSkia m_opaqueRegion;
593 bool m_trackOpaqueRegion; 601 bool m_trackOpaqueRegion;
594 602
603 // Tracks the region where text is painted via the GraphicsContext.
604 bool m_trackTextRegion;
605 SkRect m_textRegion;
606
595 // Are we on a high DPI display? If so, spelling and grammer markers are lar ger. 607 // Are we on a high DPI display? If so, spelling and grammer markers are lar ger.
596 bool m_useHighResMarker; 608 bool m_useHighResMarker;
597 // FIXME: Make this go away: crbug.com/236892 609 // FIXME: Make this go away: crbug.com/236892
598 bool m_updatingControlTints; 610 bool m_updatingControlTints;
599 bool m_accelerated; 611 bool m_accelerated;
600 bool m_isCertainlyOpaque; 612 bool m_isCertainlyOpaque;
601 bool m_printing; 613 bool m_printing;
602 }; 614 };
603 615
604 } // namespace WebCore 616 } // namespace WebCore
605 617
606 #endif // GraphicsContext_h 618 #endif // GraphicsContext_h
OLDNEW
« no previous file with comments | « Source/core/platform/graphics/FontFastPath.cpp ('k') | Source/core/platform/graphics/GraphicsContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698