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

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: addressed comments 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "third_party/skia/include/core/SkDevice.h" 42 #include "third_party/skia/include/core/SkDevice.h"
43 #include "third_party/skia/include/core/SkPicture.h" 43 #include "third_party/skia/include/core/SkPicture.h"
44 #include "third_party/skia/include/core/SkRRect.h" 44 #include "third_party/skia/include/core/SkRRect.h"
45 #include "third_party/skia/include/core/SkRefCnt.h" 45 #include "third_party/skia/include/core/SkRefCnt.h"
46 #include "third_party/skia/include/core/SkSurface.h" 46 #include "third_party/skia/include/core/SkSurface.h"
47 #include "third_party/skia/include/effects/SkBlurMaskFilter.h" 47 #include "third_party/skia/include/effects/SkBlurMaskFilter.h"
48 #include "third_party/skia/include/effects/SkCornerPathEffect.h" 48 #include "third_party/skia/include/effects/SkCornerPathEffect.h"
49 #include "third_party/skia/include/effects/SkLumaColorFilter.h" 49 #include "third_party/skia/include/effects/SkLumaColorFilter.h"
50 #include "third_party/skia/include/gpu/GrRenderTarget.h" 50 #include "third_party/skia/include/gpu/GrRenderTarget.h"
51 #include "third_party/skia/include/gpu/GrTexture.h" 51 #include "third_party/skia/include/gpu/GrTexture.h"
52 #include "third_party/skia/include/pathops/SkPathOps.h"
52 #include "wtf/Assertions.h" 53 #include "wtf/Assertions.h"
53 #include "wtf/MathExtras.h" 54 #include "wtf/MathExtras.h"
54 55
55 using namespace std; 56 using namespace std;
56 using blink::WebBlendMode; 57 using blink::WebBlendMode;
57 58
58 namespace WebCore { 59 namespace WebCore {
59 60
60 namespace { 61 namespace {
61 62
(...skipping 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 SkPath& path = const_cast<SkPath&>(pathToClip.skPath()); 1367 SkPath& path = const_cast<SkPath&>(pathToClip.skPath());
1367 SkPath::FillType previousFillType = path.getFillType(); 1368 SkPath::FillType previousFillType = path.getFillType();
1368 1369
1369 SkPath::FillType temporaryFillType = clipRule == RULE_EVENODD ? SkPath::kEve nOdd_FillType : SkPath::kWinding_FillType; 1370 SkPath::FillType temporaryFillType = clipRule == RULE_EVENODD ? SkPath::kEve nOdd_FillType : SkPath::kWinding_FillType;
1370 path.setFillType(temporaryFillType); 1371 path.setFillType(temporaryFillType);
1371 clipPath(path, AntiAliased); 1372 clipPath(path, AntiAliased);
1372 1373
1373 path.setFillType(previousFillType); 1374 path.setFillType(previousFillType);
1374 } 1375 }
1375 1376
1377 Path GraphicsContext::getCurrentClipPath()
1378 {
1379 if (contextDisabled())
1380 return Path();
1381
1382 const SkClipStack* clipStack = m_canvas->getClipStack();
1383 SkClipStack::Iter iter(*clipStack, SkClipStack::Iter::kBottom_IterStart);
1384 const SkClipStack::Element* element;
1385
1386 SkPath totalClipPath;
1387 totalClipPath.setFillType(SkPath::kInverseEvenOdd_FillType);
1388
1389 while ((element = iter.next())) {
1390
1391 SkClipStack::Element::Type type = element->getType();
1392 SkPath clipPath;
1393 if (type != SkClipStack::Element::kEmpty_Type)
1394 element->asPath(&clipPath);
1395
1396 SkRegion::Op elementOp = element->getOp();
1397 if (elementOp == SkRegion::kReplace_Op)
1398 totalClipPath = clipPath;
1399 else
1400 Op(totalClipPath, clipPath, (SkPathOp)elementOp, &totalClipPath);
1401 }
1402
1403 return Path(totalClipPath);
1404 }
1405
1376 void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* poin ts, bool antialiased) 1406 void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* poin ts, bool antialiased)
1377 { 1407 {
1378 if (contextDisabled()) 1408 if (contextDisabled())
1379 return; 1409 return;
1380 1410
1381 if (numPoints <= 1) 1411 if (numPoints <= 1)
1382 return; 1412 return;
1383 1413
1384 SkPath path; 1414 SkPath path;
1385 setPathFromConvexPoints(&path, numPoints, points); 1415 setPathFromConvexPoints(&path, numPoints, points);
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
1816 1846
1817 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) 1847 void GraphicsContext::didDrawTextInRect(const SkRect& textRect)
1818 { 1848 {
1819 if (m_trackTextRegion) { 1849 if (m_trackTextRegion) {
1820 TRACE_EVENT0("skia", "PlatformContextSkia::trackTextRegion"); 1850 TRACE_EVENT0("skia", "PlatformContextSkia::trackTextRegion");
1821 m_textRegion.join(textRect); 1851 m_textRegion.join(textRect);
1822 } 1852 }
1823 } 1853 }
1824 1854
1825 } 1855 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698