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

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

Issue 300223009: Implement basic parts of hit regions on canvas2d. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add header Created 6 years, 6 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
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 20 matching lines...) Expand all
31 #include "platform/geometry/IntRect.h" 31 #include "platform/geometry/IntRect.h"
32 #include "platform/geometry/RoundedRect.h" 32 #include "platform/geometry/RoundedRect.h"
33 #include "platform/graphics/BitmapImage.h" 33 #include "platform/graphics/BitmapImage.h"
34 #include "platform/graphics/DisplayList.h" 34 #include "platform/graphics/DisplayList.h"
35 #include "platform/graphics/Gradient.h" 35 #include "platform/graphics/Gradient.h"
36 #include "platform/graphics/ImageBuffer.h" 36 #include "platform/graphics/ImageBuffer.h"
37 #include "platform/text/BidiResolver.h" 37 #include "platform/text/BidiResolver.h"
38 #include "platform/text/TextRunIterator.h" 38 #include "platform/text/TextRunIterator.h"
39 #include "platform/weborigin/KURL.h" 39 #include "platform/weborigin/KURL.h"
40 #include "third_party/skia/include/core/SkAnnotation.h" 40 #include "third_party/skia/include/core/SkAnnotation.h"
41 #include "third_party/skia/include/core/SkClipStack.h"
41 #include "third_party/skia/include/core/SkColorFilter.h" 42 #include "third_party/skia/include/core/SkColorFilter.h"
42 #include "third_party/skia/include/core/SkData.h" 43 #include "third_party/skia/include/core/SkData.h"
43 #include "third_party/skia/include/core/SkDevice.h" 44 #include "third_party/skia/include/core/SkDevice.h"
44 #include "third_party/skia/include/core/SkPicture.h" 45 #include "third_party/skia/include/core/SkPicture.h"
45 #include "third_party/skia/include/core/SkRRect.h" 46 #include "third_party/skia/include/core/SkRRect.h"
46 #include "third_party/skia/include/core/SkRefCnt.h" 47 #include "third_party/skia/include/core/SkRefCnt.h"
47 #include "third_party/skia/include/core/SkSurface.h" 48 #include "third_party/skia/include/core/SkSurface.h"
48 #include "third_party/skia/include/effects/SkBlurMaskFilter.h" 49 #include "third_party/skia/include/effects/SkBlurMaskFilter.h"
49 #include "third_party/skia/include/effects/SkCornerPathEffect.h" 50 #include "third_party/skia/include/effects/SkCornerPathEffect.h"
50 #include "third_party/skia/include/effects/SkLumaColorFilter.h" 51 #include "third_party/skia/include/effects/SkLumaColorFilter.h"
51 #include "third_party/skia/include/gpu/GrRenderTarget.h" 52 #include "third_party/skia/include/gpu/GrRenderTarget.h"
52 #include "third_party/skia/include/gpu/GrTexture.h" 53 #include "third_party/skia/include/gpu/GrTexture.h"
54 #include "third_party/skia/include/pathops/SkPathOps.h"
53 #include "wtf/Assertions.h" 55 #include "wtf/Assertions.h"
54 #include "wtf/MathExtras.h" 56 #include "wtf/MathExtras.h"
55 57
56 using namespace std; 58 using namespace std;
57 using blink::WebBlendMode; 59 using blink::WebBlendMode;
58 60
59 namespace WebCore { 61 namespace WebCore {
60 62
61 namespace { 63 namespace {
62 64
(...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 SkPath& path = const_cast<SkPath&>(pathToClip.skPath()); 1368 SkPath& path = const_cast<SkPath&>(pathToClip.skPath());
1367 SkPath::FillType previousFillType = path.getFillType(); 1369 SkPath::FillType previousFillType = path.getFillType();
1368 1370
1369 SkPath::FillType temporaryFillType = clipRule == RULE_EVENODD ? SkPath::kEve nOdd_FillType : SkPath::kWinding_FillType; 1371 SkPath::FillType temporaryFillType = clipRule == RULE_EVENODD ? SkPath::kEve nOdd_FillType : SkPath::kWinding_FillType;
1370 path.setFillType(temporaryFillType); 1372 path.setFillType(temporaryFillType);
1371 clipPath(path, AntiAliased); 1373 clipPath(path, AntiAliased);
1372 1374
1373 path.setFillType(previousFillType); 1375 path.setFillType(previousFillType);
1374 } 1376 }
1375 1377
1378 bool GraphicsContext::isClipMode() const
1379 {
1380 if (contextDisabled())
1381 return false;
1382
1383 return m_canvas->getClipStack()->getSaveCount() != 0;
1384 }
1385
1386 Path GraphicsContext::getCurrentClipPath() const
1387 {
1388 if (contextDisabled())
1389 return Path();
1390
1391 const SkClipStack* clipStack = m_canvas->getClipStack();
1392 SkClipStack::Iter iter(*clipStack, SkClipStack::Iter::kBottom_IterStart);
1393 const SkClipStack::Element* element;
1394
1395 SkPath totalClipPath;
1396 totalClipPath.setFillType(SkPath::kInverseEvenOdd_FillType);
1397
1398 while ((element = iter.next())) {
1399
1400 SkClipStack::Element::Type type = element->getType();
1401 SkPath clipPath;
1402 if (type != SkClipStack::Element::kEmpty_Type)
1403 element->asPath(&clipPath);
1404
1405 SkRegion::Op elementOp = element->getOp();
1406 if (elementOp == SkRegion::kReplace_Op)
1407 totalClipPath = clipPath;
1408 else
1409 Op(totalClipPath, clipPath, (SkPathOp)elementOp, &totalClipPath);
1410 }
1411
1412 return Path(totalClipPath);
1413 }
1414
1376 void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* poin ts, bool antialiased) 1415 void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* poin ts, bool antialiased)
1377 { 1416 {
1378 if (contextDisabled()) 1417 if (contextDisabled())
1379 return; 1418 return;
1380 1419
1381 if (numPoints <= 1) 1420 if (numPoints <= 1)
1382 return; 1421 return;
1383 1422
1384 SkPath path; 1423 SkPath path;
1385 setPathFromConvexPoints(&path, numPoints, points); 1424 setPathFromConvexPoints(&path, numPoints, points);
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
1816 1855
1817 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) 1856 void GraphicsContext::didDrawTextInRect(const SkRect& textRect)
1818 { 1857 {
1819 if (m_trackTextRegion) { 1858 if (m_trackTextRegion) {
1820 TRACE_EVENT0("skia", "GraphicsContext::didDrawTextInRect"); 1859 TRACE_EVENT0("skia", "GraphicsContext::didDrawTextInRect");
1821 m_textRegion.join(textRect); 1860 m_textRegion.join(textRect);
1822 } 1861 }
1823 } 1862 }
1824 1863
1825 } 1864 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698