summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/util
diff options
context:
space:
mode:
authorPaul Rohde <codelogic@google.com>2015-01-30 16:55:25 -0800
committerPaul Rohde <codelogic@google.com>2015-02-11 12:10:37 -0800
commit4c7278d85c3398c97f941efb245df6e3ccde22c4 (patch)
treef79a80010be822c09fe7b5aba5b72e938d355dfa /src/com/android/camera/util
parent07a37cae38cb971c0bccb2d76db82467242c6456 (diff)
downloadandroid_packages_apps_Camera2-4c7278d85c3398c97f941efb245df6e3ccde22c4.tar.gz
android_packages_apps_Camera2-4c7278d85c3398c97f941efb245df6e3ccde22c4.tar.bz2
android_packages_apps_Camera2-4c7278d85c3398c97f941efb245df6e3ccde22c4.zip
Fix several focus indicator edge cases.
Bug: 19213609 Bug: 18949556 Bug: 19214672 Bug: 19213602 Change-Id: I0d5c5ce8b4a62f98b44f6ae02ef1ac81d1d7f178
Diffstat (limited to 'src/com/android/camera/util')
-rw-r--r--src/com/android/camera/util/DebugBoundsRenderer.java81
1 files changed, 81 insertions, 0 deletions
diff --git a/src/com/android/camera/util/DebugBoundsRenderer.java b/src/com/android/camera/util/DebugBoundsRenderer.java
new file mode 100644
index 000000000..e93215758
--- /dev/null
+++ b/src/com/android/camera/util/DebugBoundsRenderer.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.camera.util;
+
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.Rect;
+import android.graphics.RectF;
+
+/**
+ * Drawing utilities for rendering debug artifacts.
+ */
+public class DebugBoundsRenderer {
+ /**
+ * Draw a bounding box with indicators in the corners and crosshairs in
+ * the provided canvas object.
+ */
+ public static void drawBounds(Canvas canvas, Paint paint, float size, Rect rect) {
+ drawBounds(canvas, paint, size, rect.left, rect.top, rect.right, rect.bottom);
+ }
+
+ /**
+ * Draw a bounding box with indicators in the corners and crosshairs in
+ * the provided canvas object.
+ */
+ public static void drawBounds(Canvas canvas, Paint paint, float size, RectF rect) {
+ drawBounds(canvas, paint, size, rect.left, rect.top, rect.right, rect.bottom);
+ }
+
+ /**
+ * Draw a bounding box with indicators in the corners and crosshairs in
+ * the provided canvas object.
+ */
+ public static void drawBounds(Canvas canvas, Paint paint, float size, float x1, float y1,
+ float x2, float y2) {
+ // Top left
+ // horizontal
+ canvas.drawLine(x1, y1, x1 + size, y1, paint);
+ // vertical
+ canvas.drawLine(x1, y1, x1, y1 + size, paint);
+
+ // top right
+ // horizontal
+ canvas.drawLine(x2 - size, y1, x2, y1, paint);
+ // vertical
+ canvas.drawLine(x2, y1, x2, y1 + size, paint);
+
+ // bottom right
+ // horizontal
+ canvas.drawLine(x2 - size, y2, x2, y2, paint);
+ // vertical
+ canvas.drawLine(x2, y2- size, x2, y2, paint);
+
+ // bottom left
+ // horizontal
+ canvas.drawLine(x1, y2, x1 + size, y2, paint);
+ // vertical
+ canvas.drawLine(x1, y2 - size, x1, y2, paint);
+
+ // crosshairs in the center
+ float cX = (x1 + x2) / 2;
+ float cY = (y1 + y2) / 2;
+ float halfSize = size / 2;
+ canvas.drawLine(cX - halfSize, cY, cX + halfSize, cY, paint);
+ canvas.drawLine(cX, cY - halfSize, cX, cY + halfSize, paint);
+ }
+}