OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.chrome.browser.compositor; |
| 6 |
| 7 /** |
| 8 * The {@link Invalidator} invalidates a client when it is the right time. |
| 9 */ |
| 10 public class Invalidator { |
| 11 /** |
| 12 * Interface for the client that gets invalidated. |
| 13 */ |
| 14 public interface Client { |
| 15 /** |
| 16 * Do the invalidation. |
| 17 */ |
| 18 void doInvalidate(); |
| 19 } |
| 20 |
| 21 /** |
| 22 * Interface for the host that drives the invalidations. |
| 23 */ |
| 24 public interface Host { |
| 25 /** |
| 26 * Requests an invalidation of the view. |
| 27 * |
| 28 * @param view The {@link View} to invalidate. |
| 29 */ |
| 30 void deferInvalidate(Client view); |
| 31 } |
| 32 |
| 33 private Host mHost; |
| 34 |
| 35 /** |
| 36 * @param host The invalidator host, responsible for invalidating views. |
| 37 */ |
| 38 public void set(Host host) { |
| 39 mHost = host; |
| 40 } |
| 41 |
| 42 /** |
| 43 * Invalidates either immediately (if no host is specified) or at time |
| 44 * triggered by the host. |
| 45 * |
| 46 * @param client The {@link Client} to invalidate, most likely a view. |
| 47 */ |
| 48 public void invalidate(Client client) { |
| 49 if (mHost != null) { |
| 50 mHost.deferInvalidate(client); |
| 51 } else { |
| 52 client.doInvalidate(); |
| 53 } |
| 54 } |
| 55 } |
OLD | NEW |