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

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

Issue 541913002: Create a GraphicsContext from a DisplayList. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@display-list-changes
Patch Set: Rebased. Created 6 years, 3 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 | « Source/platform/graphics/GraphicsContext.h ('k') | Source/web/LinkHighlight.h » ('j') | 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 , m_disabledState(disableContextOrPainting) 128 , m_disabledState(disableContextOrPainting)
129 , m_deviceScaleFactor(1.0f) 129 , m_deviceScaleFactor(1.0f)
130 , m_regionTrackingMode(RegionTrackingDisabled) 130 , m_regionTrackingMode(RegionTrackingDisabled)
131 , m_trackTextRegion(false) 131 , m_trackTextRegion(false)
132 , m_accelerated(false) 132 , m_accelerated(false)
133 , m_isCertainlyOpaque(true) 133 , m_isCertainlyOpaque(true)
134 , m_printing(false) 134 , m_printing(false)
135 , m_antialiasHairlineImages(false) 135 , m_antialiasHairlineImages(false)
136 , m_shouldSmoothFonts(true) 136 , m_shouldSmoothFonts(true)
137 { 137 {
138 ASSERT(canvas);
139
140 // FIXME: Do some tests to determine how many states are typically used, and allocate 138 // FIXME: Do some tests to determine how many states are typically used, and allocate
141 // several here. 139 // several here.
142 m_paintStateStack.append(GraphicsContextState::create()); 140 m_paintStateStack.append(GraphicsContextState::create());
143 m_paintState = m_paintStateStack.last().get(); 141 m_paintState = m_paintStateStack.last().get();
144 } 142 }
145 143
146 GraphicsContext::~GraphicsContext() 144 GraphicsContext::~GraphicsContext()
147 { 145 {
148 #if ENABLE(ASSERT) 146 #if ENABLE(ASSERT)
149 if (!m_disableDestructionChecks) { 147 if (!m_disableDestructionChecks) {
150 ASSERT(!m_paintStateIndex); 148 ASSERT(!m_paintStateIndex);
151 ASSERT(!m_paintState->saveCount()); 149 ASSERT(!m_paintState->saveCount());
152 ASSERT(!m_annotationCount); 150 ASSERT(!m_annotationCount);
153 ASSERT(!m_layerCount); 151 ASSERT(!m_layerCount);
154 ASSERT(m_recordingStateStack.isEmpty()); 152 ASSERT(m_recordingStateStack.isEmpty());
155 ASSERT(m_canvasStateStack.isEmpty()); 153 ASSERT(m_canvasStateStack.isEmpty());
156 } 154 }
157 #endif 155 #endif
158 } 156 }
159 157
160 void GraphicsContext::resetCanvas(SkCanvas* canvas) 158 void GraphicsContext::resetCanvas(SkCanvas* canvas)
161 { 159 {
162 ASSERT(canvas);
163 m_canvas = canvas; 160 m_canvas = canvas;
164 m_trackedRegion.reset(); 161 m_trackedRegion.reset();
165 } 162 }
166 163
167 void GraphicsContext::setRegionTrackingMode(RegionTrackingMode mode) 164 void GraphicsContext::setRegionTrackingMode(RegionTrackingMode mode)
168 { 165 {
169 m_regionTrackingMode = mode; 166 m_regionTrackingMode = mode;
170 if (mode == RegionTrackingOpaque) 167 if (mode == RegionTrackingOpaque)
171 m_trackedRegion.setTrackedRegionType(RegionTracker::Opaque); 168 m_trackedRegion.setTrackedRegionType(RegionTracker::Opaque);
172 else if (mode == RegionTrackingOverwrite) 169 else if (mode == RegionTrackingOverwrite)
173 m_trackedRegion.setTrackedRegionType(RegionTracker::Overwrite); 170 m_trackedRegion.setTrackedRegionType(RegionTracker::Overwrite);
174 } 171 }
175 172
176 void GraphicsContext::save() 173 void GraphicsContext::save()
177 { 174 {
178 if (contextDisabled()) 175 if (contextDisabled())
179 return; 176 return;
180 177
181 m_paintState->incrementSaveCount(); 178 m_paintState->incrementSaveCount();
182 179
183 m_canvasStateStack.append(CanvasSaveState(m_pendingCanvasSave, m_canvas->get SaveCount())); 180 if (m_canvas) {
184 m_pendingCanvasSave = true; 181 m_canvasStateStack.append(CanvasSaveState(m_pendingCanvasSave, m_canvas- >getSaveCount()));
182 m_pendingCanvasSave = true;
183 }
185 } 184 }
186 185
187 void GraphicsContext::restore() 186 void GraphicsContext::restore()
188 { 187 {
189 if (contextDisabled()) 188 if (contextDisabled())
190 return; 189 return;
191 190
192 if (!m_paintStateIndex && !m_paintState->saveCount()) { 191 if (!m_paintStateIndex && !m_paintState->saveCount()) {
193 WTF_LOG_ERROR("ERROR void GraphicsContext::restore() stack is empty"); 192 WTF_LOG_ERROR("ERROR void GraphicsContext::restore() stack is empty");
194 return; 193 return;
195 } 194 }
196 195
197 if (m_paintState->saveCount()) { 196 if (m_paintState->saveCount()) {
198 m_paintState->decrementSaveCount(); 197 m_paintState->decrementSaveCount();
199 } else { 198 } else {
200 m_paintStateIndex--; 199 m_paintStateIndex--;
201 m_paintState = m_paintStateStack[m_paintStateIndex].get(); 200 m_paintState = m_paintStateStack[m_paintStateIndex].get();
202 } 201 }
203 202
204 CanvasSaveState savedState = m_canvasStateStack.last(); 203 if (m_canvas) {
205 m_canvasStateStack.removeLast(); 204 ASSERT(m_canvasStateStack.size() > 0);
206 m_pendingCanvasSave = savedState.m_pendingSave; 205 CanvasSaveState savedState = m_canvasStateStack.last();
207 m_canvas->restoreToCount(savedState.m_restoreCount); 206 m_canvasStateStack.removeLast();
207 m_pendingCanvasSave = savedState.m_pendingSave;
208 m_canvas->restoreToCount(savedState.m_restoreCount);
209 }
208 } 210 }
209 211
210 void GraphicsContext::saveLayer(const SkRect* bounds, const SkPaint* paint) 212 void GraphicsContext::saveLayer(const SkRect* bounds, const SkPaint* paint)
211 { 213 {
212 if (contextDisabled()) 214 if (contextDisabled())
213 return; 215 return;
214 216
217 ASSERT(m_canvas);
218
215 realizeCanvasSave(); 219 realizeCanvasSave();
216 220
217 m_canvas->saveLayer(bounds, paint); 221 m_canvas->saveLayer(bounds, paint);
218 if (regionTrackingEnabled()) 222 if (regionTrackingEnabled())
219 m_trackedRegion.pushCanvasLayer(paint); 223 m_trackedRegion.pushCanvasLayer(paint);
220 } 224 }
221 225
222 void GraphicsContext::restoreLayer() 226 void GraphicsContext::restoreLayer()
223 { 227 {
224 if (contextDisabled()) 228 if (contextDisabled())
225 return; 229 return;
226 230
231 ASSERT(m_canvas);
232
227 m_canvas->restore(); 233 m_canvas->restore();
228 if (regionTrackingEnabled()) 234 if (regionTrackingEnabled())
229 m_trackedRegion.popCanvasLayer(this); 235 m_trackedRegion.popCanvasLayer(this);
230 } 236 }
231 237
232 void GraphicsContext::beginAnnotation(const AnnotationList& annotations) 238 void GraphicsContext::beginAnnotation(const AnnotationList& annotations)
233 { 239 {
234 if (contextDisabled()) 240 if (contextDisabled())
235 return; 241 return;
236 242
243 ASSERT(m_canvas);
244
237 canvas()->beginCommentGroup("GraphicsContextAnnotation"); 245 canvas()->beginCommentGroup("GraphicsContextAnnotation");
238 246
239 AnnotationList::const_iterator end = annotations.end(); 247 AnnotationList::const_iterator end = annotations.end();
240 for (AnnotationList::const_iterator it = annotations.begin(); it != end; ++i t) 248 for (AnnotationList::const_iterator it = annotations.begin(); it != end; ++i t)
241 canvas()->addComment(it->first, it->second.ascii().data()); 249 canvas()->addComment(it->first, it->second.ascii().data());
242 250
243 #if ENABLE(ASSERT) 251 #if ENABLE(ASSERT)
244 ++m_annotationCount; 252 ++m_annotationCount;
245 #endif 253 #endif
246 } 254 }
247 255
248 void GraphicsContext::endAnnotation() 256 void GraphicsContext::endAnnotation()
249 { 257 {
250 if (contextDisabled()) 258 if (contextDisabled())
251 return; 259 return;
252 260
261 ASSERT(m_canvas);
253 ASSERT(m_annotationCount > 0); 262 ASSERT(m_annotationCount > 0);
254 canvas()->endCommentGroup(); 263 canvas()->endCommentGroup();
255 264
256 #if ENABLE(ASSERT) 265 #if ENABLE(ASSERT)
257 --m_annotationCount; 266 --m_annotationCount;
258 #endif 267 #endif
259 } 268 }
260 269
261 void GraphicsContext::setStrokePattern(PassRefPtr<Pattern> pattern) 270 void GraphicsContext::setStrokePattern(PassRefPtr<Pattern> pattern)
262 { 271 {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 357
349 bool GraphicsContext::hasShadow() const 358 bool GraphicsContext::hasShadow() const
350 { 359 {
351 return !!immutableState()->drawLooper(); 360 return !!immutableState()->drawLooper();
352 } 361 }
353 362
354 bool GraphicsContext::getTransformedClipBounds(FloatRect* bounds) const 363 bool GraphicsContext::getTransformedClipBounds(FloatRect* bounds) const
355 { 364 {
356 if (contextDisabled()) 365 if (contextDisabled())
357 return false; 366 return false;
367 ASSERT(m_canvas);
358 SkIRect skIBounds; 368 SkIRect skIBounds;
359 if (!m_canvas->getClipDeviceBounds(&skIBounds)) 369 if (!m_canvas->getClipDeviceBounds(&skIBounds))
360 return false; 370 return false;
361 SkRect skBounds = SkRect::Make(skIBounds); 371 SkRect skBounds = SkRect::Make(skIBounds);
362 *bounds = FloatRect(skBounds); 372 *bounds = FloatRect(skBounds);
363 return true; 373 return true;
364 } 374 }
365 375
366 SkMatrix GraphicsContext::getTotalMatrix() const 376 SkMatrix GraphicsContext::getTotalMatrix() const
367 { 377 {
368 if (contextDisabled()) 378 if (contextDisabled() || !m_canvas)
369 return SkMatrix::I(); 379 return SkMatrix::I();
370 380
381 ASSERT(m_canvas);
382
371 if (!isRecording()) 383 if (!isRecording())
372 return m_canvas->getTotalMatrix(); 384 return m_canvas->getTotalMatrix();
373 385
374 const RecordingState& recordingState = m_recordingStateStack.last(); 386 const RecordingState& recordingState = m_recordingStateStack.last();
375 SkMatrix totalMatrix = recordingState.m_savedMatrix; 387 SkMatrix totalMatrix = recordingState.m_savedMatrix;
376 totalMatrix.preConcat(m_canvas->getTotalMatrix()); 388 totalMatrix.preConcat(m_canvas->getTotalMatrix());
377 389
378 return totalMatrix; 390 return totalMatrix;
379 } 391 }
380 392
381 void GraphicsContext::adjustTextRenderMode(SkPaint* paint) const 393 void GraphicsContext::adjustTextRenderMode(SkPaint* paint) const
382 { 394 {
383 if (contextDisabled()) 395 if (contextDisabled())
384 return; 396 return;
385 397
386 if (!paint->isLCDRenderText()) 398 if (!paint->isLCDRenderText())
387 return; 399 return;
388 400
389 paint->setLCDRenderText(couldUseLCDRenderedText()); 401 paint->setLCDRenderText(couldUseLCDRenderedText());
390 } 402 }
391 403
392 bool GraphicsContext::couldUseLCDRenderedText() const 404 bool GraphicsContext::couldUseLCDRenderedText() const
393 { 405 {
406 ASSERT(m_canvas);
394 // Our layers only have a single alpha channel. This means that subpixel 407 // Our layers only have a single alpha channel. This means that subpixel
395 // rendered text cannot be composited correctly when the layer is 408 // rendered text cannot be composited correctly when the layer is
396 // collapsed. Therefore, subpixel text is contextDisabled when we are drawin g 409 // collapsed. Therefore, subpixel text is contextDisabled when we are drawin g
397 // onto a layer. 410 // onto a layer.
398 if (contextDisabled() || m_canvas->isDrawingToLayer() || !isCertainlyOpaque( )) 411 if (contextDisabled() || m_canvas->isDrawingToLayer() || !isCertainlyOpaque( ))
399 return false; 412 return false;
400 413
401 return shouldSmoothFonts(); 414 return shouldSmoothFonts();
402 } 415 }
403 416
(...skipping 17 matching lines...) Expand all
421 // we should switch to using color filter chains (Skia work in progress). 434 // we should switch to using color filter chains (Skia work in progress).
422 ASSERT(!stateToSet->colorFilter()); 435 ASSERT(!stateToSet->colorFilter());
423 stateToSet->setColorFilter(WebCoreColorFilterToSkiaColorFilter(colorFilter)) ; 436 stateToSet->setColorFilter(WebCoreColorFilterToSkiaColorFilter(colorFilter)) ;
424 } 437 }
425 438
426 bool GraphicsContext::readPixels(const SkImageInfo& info, void* pixels, size_t r owBytes, int x, int y) 439 bool GraphicsContext::readPixels(const SkImageInfo& info, void* pixels, size_t r owBytes, int x, int y)
427 { 440 {
428 if (contextDisabled()) 441 if (contextDisabled())
429 return false; 442 return false;
430 443
444 ASSERT(m_canvas);
431 return m_canvas->readPixels(info, pixels, rowBytes, x, y); 445 return m_canvas->readPixels(info, pixels, rowBytes, x, y);
432 } 446 }
433 447
434 void GraphicsContext::setMatrix(const SkMatrix& matrix) 448 void GraphicsContext::setMatrix(const SkMatrix& matrix)
435 { 449 {
436 if (contextDisabled()) 450 if (contextDisabled())
437 return; 451 return;
438 452
453 ASSERT(m_canvas);
439 realizeCanvasSave(); 454 realizeCanvasSave();
440 455
441 m_canvas->setMatrix(matrix); 456 m_canvas->setMatrix(matrix);
442 } 457 }
443 458
444 void GraphicsContext::concat(const SkMatrix& matrix) 459 void GraphicsContext::concat(const SkMatrix& matrix)
445 { 460 {
446 if (contextDisabled()) 461 if (contextDisabled())
447 return; 462 return;
448 463
449 if (matrix.isIdentity()) 464 if (matrix.isIdentity())
450 return; 465 return;
451 466
467 ASSERT(m_canvas);
452 realizeCanvasSave(); 468 realizeCanvasSave();
453 469
454 m_canvas->concat(matrix); 470 m_canvas->concat(matrix);
455 } 471 }
456 472
457 void GraphicsContext::beginTransparencyLayer(float opacity, const FloatRect* bou nds) 473 void GraphicsContext::beginTransparencyLayer(float opacity, const FloatRect* bou nds)
458 { 474 {
459 beginLayer(opacity, immutableState()->compositeOperator(), bounds); 475 beginLayer(opacity, immutableState()->compositeOperator(), bounds);
460 } 476 }
461 477
(...skipping 30 matching lines...) Expand all
492 ASSERT(m_layerCount > 0); 508 ASSERT(m_layerCount > 0);
493 #if ENABLE(ASSERT) 509 #if ENABLE(ASSERT)
494 --m_layerCount; 510 --m_layerCount;
495 #endif 511 #endif
496 } 512 }
497 513
498 void GraphicsContext::beginRecording(const FloatRect& bounds, uint32_t recordFla gs) 514 void GraphicsContext::beginRecording(const FloatRect& bounds, uint32_t recordFla gs)
499 { 515 {
500 RefPtr<DisplayList> displayList = DisplayList::create(bounds); 516 RefPtr<DisplayList> displayList = DisplayList::create(bounds);
501 517
502 SkPictureRecorder* recorder = 0;
503
504 SkCanvas* savedCanvas = m_canvas; 518 SkCanvas* savedCanvas = m_canvas;
505 SkMatrix savedMatrix = getTotalMatrix(); 519 SkMatrix savedMatrix = getTotalMatrix();
520 SkPictureRecorder* recorder = 0;
506 521
507 if (!contextDisabled()) { 522 if (!contextDisabled()) {
508 FloatRect bounds = displayList->bounds(); 523 FloatRect bounds = displayList->bounds();
509 IntSize recordingSize = enclosingIntRect(bounds).size(); 524 IntSize recordingSize = enclosingIntRect(bounds).size();
510 recorder = new SkPictureRecorder; 525 recorder = new SkPictureRecorder;
511 m_canvas = recorder->beginRecording(recordingSize.width(), recordingSize .height(), 0, recordFlags); 526 m_canvas = recorder->beginRecording(recordingSize.width(), recordingSize .height(), 0, recordFlags);
512 527
513 // We want the bounds offset mapped to (0, 0), such that the display lis t content 528 // We want the bounds offset mapped to (0, 0), such that the display lis t content
514 // is fully contained within the SkPictureRecord's bounds. 529 // is fully contained within the SkPictureRecord's bounds.
515 if (!toFloatSize(bounds.location()).isZero()) { 530 if (!toFloatSize(bounds.location()).isZero()) {
(...skipping 22 matching lines...) Expand all
538 } 553 }
539 554
540 bool GraphicsContext::isRecording() const 555 bool GraphicsContext::isRecording() const
541 { 556 {
542 return !m_recordingStateStack.isEmpty(); 557 return !m_recordingStateStack.isEmpty();
543 } 558 }
544 559
545 void GraphicsContext::drawDisplayList(DisplayList* displayList) 560 void GraphicsContext::drawDisplayList(DisplayList* displayList)
546 { 561 {
547 ASSERT(displayList); 562 ASSERT(displayList);
563 ASSERT(m_canvas);
548 564
549 if (contextDisabled() || displayList->bounds().isEmpty()) 565 if (contextDisabled() || displayList->bounds().isEmpty())
550 return; 566 return;
551 567
552 bool performClip = !displayList->clip().isEmpty(); 568 bool performClip = !displayList->clip().isEmpty();
553 bool performTransform = !displayList->transform().isIdentity(); 569 bool performTransform = !displayList->transform().isIdentity();
554 if (performClip || performTransform) { 570 if (performClip || performTransform) {
555 save(); 571 save();
556 if (performTransform) 572 if (performTransform)
557 concat(displayList->transform()); 573 concat(displayList->transform());
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 drawLooperBuilder->addShadow(shadowOffset, shadowBlur, shadowColor, 758 drawLooperBuilder->addShadow(shadowOffset, shadowBlur, shadowColor,
743 DrawLooperBuilder::ShadowRespectsTransforms, DrawLooperBuilder::ShadowIg noresAlpha); 759 DrawLooperBuilder::ShadowRespectsTransforms, DrawLooperBuilder::ShadowIg noresAlpha);
744 setDrawLooper(drawLooperBuilder.release()); 760 setDrawLooper(drawLooperBuilder.release());
745 fillRectWithRoundedHole(outerRect, roundedHole, fillColor); 761 fillRectWithRoundedHole(outerRect, roundedHole, fillColor);
746 restore(); 762 restore();
747 clearDrawLooper(); 763 clearDrawLooper();
748 } 764 }
749 765
750 void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2) 766 void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2)
751 { 767 {
768 ASSERT(m_canvas);
752 if (contextDisabled()) 769 if (contextDisabled())
753 return; 770 return;
754 771
755 StrokeStyle penStyle = strokeStyle(); 772 StrokeStyle penStyle = strokeStyle();
756 if (penStyle == NoStroke) 773 if (penStyle == NoStroke)
757 return; 774 return;
758 775
759 FloatPoint p1 = point1; 776 FloatPoint p1 = point1;
760 FloatPoint p2 = point2; 777 FloatPoint p2 = point2;
761 bool isVerticalLine = (p1.x() == p2.x()); 778 bool isVerticalLine = (p1.x() == p2.x());
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 const FloatRect* src, CompositeOperator op, WebBlendMode blendMode) 1135 const FloatRect* src, CompositeOperator op, WebBlendMode blendMode)
1119 { 1136 {
1120 if (contextDisabled() || !image) 1137 if (contextDisabled() || !image)
1121 return; 1138 return;
1122 1139
1123 image->draw(this, dest, src, op, blendMode); 1140 image->draw(this, dest, src, op, blendMode);
1124 } 1141 }
1125 1142
1126 void GraphicsContext::drawPicture(PassRefPtr<SkPicture> picture, const FloatRect & dest, const FloatRect& src, CompositeOperator op, WebBlendMode blendMode) 1143 void GraphicsContext::drawPicture(PassRefPtr<SkPicture> picture, const FloatRect & dest, const FloatRect& src, CompositeOperator op, WebBlendMode blendMode)
1127 { 1144 {
1145 ASSERT(m_canvas);
1128 if (contextDisabled() || !picture) 1146 if (contextDisabled() || !picture)
1129 return; 1147 return;
1130 1148
1131 SkMatrix ctm = m_canvas->getTotalMatrix(); 1149 SkMatrix ctm = m_canvas->getTotalMatrix();
1132 SkRect deviceDest; 1150 SkRect deviceDest;
1133 ctm.mapRect(&deviceDest, dest); 1151 ctm.mapRect(&deviceDest, dest);
1134 SkRect sourceBounds = WebCoreFloatRectToSKRect(src); 1152 SkRect sourceBounds = WebCoreFloatRectToSKRect(src);
1135 1153
1136 RefPtr<SkPictureImageFilter> pictureFilter = adoptRef(SkPictureImageFilter:: Create(picture.get(), sourceBounds)); 1154 RefPtr<SkPictureImageFilter> pictureFilter = adoptRef(SkPictureImageFilter:: Create(picture.get(), sourceBounds));
1137 SkMatrix layerScale; 1155 SkMatrix layerScale;
1138 layerScale.setScale(deviceDest.width() / src.width(), deviceDest.height() / src.height()); 1156 layerScale.setScale(deviceDest.width() / src.width(), deviceDest.height() / src.height());
1139 RefPtr<SkMatrixImageFilter> matrixFilter = adoptRef(SkMatrixImageFilter::Cre ate(layerScale, SkPaint::kLow_FilterLevel, pictureFilter.get())); 1157 RefPtr<SkMatrixImageFilter> matrixFilter = adoptRef(SkMatrixImageFilter::Cre ate(layerScale, SkPaint::kLow_FilterLevel, pictureFilter.get()));
1140 SkPaint picturePaint; 1158 SkPaint picturePaint;
1141 picturePaint.setXfermodeMode(WebCoreCompositeToSkiaComposite(op, blendMode)) ; 1159 picturePaint.setXfermodeMode(WebCoreCompositeToSkiaComposite(op, blendMode)) ;
1142 picturePaint.setImageFilter(matrixFilter.get()); 1160 picturePaint.setImageFilter(matrixFilter.get());
1143 SkRect layerBounds = SkRect::MakeWH(std::max(deviceDest.width(), sourceBound s.width()), std::max(deviceDest.height(), sourceBounds.height())); 1161 SkRect layerBounds = SkRect::MakeWH(std::max(deviceDest.width(), sourceBound s.width()), std::max(deviceDest.height(), sourceBounds.height()));
1144 m_canvas->save(); 1162 m_canvas->save();
1145 m_canvas->resetMatrix(); 1163 m_canvas->resetMatrix();
1146 m_canvas->translate(deviceDest.x(), deviceDest.y()); 1164 m_canvas->translate(deviceDest.x(), deviceDest.y());
1147 m_canvas->saveLayer(&layerBounds, &picturePaint); 1165 m_canvas->saveLayer(&layerBounds, &picturePaint);
1148 m_canvas->restore(); 1166 m_canvas->restore();
1149 m_canvas->restore(); 1167 m_canvas->restore();
1150 } 1168 }
1151 1169
1152 void GraphicsContext::writePixels(const SkImageInfo& info, const void* pixels, s ize_t rowBytes, int x, int y) 1170 void GraphicsContext::writePixels(const SkImageInfo& info, const void* pixels, s ize_t rowBytes, int x, int y)
1153 { 1171 {
1172 ASSERT(m_canvas);
1154 if (contextDisabled()) 1173 if (contextDisabled())
1155 return; 1174 return;
1156 1175
1157 m_canvas->writePixels(info, pixels, rowBytes, x, y); 1176 m_canvas->writePixels(info, pixels, rowBytes, x, y);
1158 1177
1159 if (regionTrackingEnabled()) { 1178 if (regionTrackingEnabled()) {
1160 SkRect rect = SkRect::MakeXYWH(x, y, info.width(), info.height()); 1179 SkRect rect = SkRect::MakeXYWH(x, y, info.width(), info.height());
1161 SkPaint paint; 1180 SkPaint paint;
1162 1181
1163 paint.setXfermodeMode(SkXfermode::kSrc_Mode); 1182 paint.setXfermodeMode(SkXfermode::kSrc_Mode);
(...skipping 13 matching lines...) Expand all
1177 1196
1178 if (!bitmap.getTexture()) { 1197 if (!bitmap.getTexture()) {
1179 SkAutoLockPixels alp(bitmap); 1198 SkAutoLockPixels alp(bitmap);
1180 if (bitmap.getPixels()) 1199 if (bitmap.getPixels())
1181 writePixels(bitmap.info(), bitmap.getPixels(), bitmap.rowBytes(), x, y); 1200 writePixels(bitmap.info(), bitmap.getPixels(), bitmap.rowBytes(), x, y);
1182 } 1201 }
1183 } 1202 }
1184 1203
1185 void GraphicsContext::drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, const SkPaint* paint) 1204 void GraphicsContext::drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, const SkPaint* paint)
1186 { 1205 {
1206 ASSERT(m_canvas);
1187 if (contextDisabled()) 1207 if (contextDisabled())
1188 return; 1208 return;
1189 1209
1190 m_canvas->drawBitmap(bitmap, left, top, paint); 1210 m_canvas->drawBitmap(bitmap, left, top, paint);
1191 1211
1192 if (regionTrackingEnabled()) { 1212 if (regionTrackingEnabled()) {
1193 SkRect rect = SkRect::MakeXYWH(left, top, bitmap.width(), bitmap.height( )); 1213 SkRect rect = SkRect::MakeXYWH(left, top, bitmap.width(), bitmap.height( ));
1194 m_trackedRegion.didDrawRect(this, rect, *paint, &bitmap); 1214 m_trackedRegion.didDrawRect(this, rect, *paint, &bitmap);
1195 } 1215 }
1196 } 1216 }
1197 1217
1198 void GraphicsContext::drawBitmapRect(const SkBitmap& bitmap, const SkRect* src, 1218 void GraphicsContext::drawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
1199 const SkRect& dst, const SkPaint* paint) 1219 const SkRect& dst, const SkPaint* paint)
1200 { 1220 {
1221 ASSERT(m_canvas);
1201 if (contextDisabled()) 1222 if (contextDisabled())
1202 return; 1223 return;
1203 1224
1204 SkCanvas::DrawBitmapRectFlags flags = 1225 SkCanvas::DrawBitmapRectFlags flags =
1205 immutableState()->shouldClampToSourceRect() ? SkCanvas::kNone_DrawBitmap RectFlag : SkCanvas::kBleed_DrawBitmapRectFlag; 1226 immutableState()->shouldClampToSourceRect() ? SkCanvas::kNone_DrawBitmap RectFlag : SkCanvas::kBleed_DrawBitmapRectFlag;
1206 1227
1207 m_canvas->drawBitmapRectToRect(bitmap, src, dst, paint, flags); 1228 m_canvas->drawBitmapRectToRect(bitmap, src, dst, paint, flags);
1208 1229
1209 if (regionTrackingEnabled()) 1230 if (regionTrackingEnabled())
1210 m_trackedRegion.didDrawRect(this, dst, *paint, &bitmap); 1231 m_trackedRegion.didDrawRect(this, dst, *paint, &bitmap);
1211 } 1232 }
1212 1233
1213 void GraphicsContext::drawOval(const SkRect& oval, const SkPaint& paint) 1234 void GraphicsContext::drawOval(const SkRect& oval, const SkPaint& paint)
1214 { 1235 {
1236 ASSERT(m_canvas);
1215 if (contextDisabled()) 1237 if (contextDisabled())
1216 return; 1238 return;
1217 1239
1218 m_canvas->drawOval(oval, paint); 1240 m_canvas->drawOval(oval, paint);
1219 1241
1220 if (regionTrackingEnabled()) 1242 if (regionTrackingEnabled())
1221 m_trackedRegion.didDrawBounded(this, oval, paint); 1243 m_trackedRegion.didDrawBounded(this, oval, paint);
1222 } 1244 }
1223 1245
1224 void GraphicsContext::drawPath(const SkPath& path, const SkPaint& paint) 1246 void GraphicsContext::drawPath(const SkPath& path, const SkPaint& paint)
1225 { 1247 {
1248 ASSERT(m_canvas);
1226 if (contextDisabled()) 1249 if (contextDisabled())
1227 return; 1250 return;
1228 1251
1229 m_canvas->drawPath(path, paint); 1252 m_canvas->drawPath(path, paint);
1230 1253
1231 if (regionTrackingEnabled()) 1254 if (regionTrackingEnabled())
1232 m_trackedRegion.didDrawPath(this, path, paint); 1255 m_trackedRegion.didDrawPath(this, path, paint);
1233 } 1256 }
1234 1257
1235 void GraphicsContext::drawRect(const SkRect& rect, const SkPaint& paint) 1258 void GraphicsContext::drawRect(const SkRect& rect, const SkPaint& paint)
1236 { 1259 {
1260 ASSERT(m_canvas);
1237 if (contextDisabled()) 1261 if (contextDisabled())
1238 return; 1262 return;
1239 1263
1240 m_canvas->drawRect(rect, paint); 1264 m_canvas->drawRect(rect, paint);
1241 1265
1242 if (regionTrackingEnabled()) 1266 if (regionTrackingEnabled())
1243 m_trackedRegion.didDrawRect(this, rect, paint, 0); 1267 m_trackedRegion.didDrawRect(this, rect, paint, 0);
1244 } 1268 }
1245 1269
1246 void GraphicsContext::drawRRect(const SkRRect& rrect, const SkPaint& paint) 1270 void GraphicsContext::drawRRect(const SkRRect& rrect, const SkPaint& paint)
1247 { 1271 {
1272 ASSERT(m_canvas);
1248 if (contextDisabled()) 1273 if (contextDisabled())
1249 return; 1274 return;
1250 1275
1251 m_canvas->drawRRect(rrect, paint); 1276 m_canvas->drawRRect(rrect, paint);
1252 1277
1253 if (regionTrackingEnabled()) 1278 if (regionTrackingEnabled())
1254 m_trackedRegion.didDrawBounded(this, rrect.rect(), paint); 1279 m_trackedRegion.didDrawBounded(this, rrect.rect(), paint);
1255 } 1280 }
1256 1281
1257 void GraphicsContext::didDrawRect(const SkRect& rect, const SkPaint& paint, cons t SkBitmap* bitmap) 1282 void GraphicsContext::didDrawRect(const SkRect& rect, const SkPaint& paint, cons t SkBitmap* bitmap)
1258 { 1283 {
1259 if (contextDisabled()) 1284 if (contextDisabled())
1260 return; 1285 return;
1261 1286
1262 if (regionTrackingEnabled()) 1287 if (regionTrackingEnabled())
1263 m_trackedRegion.didDrawRect(this, rect, paint, bitmap); 1288 m_trackedRegion.didDrawRect(this, rect, paint, bitmap);
1264 } 1289 }
1265 1290
1266 void GraphicsContext::drawPosText(const void* text, size_t byteLength, 1291 void GraphicsContext::drawPosText(const void* text, size_t byteLength,
1267 const SkPoint pos[], const SkRect& textRect, const SkPaint& paint) 1292 const SkPoint pos[], const SkRect& textRect, const SkPaint& paint)
1268 { 1293 {
1294 ASSERT(m_canvas);
1269 if (contextDisabled()) 1295 if (contextDisabled())
1270 return; 1296 return;
1271 1297
1272 m_canvas->drawPosText(text, byteLength, pos, paint); 1298 m_canvas->drawPosText(text, byteLength, pos, paint);
1273 didDrawTextInRect(textRect); 1299 didDrawTextInRect(textRect);
1274 1300
1275 // FIXME: compute bounds for positioned text. 1301 // FIXME: compute bounds for positioned text.
1276 if (regionTrackingEnabled()) 1302 if (regionTrackingEnabled())
1277 m_trackedRegion.didDrawUnbounded(this, paint, RegionTracker::FillOrStrok e); 1303 m_trackedRegion.didDrawUnbounded(this, paint, RegionTracker::FillOrStrok e);
1278 } 1304 }
1279 1305
1280 void GraphicsContext::drawPosTextH(const void* text, size_t byteLength, 1306 void GraphicsContext::drawPosTextH(const void* text, size_t byteLength,
1281 const SkScalar xpos[], SkScalar constY, const SkRect& textRect, const SkPain t& paint) 1307 const SkScalar xpos[], SkScalar constY, const SkRect& textRect, const SkPain t& paint)
1282 { 1308 {
1309 ASSERT(m_canvas);
1283 if (contextDisabled()) 1310 if (contextDisabled())
1284 return; 1311 return;
1285 1312
1286 m_canvas->drawPosTextH(text, byteLength, xpos, constY, paint); 1313 m_canvas->drawPosTextH(text, byteLength, xpos, constY, paint);
1287 didDrawTextInRect(textRect); 1314 didDrawTextInRect(textRect);
1288 1315
1289 // FIXME: compute bounds for positioned text. 1316 // FIXME: compute bounds for positioned text.
1290 if (regionTrackingEnabled()) 1317 if (regionTrackingEnabled())
1291 m_trackedRegion.didDrawUnbounded(this, paint, RegionTracker::FillOrStrok e); 1318 m_trackedRegion.didDrawUnbounded(this, paint, RegionTracker::FillOrStrok e);
1292 } 1319 }
1293 1320
1294 void GraphicsContext::drawTextBlob(const SkTextBlob* blob, const SkPoint& origin , const SkPaint& paint) 1321 void GraphicsContext::drawTextBlob(const SkTextBlob* blob, const SkPoint& origin , const SkPaint& paint)
1295 { 1322 {
1323 ASSERT(m_canvas);
1296 if (contextDisabled()) 1324 if (contextDisabled())
1297 return; 1325 return;
1298 1326
1299 m_canvas->drawTextBlob(blob, origin.x(), origin.y(), paint); 1327 m_canvas->drawTextBlob(blob, origin.x(), origin.y(), paint);
1300 1328
1301 SkRect bounds = blob->bounds(); 1329 SkRect bounds = blob->bounds();
1302 bounds.offset(origin); 1330 bounds.offset(origin);
1303 didDrawTextInRect(bounds); 1331 didDrawTextInRect(bounds);
1304 1332
1305 // FIXME: use bounds here if it helps performance. 1333 // FIXME: use bounds here if it helps performance.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 if (contextDisabled()) 1367 if (contextDisabled())
1340 return; 1368 return;
1341 1369
1342 SkRect r = rect; 1370 SkRect r = rect;
1343 SkPaint paint = immutableState()->fillPaint(); 1371 SkPaint paint = immutableState()->fillPaint();
1344 paint.setColor(color.rgb()); 1372 paint.setColor(color.rgb());
1345 drawRect(r, paint); 1373 drawRect(r, paint);
1346 } 1374 }
1347 1375
1348 void GraphicsContext::fillBetweenRoundedRects(const IntRect& outer, const IntSiz e& outerTopLeft, const IntSize& outerTopRight, const IntSize& outerBottomLeft, c onst IntSize& outerBottomRight, 1376 void GraphicsContext::fillBetweenRoundedRects(const IntRect& outer, const IntSiz e& outerTopLeft, const IntSize& outerTopRight, const IntSize& outerBottomLeft, c onst IntSize& outerBottomRight,
1349 const IntRect& inner, const IntSize& innerTopLeft, const IntSize& innerTopRi ght, const IntSize& innerBottomLeft, const IntSize& innerBottomRight, const Colo r& color) { 1377 const IntRect& inner, const IntSize& innerTopLeft, const IntSize& innerTopRi ght, const IntSize& innerBottomLeft, const IntSize& innerBottomRight, const Colo r& color)
1378 {
1379 ASSERT(m_canvas);
1350 if (contextDisabled()) 1380 if (contextDisabled())
1351 return; 1381 return;
1352 1382
1353 SkVector outerRadii[4]; 1383 SkVector outerRadii[4];
1354 SkVector innerRadii[4]; 1384 SkVector innerRadii[4];
1355 setRadii(outerRadii, outerTopLeft, outerTopRight, outerBottomRight, outerBot tomLeft); 1385 setRadii(outerRadii, outerTopLeft, outerTopRight, outerBottomRight, outerBot tomLeft);
1356 setRadii(innerRadii, innerTopLeft, innerTopRight, innerBottomRight, innerBot tomLeft); 1386 setRadii(innerRadii, innerTopLeft, innerTopRight, innerBottomRight, innerBot tomLeft);
1357 1387
1358 SkRRect rrOuter; 1388 SkRRect rrOuter;
1359 SkRRect rrInner; 1389 SkRRect rrInner;
(...skipping 11 matching lines...) Expand all
1371 1401
1372 void GraphicsContext::fillBetweenRoundedRects(const RoundedRect& outer, const Ro undedRect& inner, const Color& color) 1402 void GraphicsContext::fillBetweenRoundedRects(const RoundedRect& outer, const Ro undedRect& inner, const Color& color)
1373 { 1403 {
1374 fillBetweenRoundedRects(outer.rect(), outer.radii().topLeft(), outer.radii() .topRight(), outer.radii().bottomLeft(), outer.radii().bottomRight(), 1404 fillBetweenRoundedRects(outer.rect(), outer.radii().topLeft(), outer.radii() .topRight(), outer.radii().bottomLeft(), outer.radii().bottomRight(),
1375 inner.rect(), inner.radii().topLeft(), inner.radii().topRight(), inner.r adii().bottomLeft(), inner.radii().bottomRight(), color); 1405 inner.rect(), inner.radii().topLeft(), inner.radii().topRight(), inner.r adii().bottomLeft(), inner.radii().bottomRight(), color);
1376 } 1406 }
1377 1407
1378 void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLef t, const IntSize& topRight, 1408 void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLef t, const IntSize& topRight,
1379 const IntSize& bottomLeft, const IntSize& bottomRight, const Color& color) 1409 const IntSize& bottomLeft, const IntSize& bottomRight, const Color& color)
1380 { 1410 {
1411 ASSERT(m_canvas);
1381 if (contextDisabled()) 1412 if (contextDisabled())
1382 return; 1413 return;
1383 1414
1384 if (topLeft.width() + topRight.width() > rect.width() 1415 if (topLeft.width() + topRight.width() > rect.width()
1385 || bottomLeft.width() + bottomRight.width() > rect.width() 1416 || bottomLeft.width() + bottomRight.width() > rect.width()
1386 || topLeft.height() + bottomLeft.height() > rect.height() 1417 || topLeft.height() + bottomLeft.height() > rect.height()
1387 || topRight.height() + bottomRight.height() > rect.height()) { 1418 || topRight.height() + bottomRight.height() > rect.height()) {
1388 // Not all the radii fit, return a rect. This matches the behavior of 1419 // Not all the radii fit, return a rect. This matches the behavior of
1389 // Path::createRoundedRectangle. Without this we attempt to draw a round 1420 // Path::createRoundedRectangle. Without this we attempt to draw a round
1390 // shadow for a square box. 1421 // shadow for a square box.
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1546 1577
1547 SkPath::FillType temporaryFillType = WebCoreWindRuleToSkFillType(clipRule); 1578 SkPath::FillType temporaryFillType = WebCoreWindRuleToSkFillType(clipRule);
1548 path.setFillType(temporaryFillType); 1579 path.setFillType(temporaryFillType);
1549 clipPath(path); 1580 clipPath(path);
1550 1581
1551 path.setFillType(previousFillType); 1582 path.setFillType(previousFillType);
1552 } 1583 }
1553 1584
1554 void GraphicsContext::clipRect(const SkRect& rect, AntiAliasingMode aa, SkRegion ::Op op) 1585 void GraphicsContext::clipRect(const SkRect& rect, AntiAliasingMode aa, SkRegion ::Op op)
1555 { 1586 {
1587 ASSERT(m_canvas);
1556 if (contextDisabled()) 1588 if (contextDisabled())
1557 return; 1589 return;
1558 1590
1559 realizeCanvasSave(); 1591 realizeCanvasSave();
1560 1592
1561 m_canvas->clipRect(rect, op, aa == AntiAliased); 1593 m_canvas->clipRect(rect, op, aa == AntiAliased);
1562 } 1594 }
1563 1595
1564 void GraphicsContext::clipPath(const SkPath& path, AntiAliasingMode aa, SkRegion ::Op op) 1596 void GraphicsContext::clipPath(const SkPath& path, AntiAliasingMode aa, SkRegion ::Op op)
1565 { 1597 {
1598 ASSERT(m_canvas);
1566 if (contextDisabled()) 1599 if (contextDisabled())
1567 return; 1600 return;
1568 1601
1569 realizeCanvasSave(); 1602 realizeCanvasSave();
1570 1603
1571 m_canvas->clipPath(path, op, aa == AntiAliased); 1604 m_canvas->clipPath(path, op, aa == AntiAliased);
1572 } 1605 }
1573 1606
1574 void GraphicsContext::clipRRect(const SkRRect& rect, AntiAliasingMode aa, SkRegi on::Op op) 1607 void GraphicsContext::clipRRect(const SkRRect& rect, AntiAliasingMode aa, SkRegi on::Op op)
1575 { 1608 {
1609 ASSERT(m_canvas);
1576 if (contextDisabled()) 1610 if (contextDisabled())
1577 return; 1611 return;
1578 1612
1579 realizeCanvasSave(); 1613 realizeCanvasSave();
1580 1614
1581 m_canvas->clipRRect(rect, op, aa == AntiAliased); 1615 m_canvas->clipRRect(rect, op, aa == AntiAliased);
1582 } 1616 }
1583 1617
1584 void GraphicsContext::beginCull(const FloatRect& rect) 1618 void GraphicsContext::beginCull(const FloatRect& rect)
1585 { 1619 {
1620 ASSERT(m_canvas);
1586 if (contextDisabled()) 1621 if (contextDisabled())
1587 return; 1622 return;
1588 1623
1589 realizeCanvasSave(); 1624 realizeCanvasSave();
1590 m_canvas->pushCull(rect); 1625 m_canvas->pushCull(rect);
1591 } 1626 }
1592 1627
1593 void GraphicsContext::endCull() 1628 void GraphicsContext::endCull()
1594 { 1629 {
1630 ASSERT(m_canvas);
1595 if (contextDisabled()) 1631 if (contextDisabled())
1596 return; 1632 return;
1597 1633
1598 realizeCanvasSave(); 1634 realizeCanvasSave();
1599 1635
1600 m_canvas->popCull(); 1636 m_canvas->popCull();
1601 } 1637 }
1602 1638
1603 void GraphicsContext::rotate(float angleInRadians) 1639 void GraphicsContext::rotate(float angleInRadians)
1604 { 1640 {
1641 ASSERT(m_canvas);
1605 if (contextDisabled()) 1642 if (contextDisabled())
1606 return; 1643 return;
1607 1644
1608 realizeCanvasSave(); 1645 realizeCanvasSave();
1609 1646
1610 m_canvas->rotate(WebCoreFloatToSkScalar(angleInRadians * (180.0f / 3.1415926 5f))); 1647 m_canvas->rotate(WebCoreFloatToSkScalar(angleInRadians * (180.0f / 3.1415926 5f)));
1611 } 1648 }
1612 1649
1613 void GraphicsContext::translate(float x, float y) 1650 void GraphicsContext::translate(float x, float y)
1614 { 1651 {
1652 ASSERT(m_canvas);
1615 if (contextDisabled()) 1653 if (contextDisabled())
1616 return; 1654 return;
1617 1655
1618 if (!x && !y) 1656 if (!x && !y)
1619 return; 1657 return;
1620 1658
1621 realizeCanvasSave(); 1659 realizeCanvasSave();
1622 1660
1623 m_canvas->translate(WebCoreFloatToSkScalar(x), WebCoreFloatToSkScalar(y)); 1661 m_canvas->translate(WebCoreFloatToSkScalar(x), WebCoreFloatToSkScalar(y));
1624 } 1662 }
1625 1663
1626 void GraphicsContext::scale(float x, float y) 1664 void GraphicsContext::scale(float x, float y)
1627 { 1665 {
1666 ASSERT(m_canvas);
1628 if (contextDisabled()) 1667 if (contextDisabled())
1629 return; 1668 return;
1630 1669
1631 if (x == 1.0f && y == 1.0f) 1670 if (x == 1.0f && y == 1.0f)
1632 return; 1671 return;
1633 1672
1634 realizeCanvasSave(); 1673 realizeCanvasSave();
1635 1674
1636 m_canvas->scale(WebCoreFloatToSkScalar(x), WebCoreFloatToSkScalar(y)); 1675 m_canvas->scale(WebCoreFloatToSkScalar(x), WebCoreFloatToSkScalar(y));
1637 } 1676 }
1638 1677
1639 void GraphicsContext::setURLForRect(const KURL& link, const IntRect& destRect) 1678 void GraphicsContext::setURLForRect(const KURL& link, const IntRect& destRect)
1640 { 1679 {
1680 ASSERT(m_canvas);
1641 if (contextDisabled()) 1681 if (contextDisabled())
1642 return; 1682 return;
1643 1683
1644 SkAutoDataUnref url(SkData::NewWithCString(link.string().utf8().data())); 1684 SkAutoDataUnref url(SkData::NewWithCString(link.string().utf8().data()));
1645 SkAnnotateRectWithURL(m_canvas, destRect, url.get()); 1685 SkAnnotateRectWithURL(m_canvas, destRect, url.get());
1646 } 1686 }
1647 1687
1648 void GraphicsContext::setURLFragmentForRect(const String& destName, const IntRec t& rect) 1688 void GraphicsContext::setURLFragmentForRect(const String& destName, const IntRec t& rect)
1649 { 1689 {
1690 ASSERT(m_canvas);
1650 if (contextDisabled()) 1691 if (contextDisabled())
1651 return; 1692 return;
1652 1693
1653 SkAutoDataUnref skDestName(SkData::NewWithCString(destName.utf8().data())); 1694 SkAutoDataUnref skDestName(SkData::NewWithCString(destName.utf8().data()));
1654 SkAnnotateLinkToDestination(m_canvas, rect, skDestName.get()); 1695 SkAnnotateLinkToDestination(m_canvas, rect, skDestName.get());
1655 } 1696 }
1656 1697
1657 void GraphicsContext::addURLTargetAtPoint(const String& name, const IntPoint& po s) 1698 void GraphicsContext::addURLTargetAtPoint(const String& name, const IntPoint& po s)
1658 { 1699 {
1700 ASSERT(m_canvas);
1659 if (contextDisabled()) 1701 if (contextDisabled())
1660 return; 1702 return;
1661 1703
1662 SkAutoDataUnref nameData(SkData::NewWithCString(name.utf8().data())); 1704 SkAutoDataUnref nameData(SkData::NewWithCString(name.utf8().data()));
1663 SkAnnotateNamedDestination(m_canvas, SkPoint::Make(pos.x(), pos.y()), nameDa ta); 1705 SkAnnotateNamedDestination(m_canvas, SkPoint::Make(pos.x(), pos.y()), nameDa ta);
1664 } 1706 }
1665 1707
1666 AffineTransform GraphicsContext::getCTM() const 1708 AffineTransform GraphicsContext::getCTM() const
1667 { 1709 {
1668 if (contextDisabled()) 1710 if (contextDisabled())
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1980 // FIXME: This is to not break tests (it results in the filter bitmap fl ag 2022 // FIXME: This is to not break tests (it results in the filter bitmap fl ag
1981 // being set to true). We need to decide if we respect InterpolationNone 2023 // being set to true). We need to decide if we respect InterpolationNone
1982 // being returned from computeInterpolationQuality. 2024 // being returned from computeInterpolationQuality.
1983 resampling = InterpolationLow; 2025 resampling = InterpolationLow;
1984 } 2026 }
1985 resampling = limitInterpolationQuality(this, resampling); 2027 resampling = limitInterpolationQuality(this, resampling);
1986 paint->setFilterLevel(static_cast<SkPaint::FilterLevel>(resampling)); 2028 paint->setFilterLevel(static_cast<SkPaint::FilterLevel>(resampling));
1987 } 2029 }
1988 2030
1989 } // namespace blink 2031 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/graphics/GraphicsContext.h ('k') | Source/web/LinkHighlight.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698