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

Side by Side Diff: Source/platform/graphics/GraphicsContext.cpp

Issue 216553003: Disable painting in a few more places (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 // collapsed. Therefore, subpixel text is disabled when we are drawing 384 // collapsed. Therefore, subpixel text is disabled when we are drawing
385 // onto a layer. 385 // onto a layer.
386 if (paintingDisabled() || isDrawingToLayer() || !isCertainlyOpaque()) 386 if (paintingDisabled() || isDrawingToLayer() || !isCertainlyOpaque())
387 return false; 387 return false;
388 388
389 return shouldSmoothFonts(); 389 return shouldSmoothFonts();
390 } 390 }
391 391
392 void GraphicsContext::setCompositeOperation(CompositeOperator compositeOperation , WebBlendMode blendMode) 392 void GraphicsContext::setCompositeOperation(CompositeOperator compositeOperation , WebBlendMode blendMode)
393 { 393 {
394 if (paintingDisabled())
395 return;
394 mutableState()->setCompositeOperation(compositeOperation, blendMode); 396 mutableState()->setCompositeOperation(compositeOperation, blendMode);
395 } 397 }
396 398
397 SkColorFilter* GraphicsContext::colorFilter() 399 SkColorFilter* GraphicsContext::colorFilter()
398 { 400 {
399 return immutableState()->colorFilter(); 401 return immutableState()->colorFilter();
400 } 402 }
401 403
402 void GraphicsContext::setColorFilter(ColorFilter colorFilter) 404 void GraphicsContext::setColorFilter(ColorFilter colorFilter)
403 { 405 {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 } 484 }
483 485
484 void GraphicsContext::beginRecording(const FloatRect& bounds) 486 void GraphicsContext::beginRecording(const FloatRect& bounds)
485 { 487 {
486 RefPtr<DisplayList> displayList = adoptRef(new DisplayList(bounds)); 488 RefPtr<DisplayList> displayList = adoptRef(new DisplayList(bounds));
487 489
488 SkCanvas* savedCanvas = m_canvas; 490 SkCanvas* savedCanvas = m_canvas;
489 SkMatrix savedMatrix = getTotalMatrix(); 491 SkMatrix savedMatrix = getTotalMatrix();
490 492
491 IntRect recordingRect = enclosingIntRect(bounds); 493 IntRect recordingRect = enclosingIntRect(bounds);
492 m_canvas = displayList->picture()->beginRecording(recordingRect.width(), rec ordingRect.height(), 494 if (!paintingDisabled()) {
Stephen Chennney 2014/03/28 12:47:18 This can go up a line - I don't see us using recor
493 SkPicture::kUsePathBoundsForClip_RecordingFlag); 495 m_canvas = displayList->picture()->beginRecording(recordingRect.width(), recordingRect.height(),
496 SkPicture::kUsePathBoundsForClip_RecordingFlag);
494 497
495 // We want the bounds offset mapped to (0, 0), such that the display list co ntent 498 // We want the bounds offset mapped to (0, 0), such that the display lis t content
496 // is fully contained within the SkPictureRecord's bounds. 499 // is fully contained within the SkPictureRecord's bounds.
497 if (!toFloatSize(bounds.location()).isZero()) { 500 if (!toFloatSize(bounds.location()).isZero()) {
498 m_canvas->translate(-bounds.x(), -bounds.y()); 501 m_canvas->translate(-bounds.x(), -bounds.y());
499 // To avoid applying the offset repeatedly in getTotalMatrix(), we pre-a pply it here. 502 // To avoid applying the offset repeatedly in getTotalMatrix(), we p re-apply it here.
500 savedMatrix.preTranslate(bounds.x(), bounds.y()); 503 savedMatrix.preTranslate(bounds.x(), bounds.y());
504 }
501 } 505 }
502 506
503 m_recordingStateStack.append(RecordingState(savedCanvas, savedMatrix, displa yList)); 507 m_recordingStateStack.append(RecordingState(savedCanvas, savedMatrix, displa yList));
504 } 508 }
505 509
506 PassRefPtr<DisplayList> GraphicsContext::endRecording() 510 PassRefPtr<DisplayList> GraphicsContext::endRecording()
507 { 511 {
508 ASSERT(!m_recordingStateStack.isEmpty()); 512 ASSERT(!m_recordingStateStack.isEmpty());
509 513
510 RecordingState recording = m_recordingStateStack.last(); 514 RecordingState recording = m_recordingStateStack.last();
511 ASSERT(recording.m_displayList->picture()->getRecordingCanvas()); 515 if (!paintingDisabled()) {
512 recording.m_displayList->picture()->endRecording(); 516 ASSERT(recording.m_displayList->picture()->getRecordingCanvas());
517 recording.m_displayList->picture()->endRecording();
518 }
513 519
514 m_recordingStateStack.removeLast(); 520 m_recordingStateStack.removeLast();
515 m_canvas = recording.m_savedCanvas; 521 m_canvas = recording.m_savedCanvas;
516 522
517 return recording.m_displayList.release(); 523 return recording.m_displayList.release();
518 } 524 }
519 525
520 bool GraphicsContext::isRecording() const 526 bool GraphicsContext::isRecording() const
521 { 527 {
522 return !m_recordingStateStack.isEmpty(); 528 return !m_recordingStateStack.isEmpty();
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 if (shadowSpread < 0) 648 if (shadowSpread < 0)
643 bounds.inflate(-shadowSpread); 649 bounds.inflate(-shadowSpread);
644 650
645 IntRect offsetBounds = bounds; 651 IntRect offsetBounds = bounds;
646 offsetBounds.move(-shadowOffset); 652 offsetBounds.move(-shadowOffset);
647 return unionRect(bounds, offsetBounds); 653 return unionRect(bounds, offsetBounds);
648 } 654 }
649 655
650 void GraphicsContext::drawInnerShadow(const RoundedRect& rect, const Color& shad owColor, const IntSize shadowOffset, int shadowBlur, int shadowSpread, Edges cli ppedEdges) 656 void GraphicsContext::drawInnerShadow(const RoundedRect& rect, const Color& shad owColor, const IntSize shadowOffset, int shadowBlur, int shadowSpread, Edges cli ppedEdges)
651 { 657 {
658 if (paintingDisabled())
659 return;
660
652 IntRect holeRect(rect.rect()); 661 IntRect holeRect(rect.rect());
653 holeRect.inflate(-shadowSpread); 662 holeRect.inflate(-shadowSpread);
654 663
655 if (holeRect.isEmpty()) { 664 if (holeRect.isEmpty()) {
656 if (rect.isRounded()) 665 if (rect.isRounded())
657 fillRoundedRect(rect, shadowColor); 666 fillRoundedRect(rect, shadowColor);
658 else 667 else
659 fillRect(rect.rect(), shadowColor); 668 fillRect(rect.rect(), shadowColor);
660 return; 669 return;
661 } 670 }
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 paint.setAlpha(0x80); // signal to m_opaqueRegion that we are not fu lly opaque 1126 paint.setAlpha(0x80); // signal to m_opaqueRegion that we are not fu lly opaque
1118 1127
1119 m_opaqueRegion.didDrawRect(this, rect, paint, 0); 1128 m_opaqueRegion.didDrawRect(this, rect, paint, 0);
1120 // more efficient would be to call markRectAsOpaque or MarkRectAsNonOpaq ue directly, 1129 // more efficient would be to call markRectAsOpaque or MarkRectAsNonOpaq ue directly,
1121 // rather than cons-ing up a paint with an xfermode and alpha 1130 // rather than cons-ing up a paint with an xfermode and alpha
1122 } 1131 }
1123 } 1132 }
1124 1133
1125 void GraphicsContext::writePixels(const SkBitmap& bitmap, int x, int y) 1134 void GraphicsContext::writePixels(const SkBitmap& bitmap, int x, int y)
1126 { 1135 {
1136 if (paintingDisabled())
1137 return;
1138
1127 if (!bitmap.getTexture()) { 1139 if (!bitmap.getTexture()) {
1128 SkAutoLockPixels alp(bitmap); 1140 SkAutoLockPixels alp(bitmap);
1129 if (bitmap.getPixels()) 1141 if (bitmap.getPixels())
1130 writePixels(bitmap.info(), bitmap.getPixels(), bitmap.rowBytes(), x, y); 1142 writePixels(bitmap.info(), bitmap.getPixels(), bitmap.rowBytes(), x, y);
1131 } 1143 }
1132 } 1144 }
1133 1145
1134 void GraphicsContext::drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, const SkPaint* paint) 1146 void GraphicsContext::drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, const SkPaint* paint)
1135 { 1147 {
1136 if (paintingDisabled()) 1148 if (paintingDisabled())
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 return; 1199 return;
1188 1200
1189 m_canvas->drawRect(rect, paint); 1201 m_canvas->drawRect(rect, paint);
1190 1202
1191 if (m_trackOpaqueRegion) 1203 if (m_trackOpaqueRegion)
1192 m_opaqueRegion.didDrawRect(this, rect, paint, 0); 1204 m_opaqueRegion.didDrawRect(this, rect, paint, 0);
1193 } 1205 }
1194 1206
1195 void GraphicsContext::didDrawRect(const SkRect& rect, const SkPaint& paint, cons t SkBitmap* bitmap) 1207 void GraphicsContext::didDrawRect(const SkRect& rect, const SkPaint& paint, cons t SkBitmap* bitmap)
1196 { 1208 {
1209 if (paintingDisabled())
1210 return;
1211
1197 if (m_trackOpaqueRegion) 1212 if (m_trackOpaqueRegion)
1198 m_opaqueRegion.didDrawRect(this, rect, paint, bitmap); 1213 m_opaqueRegion.didDrawRect(this, rect, paint, bitmap);
1199 } 1214 }
1200 1215
1201 void GraphicsContext::drawPosText(const void* text, size_t byteLength, 1216 void GraphicsContext::drawPosText(const void* text, size_t byteLength,
1202 const SkPoint pos[], const SkRect& textRect, const SkPaint& paint) 1217 const SkPoint pos[], const SkRect& textRect, const SkPaint& paint)
1203 { 1218 {
1204 if (paintingDisabled()) 1219 if (paintingDisabled())
1205 return; 1220 return;
1206 1221
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1612 return; 1627 return;
1613 1628
1614 CompositeOperator previousOperator = compositeOperation(); 1629 CompositeOperator previousOperator = compositeOperation();
1615 setCompositeOperation(op); 1630 setCompositeOperation(op);
1616 fillRect(rect, color); 1631 fillRect(rect, color);
1617 setCompositeOperation(previousOperator); 1632 setCompositeOperation(previousOperator);
1618 } 1633 }
1619 1634
1620 void GraphicsContext::fillRoundedRect(const RoundedRect& rect, const Color& colo r) 1635 void GraphicsContext::fillRoundedRect(const RoundedRect& rect, const Color& colo r)
1621 { 1636 {
1637 if (paintingDisabled())
1638 return;
1639
1622 if (rect.isRounded()) 1640 if (rect.isRounded())
1623 fillRoundedRect(rect.rect(), rect.radii().topLeft(), rect.radii().topRig ht(), rect.radii().bottomLeft(), rect.radii().bottomRight(), color); 1641 fillRoundedRect(rect.rect(), rect.radii().topLeft(), rect.radii().topRig ht(), rect.radii().bottomLeft(), rect.radii().bottomRight(), color);
1624 else 1642 else
1625 fillRect(rect.rect(), color); 1643 fillRect(rect.rect(), color);
1626 } 1644 }
1627 1645
1628 void GraphicsContext::fillRectWithRoundedHole(const IntRect& rect, const Rounded Rect& roundedHoleRect, const Color& color) 1646 void GraphicsContext::fillRectWithRoundedHole(const IntRect& rect, const Rounded Rect& roundedHoleRect, const Color& color)
1629 { 1647 {
1630 if (paintingDisabled()) 1648 if (paintingDisabled())
1631 return; 1649 return;
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1889 1907
1890 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) 1908 void GraphicsContext::didDrawTextInRect(const SkRect& textRect)
1891 { 1909 {
1892 if (m_trackTextRegion) { 1910 if (m_trackTextRegion) {
1893 TRACE_EVENT0("skia", "PlatformContextSkia::trackTextRegion"); 1911 TRACE_EVENT0("skia", "PlatformContextSkia::trackTextRegion");
1894 m_textRegion.join(textRect); 1912 m_textRegion.join(textRect);
1895 } 1913 }
1896 } 1914 }
1897 1915
1898 } 1916 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698