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

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 clip tests 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 #if OS(MACOSX) 56 #if OS(MACOSX)
56 #include <ApplicationServices/ApplicationServices.h> 57 #include <ApplicationServices/ApplicationServices.h>
57 #endif 58 #endif
58 59
59 using namespace std; 60 using namespace std;
60 using blink::WebBlendMode; 61 using blink::WebBlendMode;
61 62
(...skipping 1308 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 SkPath& path = const_cast<SkPath&>(pathToClip.skPath()); 1371 SkPath& path = const_cast<SkPath&>(pathToClip.skPath());
1371 SkPath::FillType previousFillType = path.getFillType(); 1372 SkPath::FillType previousFillType = path.getFillType();
1372 1373
1373 SkPath::FillType temporaryFillType = clipRule == RULE_EVENODD ? SkPath::kEve nOdd_FillType : SkPath::kWinding_FillType; 1374 SkPath::FillType temporaryFillType = clipRule == RULE_EVENODD ? SkPath::kEve nOdd_FillType : SkPath::kWinding_FillType;
1374 path.setFillType(temporaryFillType); 1375 path.setFillType(temporaryFillType);
1375 clipPath(path, AntiAliased); 1376 clipPath(path, AntiAliased);
1376 1377
1377 path.setFillType(previousFillType); 1378 path.setFillType(previousFillType);
1378 } 1379 }
1379 1380
1381 Path GraphicsContext::getCurrentClipPath(const Path& path)
1382 {
1383 if (contextDisabled())
1384 return Path();
1385
1386 const SkClipStack* clipStack = m_canvas->getClipStack();
1387 SkClipStack::Iter iter(*clipStack, SkClipStack::Iter::kBottom_IterStart);
1388 const SkClipStack::Element* element;
1389
1390 SkPath totalClipPath(path.skPath());
fs 2014/06/09 11:06:27 This doesn't appear to work in the general case -
zino 2014/06/10 10:09:34 Done.
1391
1392 while ((element = iter.next())) {
1393
1394 SkClipStack::Element::Type type = element->getType();
1395 SkPath clipPath;
1396 if (type != SkClipStack::Element::kEmpty_Type)
1397 element->asPath(&clipPath);
1398
1399 SkRegion::Op elementOp = element->getOp();
1400 if (elementOp == SkRegion::kReplace_Op)
1401 totalClipPath = clipPath;
fs 2014/06/09 11:06:27 Since the result of this method should be the inte
zino 2014/06/10 10:09:34 Done.
1402 else
1403 Op(totalClipPath, clipPath, (SkPathOp)element->getOp(), &totalClipPa th);
1404 }
1405
1406 return Path(totalClipPath);
1407 }
1408
1380 void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* poin ts, bool antialiased) 1409 void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* poin ts, bool antialiased)
1381 { 1410 {
1382 if (contextDisabled()) 1411 if (contextDisabled())
1383 return; 1412 return;
1384 1413
1385 if (numPoints <= 1) 1414 if (numPoints <= 1)
1386 return; 1415 return;
1387 1416
1388 SkPath path; 1417 SkPath path;
1389 setPathFromConvexPoints(&path, numPoints, points); 1418 setPathFromConvexPoints(&path, numPoints, points);
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
1826 1855
1827 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) 1856 void GraphicsContext::didDrawTextInRect(const SkRect& textRect)
1828 { 1857 {
1829 if (m_trackTextRegion) { 1858 if (m_trackTextRegion) {
1830 TRACE_EVENT0("skia", "PlatformContextSkia::trackTextRegion"); 1859 TRACE_EVENT0("skia", "PlatformContextSkia::trackTextRegion");
1831 m_textRegion.join(textRect); 1860 m_textRegion.join(textRect);
1832 } 1861 }
1833 } 1862 }
1834 1863
1835 } 1864 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698